Vasya is an active Internet user. One day he came across an Internet resource he liked,…
- User
Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format:
://.ru[/]
where:
- can equal either "http" (without the quotes) or "ftp" (without the quotes),
- is a non-empty string, consisting of lowercase English letters,
- the / part may not be present. If it is present, then is a non-empty string, consisting of lowercase English letters.
If string isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context).
When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".".
Help Vasya to restore the possible address of the recorded Internet resource. Input
The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only.
It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above.
Output
Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them.
Examples
Input
httpsunrux
Output
Input
ftphttprururu
Output
ftp://http.ru/ruru
Note
In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru".
Assistant
We need to solve a problem: Given a string of lowercase letters only (max length 50), which is obtained from a valid address by removing all punctuation: ":", "/", ".". So the original address has format: ://.ru[/] where protocol is "http" or "ftp", domain is non-empty lowercase letters, context if present is non-empty lowercase letters. Also note the address contains exactly two slashes after protocol? Actually the format is ://.ru[/]. So the base is protocol + "://" + domain + ".ru". Then optionally + "/" + context. So after removal of punctuation, we lose ':', '/', '.' characters. So the given string is just the concatenation of letters from protocol, domain, possibly context, and the letters "ru" from the domain suffix ".ru". Wait careful: ".ru" is a punctuation (dot) then letters "ru". The dot is removed, but the letters "ru" remain. So in the given string, the letters "ru" appear as part of the string, but they are originally from the domain suffix ".ru". However, the domain itself consists of lowercase letters, and then the TLD "ru" is appended (without dot). The domain string itself might also contain "ru" as substring. But the correct address must have a ".ru" right after the domain. So after removal of punctuation, the string will contain a contiguous substring "ru" that corresponds to the TLD? Not necessarily contiguous? Actually the ".ru" is a dot followed by letters "ru". Removing the dot merges the preceding domain letters with "ru". So the string becomes: protocol letters + (without colon slash slash) but we removed ':' and '/' so the protocol is directly concatenated with domain? Wait: original: ://.ru[/]. Punctuation characters removed: ':', '/', '.' are removed. So the string consists of letters only from protocol, domain, "ru", and context (if present). There is no separation. So the string sequence is: all letters from protocol, then the domain letters, then the letters "ru", then possibly the context letters. Because after protocol we had "://", those are punctuation chars removed. So we lose those three characters entirely. Then after domain we had ".ru", dot removed, but "ru" stays. Then optionally "/", slash removed. So overall, the concatenated letters are: protocol + domain + "ru" + (context if present). Also note: protocol is either "http" or "ftp". So the string starts with either 'h','t','t','p' or 'f','t','p'. So we are given a string s (all lowercase letters) of length <= 50. We need to reconstruct a possible original address that yields s after removal of all punctuation (':' , '/' , '.'). That means we need to insert back the missing characters in appropriate positions to get a valid address. But note the original address had a specific structure. So we need to partition s into four parts: protocol (must be "http" or "ftp"), domain (non-empty lowercase letters), the letters "ru" (as a suffix to domain? Actually the "ru" after domain is part of the string, but it might be that the domain itself contains "ru"? But the domain is a non-empty string of lowercase letters, and then there is ".ru". The dot is removed, so the domain letters are directly followed by "ru". But note: the domain could itself contain the substring "ru". However, the structure dictates that after the domain there is exactly the letters "ru" that come from the TLD. But if domain also ends with "ru", then the concatenated letters would have "ruru" etc. The problem allows that the domain may contain "ru", but the TLD "ru" is still appended. So the string will contain two "ru" sequences: one part of domain and one from TLD, but they are merged. For parsing, we need to decide where the domain ends and where the TLD "ru" starts. But we also need to ensure that the substring "ru" that corresponds to TLD appears exactly as a suffix of the domain+? Actually after domain we have ".ru", so the letters "ru" directly follow the domain letters. So the combined string of domain and TLD is domain + "ru". Then optionally context. So the string after protocol is: domain + "ru" + context? No: the whole string after protocol is: domain + "ru" + (context if present). But wait: there is no slash. So the string is protocol + domain + "ru" + context. So we need to partition s as: s = protocol_part + rest, where protocol_part is exactly "http" or "ftp". Then the remaining string (call it t) must be partitioned into three parts: domain_part (non-empty), "ru", and possibly context_part (non-empty if present). But note: after removing punctuation, there is no marker between domain and the TLD "ru". So we need to split t into d + "ru" + c, where d is non-empty, and c may be empty (if no context) or non-empty. However, the problem says that if context is present, then there is an extra "/" before it, but since we removed slashes, there is no distinction. So the presence of context is just determined by whether we have leftover letters after consuming the "ru". But also, the address could be without context, in which case after the ".ru" there is no slash, so the string ends right after "ru". So t would be exactly d + "ru". So we need to partition t such that it ends with "ru"? Actually it ends with "ru" if no context; else it ends with something else after "ru". So we need to find a split: t = d + "ru" + c, where d is non-empty, and c can be empty or non-empty. However, c must be non-empty if we decide to include context? But the problem says the / part may not be present. If it is present, then is non-empty. So if we include context, c must be non-empty. But also note that the original address, if context is present, there is a slash before it. Since we removed slashes, c appears directly after "ru". So in the concatenated string, it's ambiguous where the TLD "ru" ends and context begins. But we can decide that some substring "ru" is the TLD, and the rest after it is context. However, the domain could also contain "ru" and we could choose the later "ru" as the TLD. So there might be multiple ways.
Given that the problem states the string can be obtained from some correct address, we just need to output any valid reconstruction.
Simplify: We need to insert punctuation back: after protocol, we need to insert "://". After domain (which is before .ru), we need to insert a '.' before "ru". And if we have context, we need to insert a '/' before context. So final address is: protocol + "://" + domain + ".ru" + ( "/" + context if context not empty else "" ). And the concatenated letters after removing punctuation should equal s.
Thus we need to find strings protocol, domain, context (possibly empty) satisfying: protocol ∈ {"http","ftp"}, domain is non-empty lowercase letters, context is either empty or non-empty lowercase letters, and s = protocol + domain + "ru" + context.
That is straightforward: We know s. We need to split s into four segments: p, d, tld, c, where p is either "http" or "ftp". Then after p, the next characters are d (non-empty), then exactly the substring "ru", then c (could be empty). But note the tld is fixed as the letters "ru", but it's part of the string, so we must locate where the "ru" that corresponds to the TLD occurs. However, the string may contain other "ru" substrings, but the TLD "ru" is a specific occurrence. So effectively we need to find an index i after p such that we can set domain = s[ len(p) : i ] (non-empty), and then we require that s[i : i+2] == "ru". Then context = s[i+2:] (could be empty). This yields a valid address if domain non-empty and context if not empty must be non-empty? Actually context can be empty, meaning no slash. If context is empty, then the address ends at .ru. That's valid. If context is non-empty, it's also valid. So any such split works.
Thus the problem reduces to: Given s, find positions: first characters must match either "http" or "ftp". So we can check if s starts with "http" or "ftp". If both? It could start with "http" which is also prefix of "https"? But protocol can only be "http" or "ftp". So check if s starts with "http". But careful: s might start with "http" but also "ftp"? It can't start with both. But we could have s = "ftphttprururu". It starts with "ftp", so protocol is "ftp". But it also starts with "http"? Actually the first four letters are "ftph", not "http". So it's unambiguous? But we need to consider both possibilities. So we should test both protocols: if s starts with "http", consider that as protocol. Similarly for "ftp". But note: "http" is length 4, "ftp" is length 3. So we need to consider both possible protocol lengths. So we could try both possible protocol strings: if s starts with "http", then p = "http", remainder = s[4:]. Else if s starts with "ftp", then p = "ftp", remainder = s[3:]. But note: s could start with "http" and also start with "ftp"? Only if s starts with "ftph..." it doesn't start with "ftp"? Actually to start with "ftp", first three letters must be 'f','t','p'. To start with "http", first four must be 'h','t','t','p'. So they can't both be true because first letter differs. So at most one matches. But is it possible that s starts with "http" but also we could consider protocol "ftp"? No, because protocol must exactly match start of s. So only one protocol possibility, unless s starts with both? It can't. So we can determine protocol uniquely by first letter: if first char is 'h' then protocol must be "http"? But what if first char is 'f' then protocol is "ftp"? But what if first char is something else? According to guarantee, it's from a valid address, so first char must be 'h' or 'f'. So protocol determined by first character? Actually "http" starts with 'h', "ftp" starts with 'f'. So indeed protocol determined by first character. But wait: could there be a case where s starts with "ht"? That would be "http"? but maybe there is also possibility that protocol is "ftp"? No. So we can simply set: if s[0]=='h' then protocol="http" else if s[0]=='f' then protocol="ftp". But careful: "http" contains 'h','t','t','p'. Could there be an address where domain starts with letters that could be misinterpreted? The protocol is the prefix of s, because after protocol we had "://" which are removed, so protocol letters directly followed by domain letters. So yes, the first few letters of s are exactly the protocol. So we can extract protocol as either "http" (if s starts with "http") or "ftp" (if s starts with "ftp"). But what if s starts with "ftph"? That starts with "ftp", so protocol is "ftp". So it's fine.
Thus we can determine p and length Lp (4 for http, 3 for ftp). Then we have remainder r = s[Lp:]. Now we need to split r into domain d (non-empty) + "ru" + context c (maybe empty). That is: find an index i (starting from 0) such that i >= 1 (since domain non-empty) and i+2 <= len(r) and r[i:i+2] == "ru". Then domain = r[0:i], context = r[i+2:]. Then address = p + "://" + domain + ".ru" + (("/"+context) if context != "" else ""). This yields a valid address. We just need to find any such i. Since the problem guarantees a solution exists, there is at least one i. But we must be careful: domain must be non-empty, so i must be at least 1. Also, we are allowed to pick any valid reconstruction.
Thus simplest solution: iterate i from 1 to len(r)-2 (i.e., possible start index of "ru" such that there are at least two characters after i-1). Check if r[i:i+2] == "ru". For the first such i, we output the reconstructed address. But is that always valid? The guarantee says solution exists, but we need to ensure that we also consider the case where context is empty: i+2 == len(r). That's allowed. So i can be up to len(r)-2 inclusive. So iterate i from 1 to len(r)-2. However, what if there is no i? That can't happen due to guarantee. But maybe the domain could be empty? No, domain must be non-empty. So i must be >=1. So we must ensure that the "ru" we pick for TLD is not at the very beginning of r. That would mean domain empty, which is invalid. So we must ensure domain non-empty.
But is there any other nuance? Could there be a scenario where the "ru" we pick is not actually the TLD but part of the domain, and the real TLD is later? That would mean we could have multiple valid splits. Our algorithm picks one. But we need to ensure that the chosen split yields a valid address. That's fine if it satisfies the constraints. However, is there any requirement that context must be non-empty if we add a slash? Actually we add slash only if context non-empty. So no issue.
But there is a subtle point: The address format has exactly three slashes? Wait: ://.ru[/]. So after protocol, there is "://". That's two slashes? Actually "://" contains two slashes? The string is "://.ru[/]". Typically "://" is colon followed by two slashes. So there are two slashes after colon. So total slash characters: two in "://". Then possibly an extra slash before context. So indeed either two or three slashes. After removing punctuation (which includes '/'), all slashes are removed. So there is no marker.
Thus algorithm seems trivial. But let's test with examples.
Example 1: s = "httpsunrux". First char 'h', so protocol = "http". Lp=4, r = "sunrux". Now we need to find i (>=1) such that r[i:i+2] == "ru". r = s u n r u x. Indices: 0 s,1 u,2 n,3 r,4 u,5 x. Check i=1: r[1:3]="un"? no. i=2: r[2:4]="nr"? no. i=3: r[3:5]="ru"? yes. i=3 (domain = r[0:3]="sun", non-empty). context = r[5:] = "x". Output: http://sun.ru/x -> matches.
Example 2: s = "ftphttprururu". First char 'f', protocol = "ftp". Lp=3, r = "httprururu". Need i>=1 such that r[i:i+2]=="ru". r = h t t p r u r u r u? Actually string: index:0 h,1 t,2 t,3 p,4 r,5 u,6 r,7 u,8 r,9 u? Wait length? "httprururu" is 10 letters? Let's count: "h","t","t","p","r","u","r","u","r","u" => 10. But we need to find "ru". Check i=1: r[1:3]="tt"? no. i=2: "tp"? no. i=3: "pr"? no. i=4: r[4:6]="ru"? yes (positions 4 and 5 are 'r','u'). domain = r[0:4]="http". context = r[6:] = "ruru"? Actually r[6:] from index 6 to end: "ruru"? positions 6:r,7:u,8:r,9:u => "ruru". Output: ftp://http.ru/ruru -> matches sample output. But there were other possible splits: i=6? r[6:8]="ru"? positions 6 r,7 u -> "ru"? yes. Then domain = r[0:6]="httpr u"? Actually r[0:6]="httpr u"? let's write: indices 0-5: h t t p r u => "httpr u"? Actually that is "httpr u"? No, careful: r[0:6] means characters at 0,1,2,3,4,5: h, t, t, p, r, u -> "httpr u"? But combined: "httpr u" -> "httpr u" doesn't form a valid string? It's "httpr"+"u"? Actually that would be "httpr u"? Wait it's "httpr u"? That's "httpr"+"u"? It's "httpr u"? I'd better treat as string: from index 0 to 5 inclusive? In Python, slicing r[0:6] yields characters at indices 0,1,2,3,4,5. That's "h","t","t","p","r","u" => "httpr u"? Actually concatenated: "h"+"t"+"t"+"p"+"r"+"u" = "httpru"? Wait "h","t","t","p" makes "http". Then add "r" gives "httpr". Then add "u" gives "httpru". So domain = "httpru". That is non-empty. Then context = r[8:] = from index 8: r[8] = 'r', r[9] = 'u'? Actually if i=6, then i+2=8, context = r[8:] = characters 8,9: r[8]='r', r[9]='u' => "ru". So address: ftp://httpru.ru/ru -> That's one of the possible answers mentioned: "ftp://httpru.ru/ru". That works. Also i=8? i=8: need i+2 <= len(r)=10, so i=8 => i+2=10 okay. Check r[8:10] = positions 8: r,9: u => "ru". domain = r[0:8] = "httpruru"? Actually indices 0-7: h t t p r u r u => "httpruru". That's non-empty. context = r[10:] = empty. So address: ftp://httpruru.ru -> That's "ftp://httpruru.ru" which is the other mentioned: "ftp://httpruru.ru"? Actually they said "ftp://httpruru.ru" as one of possible answers? The note: "ftp://httpruru.ru" and "ftp://httpru.ru/ru". Yes. So our algorithm if we take first i that satisfies condition (starting from 1) we get i=4 (the earliest occurrence of "ru" after index >=1). That yields "ftp://http.ru/ruru", which is the sample output. So any is fine.
Thus the problem is trivial: just find any split.
But wait: there might be a nuance: The domain must be non-empty and can consist only of lowercase letters, which is satisfied. Context if present must be non-empty, which we ensure because if we pick context and it's empty, we wouldn't output slash. But if we pick i such that context empty, that's fine. So all such splits are valid.
Thus solution: iterate i from 1 to len(r)-2, check if r[i:i+2] == "ru". For the first such i, construct answer. But what if there is no such i? Then maybe we need to consider that the "ru" could be part of the context? No, TLD must be present. So there must be a "ru" somewhere after domain. Since domain non-empty, the earliest "ru" could be at position 1? But maybe the only "ru" is at position 0? That would mean domain empty, invalid. So guarantee ensures existence of some i>=1.
Thus implementation is simple.
But I want to double-check the guarantee: "It is guaranteed that the given string can be obtained from some correct Internet resource address, described above." So there is at least one valid partition.
Edge cases: s length minimal. If protocol is "ftp" (3), domain non-empty (at least 1), plus "ru" (2) => minimal length 3+1+2=6. For "http" (4) minimal length 4+1+2=7. So s length at least 6 or 7. Could be with context empty. So okay.
But wait: Could the domain include uppercase? No, only lowercase. Given string is lowercase letters only, so fine.
One more nuance: The domain can be any non-empty string, but does it have any restrictions? No.
Now, any pitfalls? The address reconstruction must have exactly the format: ://.ru[/]. We must insert a dot before "ru". That's standard. So we output the string with the appropriate punctuation.
Thus solution: read s, determine protocol. Then r = s[len(protocol):]. Then for i in range(1, len(r)-1): actually we need i such that i+1 < len(r) to have two chars, so i up to len(r)-2 inclusive. Check if r[i] == 'r' and r[i+1] == 'u'. If found, domain = r[:i], context = r[i+2:]. Then print: protocol + "://" + domain + ".ru" + (("/" + context) if context else ""). Done.
But is it possible that the address without context but there is still extra letters after "ru"? That wouldn't be without context, it would be context. So no.
Thus final answer.
But wait: Could there be a scenario where the domain is empty if we choose i=0? But we exclude i=0 because domain non-empty. But maybe the problem allows domain to be empty? The statement says: is a non-empty string. So non-empty. So we must exclude i=0.
Thus algorithm is correct.
But let's think more: Could there be a case where the string s = "ftpxru"? Protocol "ftp", r = "xru". len(r)=3. Need i>=1 and i+2<=3 => i=1 only. Check r[1:3]="ru"? r[1]='r'? Actually r = "xru": indices 0:'x',1:'r',2:'u'. r[1:3]="ru" yes. domain = r[:1]="x", context = r[3:]="" => empty. Address: ftp://x.ru -> valid.
If r = "xruy": len=4. i can be 1 or 2? i=1 => r[1:3]="ru", domain="x", context="y". Output: ftp://x.ru/y. i=2 => r[2:4]="u?" Actually r[2:4] = "uy"? not "ru". So only i=1 works.
If r = "abcru": i=3? Check indices: 0:a,1:b,2:c,3:r,4:u. i from 1 to 2? Actually i can be 1,2,3? i=3: i+2=5 <=5? len=5, so i<=3? i+2<=5 => i<=3. So i=3 allowed. domain = "abc", context="". So output: ftp://abc.ru. i=1: r[1:3]="bc"? no. i=2: r[2:4]="cr"? no. So only i=3 works.
If r = "abrucru": multiple possibilities.
Thus algorithm fine.
But wait: The problem statement says: "the / part may not be present. If it is present, then is a non-empty string". So if we choose context empty, we don't output slash. That's fine.
Thus solution straightforward.
Now check for any tricky case: Could there be a scenario where the string starts with "http" but the protocol is actually "ftp"? No, because the protocol letters are first. So if first character is 'h', it can't be "ftp". So it's uniquely determined.
Thus we can code.
But hold on: Let's double-check the removal process: The address originally contains ':' and '/' and '.' punctuation. Vasya didn't write those characters. So the notebook contains only letters. So indeed the string consists solely of the letters from protocol, domain, "ru", and context. So our reasoning stands.
Thus solution is O(n) scanning.
Edge Cases: Given string length up to 50, trivial.
I'll produce Python solution.
But I realize there is one nuance: The protocol could be "http" or "ftp". However, what if the string starts with "http" but the domain part also begins with letters that could be interpreted as the rest of "http"? No, the protocol is exactly at the start. So we must check if the first four letters are "http". But what if the string is "httpxxx"? That starts with "http", so protocol = "http". That seems fine. But what if the string starts with "ftpxxx"? That is "ftp". So both are distinct.
But wait: There is a possibility: The string could start with "ftp", but the domain might start with "http" as in example. That's fine.
Now, what about a string like "httphttpru"? That starts with "http". r = "httpru". i possibilities: i=4? Actually r = "httpru": indices 0:h,1:t,2:t,3:p,4:r,5:u. i from 1 to 4? i=4: r[4:6]="ru", domain=r[:4]="http", context="". Output: http://http.ru. That's valid? Domain "http" is non-empty. That seems allowed. Another i=2? r[2:4]="tp"? no. So only i=4. That yields a valid address. So okay.
Now, what about string starting with "http" and domain empty? That would require r starting with "ru". r would be "ru..."? That would be possible if domain empty? But domain must be non-empty, so that wouldn't be a valid original address. However, the guarantee says it's from a valid address, so such case won't occur. So we don't need to worry about i=0.
Thus solution fine.
But is there any scenario where the protocol is "http" but the string is like "httpruru"? Actually that's s = "httpruru". This starts with "http", so p="http", r="ruru". r length 4. i from 1 to 2? i=1: r[1:3]="ur"? no. i=2: r[2:4]="ru"? yes. domain = r[:2]="ru"? Actually r[:2] = "ru". So domain = "ru", context="". So address: http://ru.ru? Wait domain is "ru", TLD "ru" => domain.ru => "ru.ru"? That is valid? Domain "ru" is allowed? Yes, non-empty lowercase letters. So address: http://ru.ru. But wait, original string would be "httpruru". But note: This is "http"+"ru"+"ru" = "httpruru". That matches. But is that a valid original address? Yes, protocol http, domain "ru", TLD "ru", no context. So output http://ru.ru. That is valid. But note: There might be ambiguity: Could there be another split? i=... no. So fine.
Now, what about protocol "ftp" and r = "ru"? That would be length 2, but domain must be non-empty, so r length at least 3? Actually protocol "ftp" (3) + domain (>=1) + "ru" (2) = at least 6. So r length at least 3? Actually 3+1+2=6 total, so r length = 3? Wait total s length = 3+? Actually s = protocol + domain + "ru" + context. So after protocol removal, r length = domain + "ru" + context. Minimum domain=1, context=0 => r length = 1+2 = 3. So r length >=3. So r could be "ru?" But "ru" is only 2, so not possible. So fine.
Thus solution done.
But wait: There is a nuance: The address format says: ://.ru[/]. There is a dot before "ru". So in our output we must include that dot. So we print domain + ".ru". No issues.
Now, let's consider if there might be multiple protocol possibilities if the string starts with "h" but is "http"? That's the only option. But what about "ht"? Could it be that the protocol is "ftp" but the first character is 'f'? So no.
Now, what about strings that start with "ftph"? That's "ftp", not "http". So ok.
Thus problem is trivial. However, let's not overlook that the problem might be from Codeforces and there may be a catch: the domain must be non-empty and the TLD is exactly ".ru". The tricky part is that the domain itself could contain "ru" and the TLD "ru" could be overlapping? For example, s = "ftpxruru". Protocol ftp, r = "xruru". Options: i=2? r[2:4]="ru"? r indices: 0:x,1:r,2:u,3:r,4:u? Actually "xruru": 0:x,1:r,2:u,3:r,4:u. Check i=1: r[1:3]="ru"? (r[1]='r', r[2]='u') -> "ru". Yes. domain = r[:1]="x", context = r[3:]="ru"? Actually r[3:] = from index 3: r,4:u => "ru". So address: ftp://x.ru/ru. i=3: r[3:5]="ru"? positions 3:'r',4:'u' => "ru". domain = r[:3]="xru", context="". Address: ftp://xru.ru. Both valid. So any works.
Thus algorithm to pick first i works.
But is there a scenario where the first i yields an invalid address? Possibly if context is empty? That's valid. So okay.
Thus we can implement.
Now, I'll write the solution: read s. if s.startswith("http"): protocol="http"; rest = s[4:]; else if s.startswith("ftp"): protocol="ftp"; rest = s[3:]; else: maybe impossible but guarantee ensures one of these holds.
Then for i in range(1, len(rest)-1): if rest[i:i+2] == "ru": domain = rest[:i]; context = rest[i+2:]; break.
Then output as described.
But careful: range upper bound: we need i+2 <= len(rest), so i <= len(rest)-2. So range(1, len(rest)-1) because in Python range stop is exclusive, so range(1, len(rest)-1) will go up to len(rest)-2. Actually if len(rest)=5, len(rest)-1=4, range(1,4) gives i=1,2,3. i=3+2=5 which is okay. So yes.
Now consider if no break occurs? The guarantee says there is a solution, but to be safe, we might search i from len(rest)-2 down to 1? But any is fine.
Edge case: if rest length is 2? Then domain non-empty impossible, so guarantee won't produce such. So fine.
Thus code done.
But wait: Could there be a scenario where the protocol is "http" but the string starts with "http" and also we might consider protocol "ftp"? Obviously not.
However, I just thought: Could the string be something like "ftph...", where the first three letters are "ftp", but the domain could start with 'h' etc. That's fine.
Now, what about string like "httpr"? That length 5? Actually "http"+"r" would be "httpr". But we need at least "ru" after domain. So total length at least 7 for http. So not possible.
Thus final.
But I recall Codeforces problem named "Internet Address" or something similar. Actually I think it's Codeforces 245B - Internet Address. Let me recall: The problem "Internet Address" (CF 245B) has similar description: Vasya writes address without punctuation and we need to restore. However, in that problem, there are more protocols? Possibly "http", "ftp". And the rule: address format: ://.ru[/]. That's exactly it. And I recall that solution is just to parse as described. Actually I think the official solution involved finding the first occurrence of "ru" after the protocol, but with domain non-empty, and then adding punctuation accordingly. But also there is nuance about the protocol being "http" or "ftp". Yes.
Thus our solution matches.
However, there might be a nuance: The protocol could be "http" or "ftp". But note that "http" contains "ht" and "tp"? Not important.
Now, check example: Input "httpsunrux" we output "http://sun.ru/x". That's correct.
Now, let's test some extra cases.
Case: s = "httpabcru". p="http", r="abcru". len(r)=5. i from 1 to 3. Check i=1: r[1:3]="bc"? no. i=2: r[2:4]="cr"? no. i=3: r[3:5]="ru"? yes. domain="abc", context="". Output "http://abc.ru". Good.
Case: s = "ftpabcru". p="ftp", r="abcru". i=3? r[3:5]="ru"? domain="abc". Output "ftp://abc.ru". Good.
Case: s = "ftpabcruxy". p="ftp", r="abcruxy". i=3? r[3:5]="ru", domain="abc", context="xy". Output "ftp://abc.ru/xy". Good.
Case: s = "httpabruc". p="http", r="abruc". i=2? r[2:4]="ru"? domain="ab", context="c". Output "http://ab.ru/c". Good.
Now, could there be a case where the chosen "ru" is part of the context? Actually if we pick the earliest "ru", it might be part of domain? But the TLD "ru" must be after domain. If we pick earliest "ru" that is after domain start, it's fine as long as domain non-empty. However, consider s = "ftpabrucru". p="ftp", r="abrucru". The earliest "ru" is at i=2 (since "ab ru"? indices: 0:a,1:b,2:r,3:u,4:c,5:r,6:u). So i=2 yields domain="ab", context="cru". But what if the correct original address had domain="abruc" and TLD "ru" at the end? That would be i=5? Actually that yields domain="abruc", context="". Both are valid. So either is acceptable.
Thus our method yields a valid address.
Thus solution ready.
But wait: The problem says: "If there are several addresses that meet the problem limitations, you are allowed to print any of them." So we can output any.
Thus code is straightforward.
But I realize there is another nuance: The address format is ://.ru[/]. The domain is followed immediately by ".ru". So in our reconstruction, we output domain + ".ru". But what if domain itself contains uppercase? No.
Now, is there any requirement that the domain cannot be "ru"? No, it can be "ru". So fine.
Now, the context is optional. If we output a slash, it must be followed by non-empty context. Our method ensures that if context is empty we don't output slash. So good.
Thus solution done.
Now, write code.
Pseudo:
def solve(): s = input().strip() if s.startswith('http'): protocol = 'http' rest = s[4:] else: # must start with 'ftp' protocol = 'ftp' rest = s[3:] # find i for i in range(1, len(rest)-1): if rest[i] == 'r' and rest[i+1] == 'u': domain = rest[:i] context = rest[i+2:] break # construct output res = protocol + "://" + domain + ".ru" if context: res += "/" + context print(res)
But we must handle case where no i found? According to guarantee, there will be. But we can add fallback: maybe take i = len(rest)-2? But if not found, that would mean no "ru". But guarantee says solution exists, so there must be "ru". So fine.
But there is a subtlety: What if the protocol is "http" but the string starts with "http" and also "ftp"? Not possible.
But what if the string is "fttp"? That's invalid but guarantee says valid.
Thus solution.
But I recall a known Codeforces problem (245B) and its solution often used a method: find first occurrence of "ru" after the protocol, but ensure domain non-empty. However, some solutions check also that after the protocol, the domain must contain at least one character before "ru". So they find the index of "ru" after position 1 (i.e., not at the very start of rest). So same.
Now, edge case: Could there be a scenario where the earliest "ru" occurs at index 0 of rest? That would mean domain empty, invalid. But then there must be another "ru" later. So earliest valid "ru" is the one after at least one character. So we need to skip the first occurrence if it's at index 0? But our loop starts from 1, so we skip i=0. So that's fine.
But what if rest starts with "ru" but the only "ru" is at index 0? That would be invalid per guarantee because domain must be non-empty. So guarantee ensures there is some "ru" with index >=1. So okay.
Thus answer.
Now, let's test with some more complicated case:
s = "httprupru" (protocol "http", rest="rupru")? Actually "http"+"rupru" = "httprupru". Rest = "rupru". i from 1 to len-2=3. Check i=1: rest[1:3]="up"? no. i=2: rest[2:4]="pr"? no. i=3: rest[3:5]="ru"? (positions 3='r',4='u'? Let's index: rest = r u p r u; indices:0:r,1:u,2:p,3:r,4:u. i=3 -> rest[3:5]="ru". domain=rest[:3]="rup"? Actually "rup"? indices 0,1,2: r,u,p => "rup". context=rest[5:]=""? Actually i+2=5 -> rest[5:] empty. So address: http://rup.ru? But domain is "rup". That yields "rup.ru". But original string was "httprupru". That is protocol + domain + "ru"? Actually "http"+"rup"+"ru" = "httprupru". So that's valid. But could there be another split? i=0? Not allowed. So ok.
Now, check if context empty but we might incorrectly add slash? We don't.
Thus code works.
But wait, is there any requirement about the domain not containing uppercase? No.
Now, could there be a scenario where the address includes a context that is empty but we still output slash? That would be invalid. We avoid by checking context non-empty.
Thus final.
Now, let's implement in Python.
But also note: The problem might have input string containing newline, so we strip.
Thus final answer.
I'll now produce a solution.
But hold on, I recall there is a Codeforces problem "245B - Internet Address" where the solution is a bit more involved because they also considered that after "://" there may be additional 'ru' substrings, but they used a method: after protocol, find first "ru" that is not at the very beginning, then treat everything before that as domain, and after that as context. Then output. That matches.
Thus ready.
Now, confirm with sample:
Input: "httpsunrux" -> protocol http, rest="sunrux". Loop i=1: rest[1:3]="un"? no. i=2: "nr"? no. i=3: "ru"? yes. domain="sun", context="x". Output "http://sun.ru/x". Good.
Second: "ftphttprururu" -> protocol ftp, rest="httprururu". i from 1: i=1: "tt"? no. i=2: "tp"? no. i=3: "pr"? no. i=4: "ru"? yes. domain="http", context="ruru". Output "ftp://http.ru/ruru". Good.
Thus final.
Now, I'll write code.
But perhaps there is another nuance: In some addresses, the domain might include the substring "ru" that is actually part of the TLD? Actually the TLD is ".ru". The dot is removed, so the domain and TLD are directly concatenated. So if domain ends with 'r', then the combined string would have ...r + "ru" = ...rru. The TLD "ru" starts at the next character after domain, not overlapping. So if domain ends with 'r', it's okay. The first 'r' of TLD is separate. But our algorithm looks for "ru" anywhere. It could pick a "ru" that starts at a position that is not exactly after the domain but includes the last character of domain? For example, domain="ab", TLD="ru" -> combined "abru". Our algorithm finds "ru" starting at index 2 (0-based), which is after "ab". That's correct. If domain="abr", then combined "ab r u"? Actually domain="abr", TLD="ru" -> combined "abrru". Here the string is "abrru". Where is the TLD "ru"? The TLD "ru" starts at index 3? Let's index: indices: 0:a,1:b,2:r,3:r,4:u. The TLD "ru" would be at indices 3 and 4 (r,u). But there is also a "ru" overlapping? At indices 2 and 3: r,r? That's not "ru". At indices 2 and 3: (r,r) not "ru". At indices 3 and 4: (r,u) is "ru". So our algorithm, if we iterate from i=1, we will check i=1: (b,r) no; i=2: (r,r) no; i=3: (r,u) yes. So we correctly pick i=3, domain = rest[:3]="abr", which is correct. So the algorithm works because we look for "ru" as a substring; the TLD "ru" will appear somewhere after domain, and it will be the first occurrence that is not overlapping with domain? Not necessarily the first; consider domain="abru", TLD="ru": combined "abru"+"ru" = "ab r u r u"? Actually "abru"+"ru" = "ab r u r u" -> "abruru"? Wait "abru" is a b r u, plus "ru" yields "ab r u r u" => "abruru". The string is "abruru". Where is TLD "ru"? After domain "abru", the TLD starts at index 4? Indices: 0:a,1:b,2:r,3:u,4:r,5:u. So TLD at indices 4,5. But there is also a "ru" at indices 2,3? Let's see: indices 2:r,3:u -> "ru". That's actually part of the domain (if domain is "abru", it ends with "ru"). So there is a "ru" inside the domain. The earliest occurrence of "ru" is at i=2. Our algorithm, if we take the first i that is >=1, that would be i=2. Then domain = rest[:2]="ab", context = rest[4:]="ru"? Actually rest[2+2=4:] from index 4 to end: "ru". That yields address: protocol://ab.ru/ru. But is that a valid original address? Let's see: Could the original address be protocol://ab.ru/ru? That would correspond to s = protocol + "ab" + "ru" + "ru" = protocol + "abru" + "ru"? Wait original would be protocol://ab.ru/ru -> after removing punctuation: protocol + "ab" + "ru" + "ru" = protocol + "abru" + "ru"? Actually careful: In original address protocol://ab.ru/ru, the domain is "ab", TLD "ru", context "ru". After removal of punctuation, we get protocol letters + domain "ab" + "ru" (from .ru) + context "ru" = protocol + "ab" + "ru" + "ru" = protocol + "ab" + "ruru". That equals protocol + "abruru"? Actually "ab"+"ru"+"ru" = "ab"+"ruru" = "abruru". That's exactly the given string: protocol + "abruru". So indeed that is a valid original address. So picking the earliest "ru" yields a different but still valid address. So the algorithm works.
But what about the case where domain is "abru" and no context, original address protocol://abru.ru. Then s = protocol + "abru" + "ru" = protocol + "abruru". That's same string as above! So the same string could correspond to two different original addresses: one with domain "abru" and no context, and one with domain "ab" and context "ru". Indeed, that is possible. So the problem guarantees that the given string can be obtained from some correct address, but there may be multiple. So our algorithm, picking the earliest "ru" (with i>=1), might produce an address with context. But if the intended solution by the problem might expect a specific output? But the statement says you are allowed to print any of them. So either is fine.
Thus algorithm robust.
Now, check: In the scenario above, our algorithm (first i) would produce domain "ab", context "ru". That is valid. So okay.
But what if the string is from an address with domain "abru" and no context, and our algorithm picks the earliest "ru" yields domain "ab", context "ru". That's still valid because the string could have come from that. But is it guaranteed that domain non-empty and context non-empty (if present) conditions hold? Yes, domain "ab" non-empty, context "ru" non-empty. So it's a valid address. So it's fine. So any output meeting constraints is accepted. So we can output that.
Thus solution is simply: find any occurrence of "ru" after protocol, with at least one character before it. So the earliest is fine.
Now, we should also consider that after protocol, we need to ensure that domain is non-empty. Our loop starts at i=1, so it ensures at least one character before the "ru". Good.
Now, let's think about edge case: what if the string is such that the only occurrence of "ru" after protocol is at the very end? That's fine. Our loop will catch it when i = len(rest)-2, if that i >=1.
Now, implement.
But one more nuance: Could the protocol be "http" but the string is "httpru"? That's length 6. Protocol "http" length 4, rest = "ru". rest length 2. Our loop range(1, len(rest)-1) = range(1, 1) empty, so no i found. But is "httpru" a valid string from an address? Let's check: If address is http://.ru? Domain must be non-empty, so impossible. But address http://ru.ru would be "http" + "ru" + "ru"? Actually "http://ru.ru" yields after removal: "http" + "ru" + "ru" = "httpru"+"ru"? Wait "http"+"ru"+"ru" = "http"+"ruru" = "httpruru". So "httpru" would be length 6, but "http"+"ru"+"ru" is length 8? Let's compute: "http" (4) + "ru" (2) = 6, but we need domain non-empty plus "ru". For domain "r"? Then s = "http"+"r"+"ru" = "httprru"? That is 7? Actually "http"+"r"+"ru" = "httprru" (7 letters). So "httpru" (6) would require domain empty, not allowed. So "httpru" cannot come from a valid address. So guarantee avoids this. So our loop will always find an i.
Now, let's consider when rest length is 3: e.g., "xru". Then i can be 1 only if rest[1:3] == "ru". That requires rest[1]=='r' and rest[2]=='u'. So string like "xru". Then domain = "x", context="". Works. So range(1, len(rest)-1) = range(1, 2) yields i=1. Good.
When rest length is 4: e.g., "xruy". i=1 check, i=2? range(1,3) yields i=1,2. If rest[1:3]="ru"? then ok.
Thus implementation fine.
Now, just to be thorough, consider input: s = "ftpruru". Protocol ftp, rest = "ruru". rest length 4. i from 1 to 2. i=1: rest[1:3]="ur"? no (r u r u: indices 0:r,1:u,2:r,3:u, so rest[1:3] = u,r -> "ur"). i=2: rest[2:4]="ru"? yes (r,u). domain = rest[:2] = "ru", context="". Output: ftp://ru.ru. That's valid. So okay.
Now, I'll code.
But sometimes problems require careful handling of context: if context is empty, no slash. We'll do that.
Thus final answer.
Now, double-check problem statement: "Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them." So we can print any valid.
Thus code is ready.
But what if there are multiple protocols? As argued, it's determined by first char.
One more nuance: Could the protocol be "http" but the string starts with "http" and also we could interpret "ftp" if the string starts with "ftph"? Not. So fine.
Thus final solution.
I'll produce the final answer with explanation.
However, I realize that some solutions online for Codeforces 245B used a different approach: they first identify protocol, then they find the first occurrence of "ru" after the second character (or something). But essentially same.
Now, write final code.
Implementation:
def main(): s = input().strip() if s[:4] == "http": protocol = "http" rest = s[4:] else: protocol = "ftp" rest = s[3:] # Find index of "ru" for i in range(1, len(rest)-1): if rest[i] == 'r' and rest[i+1] == 'u': domain = rest[:i] context = rest[i+2:] break # Construct output res = f"{protocol}://{domain}.ru" if context: res += f"/{context}" print(res)
We could also use rest.find("ru", 1) but need to ensure we don't take an occurrence that doesn't have two characters. Actually we can use:
pos = rest.find("ru", 1) # start searching from index 1 if pos != -1: domain = rest[:pos] context = rest[pos+2:]
But careful: If rest.find returns position of 'r', then we need to ensure that there is at least 2 characters after start? Actually if pos <= len(rest)-2, it's fine. Since we start from 1, and if found, it will be valid. But what if rest = "abru", find("ru",1) returns 2, that's fine. If rest = "aruu"? Actually "ru" at index 1? If index=1, but we started from 1, it will find index=1 if present, but index 1 is okay because we need domain non-empty? If index=1, then domain = rest[:1] which is non-empty (one character). So starting from 1 is fine. So we can simply do:
pos = rest.find("ru", 1)
But note: The second argument of find is the start index; it will return the first occurrence at or after that index. So if there is "ru" at index 1, that's fine. So we don't need loop. However, we must ensure that pos+2 <= len(rest). If find returns a position, it's guaranteed that there are at least 2 characters from that position because "ru" is length 2; find only returns if the substring exists fully. So pos+2 <= len(rest) automatically. So we can use:
pos = rest.find("ru", 1)
But what if the only "ru" is at index 0? find starting from 1 will not find it, returning -1. But guarantee says there is a valid "ru" with domain non-empty, so there must be some occurrence at index >=1. So find will succeed. So simpler:
pos = rest.find("ru", 1) domain = rest[:pos] context = rest[pos+2:]
But wait: what if there are multiple "ru", find will return the earliest at or after index 1, which is the earliest valid occurrence. That's exactly what we want. So we can use that.
But caution: if rest starts with "ru" at index 0, and there is also "ru" at index 2, find(...,1) will return 2, skipping index 0. That's good. If only occurrence is at index 0, find returns -1, but guarantee prevents that.
Thus simpler:
if s.startswith("http"): protocol = "http" rest = s[4:] else: protocol = "ftp" rest = s[3:]
pos = rest.find("ru", 1) # first occurrence after at least one character domain = rest[:pos] context = rest[pos+2:]
Then output.
But ensure that domain is non-empty: since pos >=1, domain length >=1. So good.
Now, test with sample: "httpsunrux": rest="sunrux". find("ru",1) will find at index 3? Let's compute: "sunrux". find("ru",1): scanning from index1: index1 'u' no, index2 'n' no, index3 'r' followed by 'u' -> index3. So domain="sun", context="x". Works.
Second: "ftphttprururu": rest="httprururu". find("ru",1): start index1: index1='t', index2='t', index3='p', index4='r' followed by 'u' => index4. domain="http", context="ruru". Works.
Edge: rest="xru": find("ru",1) -> from index1: index1='r'? Actually rest="xru": indices 0:x,1:r,2:u. find("ru",1) checks at index1: rest[1]='r', rest[2]='u' => match at index1. domain="x", context="" -> works.
Edge: rest="abrucru": find("ru",1) -> index2? Actually "abrucru": indices 0:a,1:b,2:r,3:u,4:c,5:r,6:u. find from 1: index1='b' no, index2='r' with next 'u'? at index2, rest[2]='r', rest[3]='u' => match at index2. domain="ab", context="cru". Works. That's earliest valid.
Now, what about scenario where the earliest valid is not the earliest overall because there is a "ru" at index0? Example: s = "httpruabcru". protocol http, rest="ruabcru". find("ru",1) will skip index0 and find at index? index0 is "ru" but we skip; next maybe at index? rest: r u a b c r u. indices:0:r,1:u,2:a,3:b,4:c,5:r,6:u. find from 1: index1: u, not; index2: a, not; index3: b, not; index4: c, not; index5: r, next u? index5='r', index6='u' => match at index5. domain=rest[:5]="ruabc", context="". Output: http://ruabc.ru? Wait domain "ruabc" (non-empty). That yields address: http://ruabc.ru. Is that valid? The original string is "http"+"ruabc"+"ru" = "httpruabcru". That matches. But could there be an address with domain "r" and context "uabcru"? Let's see: If domain="r", context="uabcru"? That would be http://r.ru/uabcru, which yields after removal: http + "r" + "ru" + "uabcru" = "httprruuabcru" which is different. So not. However, there is also possibility domain="ru", context="abcru"? That would give http://ru.ru/abcru -> after removal: http + "ru" + "ru" + "abcru" = "httpru ru abc ru"? Actually "http"+"ru"+"ru"+"abcru" = "http" + "ruru" + "abcru"? That concatenates to "httpruruabcru" which is not the given string. So not. So the only valid splits might be domain="ruabc", no context. But our algorithm found that. However, what if there is also a "ru" at index0 and we skip it, we still find a later one. That's fine.
But consider a string where the only "ru" is at index0? That would be invalid as discussed. So no.
Thus using find("ru", 1) is safe given the guarantee.
But I should double-check the guarantee: "It is guaranteed that the given string can be obtained from some correct Internet resource address, described above." That means there exists at least one way to split with domain non-empty and with TLD "ru". That split might correspond to an occurrence of "ru" at some index >=1. But it's possible that the only occurrence of "ru" in the string is at index 0 relative to rest? Let's see: Could there be a valid address where the domain is non-empty but the first character of rest is 'r' and second is 'u', and that is the TLD? That would require domain to be something that ends before that, but if the TLD "ru" starts at index 0 of rest, then domain must be empty (since domain is everything before TLD in rest). Because rest = domain + "ru" + context. If "ru" starts at index 0, then domain would be rest[:0] empty. That's invalid. So such address cannot be valid. Therefore, in any valid address, the TLD "ru" must start at an index >=1 in rest. So there must be at least one occurrence of "ru" at index >=1. So find("ru", 1) will find a valid occurrence (though it might not be the one that corresponds to the original valid address? But any occurrence that yields domain non-empty and the rest split works is a valid address, as we argued. However, is it guaranteed that find("ru", 1) yields a split that results in a valid address? Let's examine: We take the first occurrence of "ru" at or after index 1. That gives domain = rest[:pos] and context = rest[pos+2:]. Is it always true that this split yields a valid address? Could there be a case where this split yields domain non-empty but the resulting address is invalid for some other reason? The only constraints are domain non-empty, context can be anything (non-empty if we add slash, but if context empty it's fine). So it's always valid. Because the address constructed as protocol://domain.ru/context (or without slash if context empty) is a syntactically correct address per the definition. The only question is: Could it be that the original address (the one that produced s) had a different split, but the split we found also yields the same s after removal of punctuation? Yes, by construction: s = protocol + rest, and rest = domain + "ru" + context, so if we set domain and context based on this split, s = protocol + domain + "ru" + context, which is exactly the original string. So after adding punctuation back, the address will be protocol://domain.ru[/context], and if we then remove punctuation, we get s again. So it's a valid reconstruction. So any such split yields a valid address. Therefore find("ru", 1) works.
But one nuance: The context must be non-empty if we add a slash. If context is empty, we don't add slash. That's fine. If context is non-empty, we add slash. That's fine. So yes.
Thus find is safe.
But wait: Could the split we get produce a domain that contains uppercase? No, all lowercase. So all constraints satisfied.
Thus solution can be extremely simple.
Let's implement with find.
But careful: The find method returns -1 if not found. Since guarantee exists, we can assume not -1.
Now, edge: if rest starts with "ru" and there is another "ru" later, find from 1 returns the later one, which yields a domain that includes the first "ru" as part of domain. That's fine.
Now, let's test with a more complex string: s = "httpabrucru". protocol http, rest="abrucru". find("ru",1) -> index? rest: a b r u c r u. index1: b, no; index2: r with u? index2='r', index3='u' => match at 2. domain="ab", context="cru". Address: http://ab.ru/cru. That's valid. Another split: index5? but find picks earliest after 1, so index2.
Now, what if rest is "arurru"? That's a contrived case: maybe find("ru",1) finds at index1? rest: a r u r r u? Actually "arurru": indices0:a,1:r,2:u,3:r,4:r,5:u. find("ru",1) will test index1: r and next u? index1='r', index2='u' => match at 1. domain="a", context="rru"? Wait context = rest[3:] = from index3: r,r,u => "rru". That yields address: protocol://a.ru/rru. That's valid.
Now, what if there is a case where find("ru",1) returns an index, but the resulting domain would be empty? That's impossible because pos >=1, domain length = pos >=1.
Thus solution.
Now, I will present code using find.
But let's ensure we handle protocol detection correctly: if s starts with "http", we set protocol http. But what if s starts with "ftp"? It does not start with "http". So we go to else. But what if the string starts with "httpftp"? That could be protocol "http" and domain starting with "ftp"... That's allowed. So we must check "http" first? But if string starts with "http", it's "http". If it starts with "ftp", it's "ftp". There's no conflict. So we can do:
if s[:4] == "http": protocol = "http" rest = s[4:] else: protocol = "ftp" rest = s[3:]
But what if s starts with "http" and also "ftp"? Not possible. So fine.
But what about a string starting with "ht"? That would be invalid per guarantee. So not needed.
Thus final.
Now, I'll produce final answer with explanation.
But maybe we need to consider that the protocol could be either, and we must decide based on first character? But the first character 'h' => "http", 'f' => "ftp". So we could also do:
if s[0] == 'h': protocol = "http" rest = s[4:] else: protocol = "ftp" rest = s[3:]
But is there any case where s[0] == 'h' but the protocol is actually "ftp"? No.
But better to use startswith for clarity.
Now, code.
Now, final answer: we'll write a solve() function.
Potential pitfalls: Input may have trailing newline, use strip.
Now, I'll produce final answer.
Now, perhaps we should consider that the problem might be from Codeforces and the expected output must be exactly as shown. In sample, they output "http://sun.ru/x". That includes no trailing spaces. So fine.
Now, final.
I'll write the solution in Python.
Let's produce the final answer.
But wait: The problem statement: "The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only." So we read s.
Now, I'll produce the code.
Now, is there any scenario where using find("ru", 1) might return a position that is not valid because the "ru" is part of the context? But that's still valid because domain is everything before that "ru", and context is after. But what if that split results in a context that itself contains a slash? No slash. It's fine. So all good.
Thus final.
Now, I'll include a comment that we search for the first "ru" after at least one character to ensure domain non-empty.
Now, produce answer.
Now, let's double-check with a tricky case: s = "httpabru". protocol http, rest="abru". find("ru",1) -> index? rest: a b r u. index1='b' no, index2='r' with next 'u'? index2='r', index3='u' => pos=2. domain="ab", context="". Output: http://ab.ru. But could the original address be http://ab.ru? That yields s = httpabru. Yes. However, what if the intended original address was http://a.bru? No, because domain must end with .ru, not .bru. So not.
Now, another: s = "httpabruru". rest="abruru". find("ru",1): indices: a b r u r u. index1 b, no; index2 r, next u => pos=2. domain="ab", context="ru". Output: http://ab.ru/ru. That's valid. Also possible: pos=4 (second "ru") gives domain="abru", context="". So both valid.
Thus fine.
Now, edge: s = "ftpa". Not possible because length.
Thus done.
Now, let's also consider if protocol is "http" but rest length is 2? That would be "ru"? But domain empty. Not possible.
Now, final.
We'll output as described.
Now, I'll present solution.
But I recall that some Codeforces solutions also considered that after protocol, the domain must have at least one character, and the "ru" must be found, and then they print. So it's consistent.
Thus final answer.
Now, I'll produce final explanation and code. ```python
def main(): s = input().strip()
# Determine the protocol if s.startswith("http"): protocol = "http" rest = s[4:] # letters after the protocol else: # guaranteed to be "ftp" protocol = "ftp" rest = s[3:] # Find the first occurrence of "ru" that leaves a non‑empty domain. # Searching from index 1 ensures domain length >= 1. pos = rest.find("ru", 1) # According to the input guarantee such a position always exists. domain = rest[:pos] context = rest[pos+2:] # Build the answer ans = f"{protocol}://{domain}.ru" if context: ans += f"/{context}" print(ans)if name == "main": main()