TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
# -*- coding: utf-8 -*-

import io
import sys
import math

def solve():
    
    pass

def main():
    # input
    n = int(input())
    s_list = sys.stdin.readlines()
    print(s_list)
    # process
    ans = str( len( set(s_list)) )
    
    # output
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
5
grape
grape
grape
grape
grape
"""
_EXPECTED = """\
1
"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

# -*- coding: utf-8 -*-

import io
import sys
import math

def solve():
    
    pass

def main():
    # input
    n = int(input())
    s_list = open(0).read().split() 
    
    # process
    ans = str( len( set(s_list)) )
    
    # output
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
5
grape
grape
grape
grape
grape
"""
_EXPECTED = """\
1
"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

# -*- coding: utf-8 -*-

import io
import sys
import math

def solve():
    
    pass

def main():
    # input
    n = int(input())
    s_list = []
    for s in range(n):
      s_list.append(input())
    
    # process
    s_set = set(s_list)
    ans = str( len( s_set) )
    
    # output
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
5
grape
grape
grape
grape
grape
"""
_EXPECTED = """\
1
"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n = int(input())
string_list=[input() for i in range(n)]
c = collections.Counter(string_list)
print(len(c))



from collections import Counter
n = int(input())
string_list=[input() for i in range(n)]
c = collections.Counter(string_list)
print(len(c))



n = int(input())
s = [input() for _ in range(n)]
print(len(set(s)))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
from collections import Counter
a=int(input())
list1=[]
for i in range(a)
list1.append(input())
a=set(list1)
print(len(a))



a=int(input())
list1=[]
for i in range(a):
  list1.append(input())
a=set(list1)
print(len(a))

Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input().split())
S = []
for _ in range(N):
    keihin = input().split()
    if keihin not in S:S.append(keihin)

print(len(S))

N = int(input())
S = []
for _ in range(N):
    S.append(input())

print(len(set(S)))

Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])

print(n)

l = []
for i in range(n):
    if not data[i+1].split()[0] in l:
        l.append(data[i+1].split()[0])
print(len(l))

from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])

l = []
for i in range(n):
    l.append(data[i+1].split()[0])
print(len(set(l)))

Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n = int(input())
s = list(map(str,input().split()))
l = []

for i in range(N):
  l.append(s[i])
 
print(len(set(l)))

n = int(input())
s = input()
l = []

for i in range(N):
  l.append(s[i])
 

print(len(list(set(l))))

n = int(input())
s = list(map(int,input().split()))
l = []

for i in range(N):
  l.append(s[i])
 
print(len(set(l)))

n = int(input())
s = list(input())
S = len(s)
l = []

if n>=S:
  for i in range(n):
    l.append(s[i])
    print(len(set(l)))

elif n<S:
  for i in range(S):
    l.append(s[i])
    print(len(set(l)))

n = int(input())
s = [input() for i in range(n)]
S = len(set(s))

print(S)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n=int(input())
s=[input() for i in range(n)]

a=[]
c=0

for i in s:
    if i not in a:
        c+=1

print(c)

n=int(input())
s=[input() for i in range(n)]

s=set(s)

print(len(s))

Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N=int(input())
count=0
A=''
for i in range(0,N):
  B=input()
  if A==B:
    count+=0
  else:
    count+=1
print(count)   

N=int(input())
x=set([input() for i in range(N)])
print(len(x))

Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
list1=[]
num=int(input())
for i in range (0,num):
	some=input()
    list1.append(some)
print(len(set(i for i in list1 if i.isalpha())))

num=int(input())
for i in range (0,num):
	some=input(list1[])
    list1.append(some)
print(len(set(i for i in list1 if i.isalpha())))

num=int(input())
for i in range (0,num):
	some=input()
    list1.append(some)
print(len(set(i for i in list1 if i.isalpha())))

num=int(input())
for i in range (0,num):
	some=input(list1[])
    list1.append(some)
print(len(set(i for i in lst if i.isalpha())))

list1=[]
num=int(input())
for i in range (0,num):
    list1.append(input())
print(len(set(i for i in list1 if i.isalpha())))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N=int(input())
S=[input() for i in range (N)]
L=list(S)
sorted(L)
print(len(L)+1)

N=int(input())
L=[input() for i range(N)]
M=sorted(L)
print(len(M))

N=int(input())
L=[input() for i in range(n)]
M=set(L)
print(len(M))

N=int(input())
L=[input() for i in range(N)]
M=set(L)
print(len(M))


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
a = int(input())
aaa = list([input(i)for i in range(a)])

ans = len(set(aaa))

print(ans)

a = int(input())
aaa = set([input()for i in range(a)])

bbb = list(set(aaa))

ans = len(bbb)

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
from collections import Counter
N = int(input())
s = [input() for i in range(N)]
print(len(s))

from collections import Counter
N = int(input())
s = [input() for i in range(N)]
c = collections.Counter(s)
print(len(c))

N = int(input())
s = [input() for i in range(N)] 
c = collections.Counter(s)
print(len(c))

N = int(input())
s = [input() for i in range(N)] 
c = collections.Counter(s)
print(c)

from collections import Counter
N = int(input())
s = [input() for i in range(N)]
c = Counter(s)
print(len(c))

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
from collections import Counter

n = int(input())
s = [str(e) for e in input().split()]
print(len(Counter(s)))

from collections import Counter

n = int(input())
s = []
for _ in range(n):
    s.append(input())
print(len(Counter(s)))

Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())
S = []
for i in range(1, N+1):
        S_i = input()
        S.append(S_i)
cnt = 0
for i in range(0, N):
        flg = 0
        for j in range(i+1, N):
                if( S[i] == S[j]):
                        break
        if(flg ==0):
                cnt += 1
print(cnt)

N = int(input())
S = []
for i in range(1, N+1):
        S_i = input()
        S.append(S_i)
A = set(S)
print(len(A))

Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())
S = [int(input()) for i in range(N)]

print(len(set(S)))

N = int(input())
S = [input() for i in range(N)]

print(len(set(S)))

Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
a = int(input())
ar = []
for i in range(a):
    ar.append(l)
print(len(set(ar)))

a = int(input())
ar = []
for i in range(a):
    l = input()
    ar.append(l)
print(len(set(ar)))

Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
import numpy as np
N = int(input())
l = []
for i in range(N):
    l.append(input())
k = np.array(l)
ans = 0
for i in range(N):
    a = 0
    if k[np.argsort(k)[i]]!=a:
        ans+= 1
        a = k[np.argsort(k)[i]]

N = int(input())
l = []
for i in range(N):
    l.append(input())
k = sorted(l)
ans = 0
for i in range(N):
    a = 0
    if l[i]!=a:
        ans+= 1
        a = l[i]
print(ans)

N = int(input())
l = []
for i in range(N):
    l.append(input())
k = sorted(l)
ans = 0
for i in range(N):
    a = 0
    if k[i]!=a:
        ans+= 1
        a = k[i]
print(ans)

N = int(input())
l = []
for i in range(N):
    l.append(input())
k = sorted(l)
ans = 0
a = 0
for i in range(N):
    if k[i]!=a:
        ans+= 1
        a = k[i]
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):

i = int(input())
lists = []
for j in range(i):
    lists.insert(j, str(input()))

print(lists)
print(len(set(lists)))


i = int(input())
lists = []
for j in range(i):
    lists.insert(j, str(input()))

print(lists)
print(len(set(lists)))

i = int(input())
lists = []
for j in range(i):
    lists.insert(j, str(input()))

print(lists)
print(len(set(lists)))


N = int(input())
lists = []
for i in range(N):
    lists.append(input())
set_S = list(set(lists))
print(len(set_S))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())
ans = {}
for i in range(N):
  t = input()
  if t not in ans:
    ans[t] = 1
print(len(ans.keys())

N = int(input())
ans = {}
for i in range(N):
  t = input()
  if t not in ans:
    ans[t] = 1
print(len(ans.keys()))


Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())
S =[input() for i in range(N+1)]

s = set(S)

print(len(s))

N = int(input())
S =[input() for i in range(N)]

s = set(S)

print(len(s))

Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
mport collections
S=[]
N=int(input())
for i in range(N):
    S.append(input())
print(len(collections.Counter(S)))
    

    



import collections
S=[]
N=int(input())
for i in range(N):
    S.append(input())
print(len(collections.Counter(S)))
    

Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n = int(input())
s = [input() for _ in range(n)]
ans = [[] for _ in range(n)]

for i in range(n):
  ans[i] = s[i]

print(len(ans))

n = int(input())
s = [input() for _ in range(n)]
ans = [[] for _ in range(n)]

for i in range(n):
     ans[i] = s[i]

ANS = set(ans)
print(len(ANS))

Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())
S = [input() for i in range(N)]
a = set(S)
print(len(a)

N = int(input())
S = [input() for i in range(N)]
a = set(S)
print(len(a))

Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n = int(input())
li = list()
for i range(n):
	li.append(str(input()))

print(len(set(li)))



n = int(input())
li = list()
for i in range(n):
	li.append(str(input()))

print(len(set(li)))



Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
M = int(input())
P = [input().split() for i in range(M)]
print(len(set(P)))

M = int(input())
P = [input() for i in range(M)]
print(len(set(P)))

Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N=input()
S = [str(input()) for i in range(N)]
print(len(set(S)))

S=[str(input()) for i in range(2*10^5-1)]
S.pop(0)
print(len(set(S)))

S=[str(input()) for i in range(2*10^1-1)]
S.pop(0)
print(len(set(S))

S = [str(input()) for i in range(2*10^5)]
#(2*10^5):    
S.pop(0)
if '' in S:
    print(len(set(S))-1)
else:
    print(len(set(S)))

N=int(input())
S = [str(input()) for i in range(N)]
print(len(set(S)))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())
S = set()
for i in range(N):
  S.add(i)
print(len(S))

N = int(input())
S = set()
for i in range(N):
  S.add(input())
print(len(S))

Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
# C - gacha

n = int(input())
s = []
c = 0

for i in range(n):
    s.append(input())

s.sort()

for j in range(n-1):
    if s[j] != s[j+1]:
        c += 1


print(c)


# C - gacha

n = int(input())
s = []
c = 1

for i in range(n):
    s.append(input())

s.sort()

for j in range(1,n):
    if s[j-1] != s[j]:
        c += 1


print(c)


Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
a=set(a)
print(len(a))


n=int(input())
a=[0]*n
for i in range(n):
  a[i]=input()
  
a=set(a)
print(len(a))



Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N=int(input())
S=[]
count++
for i in range(N):
    A=input()
    if A not in S:
        S.append(A)
        count+=1
print(count)

N=int(input())
S=[]
for i in range(N):
    A=input()
    S.append(A)
print(len(set(S)))

Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())

items = [input() for _ in range(N)]

d = {}
for item in items:
  if item not in d:
    d[item] = True
    print(item)
  


N = int(input())

d = {}

for _ in range(N):
  s = input()
  if s not in d:
    print(s)
    d[s] = 1
  


N = int(input())

s = set(input() for _ in range(N))
    
print(len(s))
  


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = input()
str_list = [input() for _ in range(N)]

print(len(set(str_list)))

N = int(input())
str_list = [input() for _ in range(N)]

print(len(set(str_list)))


Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
A=map(int,input().split())
list = []
for n in range(A):
	con = str(input())
	if con not in list:
		list.append(con)
	else: pass
print(str(len(list)))


n = int(input())
s = set(input() for _ in range(n))
print(len(s))

Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n=int(input())
r=0
l=[]
for i in range(n):
  l.append(input())
l.sort()
for i in range(n-1):
  if l[i]!=l[i+1]:
    r+=1
  
print(r)


n=int(input())
r=1
l=[]
for i in range(n):
  l.append(input())
l.sort()
for i in range(n-1):
  if l[i]!=l[i+1]:
    r+=1
  
print(r)


Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())

arr = []

for i in range(N):
    arr.append(input())

print(len(set(arr))

N = int(input())

arr = []

for i in range(N):
    arr.append(input())

print(len(arr.set()))

N = int(input())

arr = []

for i in range(N):
    arr.append(input())

print(len(set(arr)))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n = int(input())
al = []
count = 1
for i in range(n):
  a = input()
  if a　in al:
    count += 1
  else:
    al.append(a)
print(count)

s = set(open(0))
print(len(s)-1)


Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())
L = []
if not (1 <= N <= 2*(10**5)):
    exit()


for i in range(N):
    d = input()
    if not (1 <= len(d) <= 10):
        exit()
    if not (d.lower() == d):
        exit()
    L.append(d)

print(len(set(L)))
root@stypr-ubuntu:~/1# 

N = int(input())
L = []
if not (1 <= N <= 2*(10**5)):
    exit()


for i in range(N):
    d = input()
    # if not (1 <= len(d) <= 10):
    #    exit()
    # if not (d.lower() == d):
    #     exit()
    L.append(d)

print(len(set(L)))

Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())
# N = 3

items = []

for i in range(0, N) :
    newItem = str(input())
    # newItem = str("apple")

    if newItem not in items :
        items.append(newItem)

len(items)

N = int(input())
# N = 3

items = set()

for i in range(0, N) :
    items.add(str(input()))
    # items.add(str("apple"))
    # print(newItem)

print(len(items)) # don't forget print()!

Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n = int(input())
ls = []
count = 0
for x in range(n):
    ls.append(input())
set(ls)
print(len(ls))

n = int(input())
ls = []
count = 0
for x in range(n):
    ls.append(input())
ls = set(ls)
print(len(ls))

Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input)
ans = []
for _ in range(N):
  s = input()
  ans.append(s)
print(len(list(set(ans)))

N = int(input())
ans = []
for _ in range(N):
  s = input()
  ans.append(s)
print(len(list(set(ans))))

Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n=int(input())
lists=[input() for x in range(n)]
listget=[]
for s in lists:
    for y in range(1,n+1):
        listget.append(s[y])
print(len(set(listget))
      
     

n=int(input())
lists=[input() for x in range(n)]
print(len(set(lists))

n=int(input())
s=[input() for _ in range(n)]
print(len(set(s)))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())
a = []

for i in range(N):
  a.append(input())
  
b = set(a)
print(len(a))

N = int(input())
a = []

for i in range(N):
  a.append(input())
  
b = set(a)
print(len(b))

Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n=int(input())
li=[]
for si in n:
    si=input()
    li.append(si)
print(len(set(li)))

n=int(input())
li=[]
for si in range(n):
    si=input()
    li.append(si)
print(len(set(li)))

Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n = int(input())
obj= []
for i in range (n):
	obj.append(input())
dictOfElems = dict()
for elem in obj:
  if elem in dictOfElems:
    dictOfElems[elem] += 1
  else:
    dictOfElems[elem] = 1
print(len(dict))

n = int(input())
obj= []
for i in range (n)
	obj.append(input())
dictOfElems = dict()
    # Iterate over each element in list
    for elem in obj:
        # If element exists in dict then increment its value else add it in dict
        if elem in dictOfElems:
            dictOfElems[elem] += 1
        else:
            dictOfElems[elem] = 1
print(len(dict))


n = int(input())
obj= []
for i in range (n):
	obj.append(input())
dictOfElems = dict()
    # Iterate over each element in list
    for elem in obj:
        # If element exists in dict then increment its value else add it in dict
        if elem in dictOfElems:
            dictOfElems[elem] += 1
        else:
            dictOfElems[elem] = 1
print(len(dict))

n = int(input())
obj= []
for i in range (n):
	obj.append(input())
dictOfElems = dict()
for elem in obj:
  if elem in dictOfElems:
    dictOfElems[elem] += 1
  else:
    dictOfElems[elem] = 1
print(len(dictOfElems))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n=int(input())
List = [input() for i in range(n)]
set(List)
print(len(List))

n=int(input())
List = [input() for i in range(n)]
d=set(List)
print(len(d))

Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n=int(input())
lst={}
 for i in range(n):
    lst[str(input())]+=1
print(len(lst))

n=int(input())
lst=[]
for i in range(n)
 lst.extend(str(input()))
 
 
list_uniq=[]
for j in lst
 if list_uniq.count(j)==0:
    list_uniq.extend(j)
 else:
    pass
 print(len(list_uniq))

n=int(input())
lst={}
for i in range(n):
 lst.extend(input().split())
list_uniq={}
ans=0
for j in lst:
 if list_uniq.count(j)==0:
    list_uniq.append(j)
    ans+=1
 else:
    pass
print(ans)

n=int(input())
lst=[]
for i in range(n)
 lst.extend(str(input()))


list_uniq=[]
for j in lst
 if list_uniq.count(j)==0:
    list_uniq.extend(j)
 else:
    pass
 print(len(list_uniq))

 

n=int(input())
lst={}
for i in range(n):
  lst[input()]=1
print(len(lst))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
import sys
from collections import Counter


def main():
  scan = sys.stdin.readline
  
  n = int(scan().rstrip())
  s = scan().rstrip().split()
  
  print(len(Counter(s)))


if __name__ == "__main__":
  main()


import sys
from collections import Counter


def main():
  scan = sys.stdin.readline
  
  n = int(scan().rstrip())
  s = [scan().rstrip() for _ in range(n)]
  
  print(len(Counter(s)))


if __name__ == "__main__":
  main()


Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())
L = [input()]

for _ in range(N-1):
    a = input()
    imin = 0
    imax = len(L)-1
    l = 0

    while (imin<imax):
        l = (imin+imax)//2
        if (a==L[l]):
            break
        elif (a>L[l]):
            imin = min(l+1,len(L)-1)
        else:
            imax = max(l-1,0)
    
    if(imax==imin)       
    	if (a>L[imin]):
        	L.insert(imin+1,a)
    	elif (a<L[imin]):
        	L.insert(imin,a)
            
print(len(L))

N = int(input())
L = [input()]
 
for _ in range(N-1):
    a = input()
    imin = 0
    imax = len(L)-1
    l = 0
 
    while (imin<imax):
        l = (imin+imax)//2
        if (a==L[l]):
            break
        elif (a>L[l]):
            imin = min(l+1,len(L)-1)
        else:
            imax = max(l-1,0)
    
    if(imax==imin)       
    	if (a>L[imin]):
        	L.insert(imin+1,a)
    	elif (a<L[imin]):
        	L.insert(imin,a)
            
print(len(L))
N = int(input())
L = [input()]

for _ in range(N-1):
    a = input()
    imin = 0
    imax = len(L)-1
    l = 0

    while (imin<imax):
        l = (imin+imax)//2
        if (a==L[l]):
            break
        elif (a>L[l]):
            imin = min(l+1,len(L)-1)
        else:
            imax = max(l-1,0)
    
    if(imax==imin):     
    	if (a>L[imin]):
        	L.insert(imin+1,a)
    	elif (a<L[imin]):
        	L.insert(imin,a)
            
print(len(L))

N = int(input())
L = set([input() for _ in range(N)])
print(len(L))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())
S = list(map(str,input().split()))

T = list(set(S))
print(len(T))

N = int(input())
S = [input() for i in range(N)]
T = list(set(S))
print(len(T))

Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):

s = int(input())  
s_list = [input() for _ in range(s)]
print(s_list)   

ans = 0

s_list = set(s_list)

print(len(s_list))


s = int(input())  
s_list = [input() for _ in range(s)]


ans = 0

s_list = set(s_list)

print(len(s_list))

Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())
gacha = set()
for _ in range(N):
  gacha.append(input())
print(len(gacha))

N = int(input())
gacha = set()
for _ in range(N):
  gacha.add(input())
print(len(gacha))

Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())
S = []
while True:
    Si = input()
    if Si:
        S.append(Si)
    else:
        break
g = S[: N]
print(g)


c = input().split("\n")
N = int(c[0])
S = c[1:]
print(len(set(S[:N])))


n = int(input())
s = set(input() for _ in range(n))
print(len(s))


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n = int(input())
a = [input() for i in range(n)]

c = collections.counter(a)

print(len(c))

n = int(input())
a = [input().split() for i in range(n)]

c = collections.counter(a)

print(len(c))


import collections
n = int(input())
a = [input() for i in range(n)]
list_a = list(a)
c = collections.Counter(a)

print(len(c))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
import collections

N=int(input())
list=[input() for i in range(N)]

c= collections.Counter(list)

m=0
for i in c.values():
    m+=i

print(m)

import collections

N=int(input())
list=[input() for i in range(N)]

c= collections.Counter(list)

m=0
for i in c.values():
    m+=1

print(m)

Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n = int(input())

l = list()
for num in range (1,n+1):
    l.append(input())

answer = [x for x in set(l) if l.count(x) > 1]
print(len(answer))

n = int(input())

l = list()
for num in range (1,n+1):
    l.append(input())

print(len(set(l)))


Verdicts: Wrong Answer

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
n=int(input())

s=input().split()

ans=[0 for i in range(n)]
for i in range(0,n-1):
    s[i]=int(s[i])
    ans[s[i]-1]+=1

for i in range(0,n):
    print(ans[i])




n=int(input())

s=[0]*n

for i in range(0,n):
    s[i]=input()


s_set=set(s)
ans=len(s_set)
print(ans)


Verdicts: Runtime Error

Accepted
Problem: You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.  How many kinds of items did you get?

Submission attempts (in order):
N = int(input())

keihin = []


for i in range(N):
    if keihin.count(input()) == 0:
        keihin.append(input())


print(len(keihin))


N = int(input())
S = [str(input()) for _ in range(N)]

S.sort()

count = 1

for i in range(N-1):
    if S[i] != S[i+1]:
        count += 1

print(count)

Verdicts: Runtime Error

Accepted
Problem: Given is a string S consisting of digits from `1` through `9`.  Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:  Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

Submission attempts (in order):
from collections import defaultdict

def main():
  s = input()
  n = len(s)

  mod = 2019

  counts = [0] * mod

  prev = int(s[-1])
  counts[prev] += 1
  for i in range(2, n + 1):
    t = prev + int(s[-i]) * 10 ** (i - 1)
    counts[t % mod] += 1
    prev = t

  ans = 0
  for count in counts:
    if count > 1:
      ans += count * (count - 1) // 2

  print(ans)

main()


from collections import defaultdict

def main():
  s = input()
  n = len(s)

  mod = 2019

  counts = [0] * mod

  prev = int(s[-1])
  for i in range(2, n + 1):
    t = prev + int(s[-i]) * 10 ** (i - 1)
    counts[t % mod] += 1
    prev = t

  ans = 0
  for count in counts:
    if count > 1:
      ans += count * (count - 1) // 2

  print(ans)

main()


from collections import defaultdict

def main():
  s = input()
  n = len(s)

  mod = 2019

  counts = [0] * mod

  prev = int(s[-1])
  counts[prev] += 1
  for i in range(2, n + 1):
    t = prev + int(s[-i]) * 10 ** (i - 1)
    print(t)
    counts[t % mod] += 1
    prev = t

  ans = 0
  for count in counts:
    if count > 1:
      ans += count * (count - 1) // 2

  print(ans)

main()



def main():
  s = tuple(map(int, input()[::-1]))

  mod = 2019

  counts = [0] * mod
  counts[0] = 1
  t = 0
  x = 1
  for i in range(len(s)):
    t = (t + s[i] * x) % mod
    counts[t] += 1
    x = (x * 10) % mod

  ans = 0
  for count in counts:
    if count > 1:
      ans += count * (count - 1) // 2

  print(ans)

main()


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given is a string S consisting of digits from `1` through `9`.  Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:  Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

Submission attempts (in order):
s = input()
counts = [0] * 2019
counts[0] = 1
result = 0

for i in range(len(s)):
    mod2019 = int(s[-i:]) % 2019
    print("mod2019={}".format(mod2019))
    counts[mod2019] += 1

for cnt in counts:
    result += cnt*(cnt-1)//2
    
print(result)
    

s = input()[::-1]
counts = [0] * 2019
counts[0] = 1
num, d = 0, 1
result = 0

for i in s:
    num += int(i) * d
    num %= 2019
    d *= 10
    d %= 2019
    counts[num] += 1
    
for cnt in counts:
    result += cnt*(cnt-1)//2
    
print(result)
    

Verdicts: Wrong Answer

Accepted
Problem: Given is a string S consisting of digits from `1` through `9`.  Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:  Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

Submission attempts (in order):
def main():
    import sys
    S = sys.stdin.readline()[:-1]

    S = input()
    int_S = int(S)
    N = len(S)
    cnt = 0
    pos_l = 0
    pos_r = 0


    while (True):
        pos_r +=  + 1
        
        if (pos_r < N):
            tmp = int(S[pos_l: pos_r + 1])
            if (tmp % 2019 == 0):
                cnt += 1
                pos_l = pos_r
        else:
            pos_l += 1
        
        if (pos_l >= N):
            break


    print(cnt)

if __name__ == '__main__':
    main()

def main():
    import collections

    S = input()

    mod_list = [0]

    for i in range(len(S)):
        index = len(S) - i - 1
        num = int(S[index])

        mod_list.append((mod_list[-1] + num * pow(10, i, 2019)) % 2019)

    CTR_mod_list = collections.Counter(mod_list).most_common()
    cnt = 0

    for i in range(len(CTR_mod_list)):
        n = CTR_mod_list[i][1]

        if (n == 1):
            break

        cnt += n * (n - 1) // 2

    print(cnt)

if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: Given is a string S consisting of digits from `1` through `9`.  Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:  Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

Submission attempts (in order):
P=2019
S = input()
N=len(S)

ans = 0
count = [0] * P
count[0] = 1
u = 0
for i, s in enumerate(reversed(S)):
  print(i,s)
  u = (int(s) * pow(10, i, P) + u) % P
  ans += count[u]
  count[u] += 1

print(ans)

P=2019
S = input()
N=len(S)
count=[0]*P
ans = 0
count[0] = 1
u = 0
for i, s in enumerate(reversed(S)):
  u = (int(s) * pow(10, i, P) + u) % P
  ans += count[u]
  count[u] += 1
 
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given is a string S consisting of digits from `1` through `9`.  Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:  Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

Submission attempts (in order):
d = {0: 1}
s, p = 0, 1
for c in reversed(input()):
  s = (s + p * int(c)) % 2019
  d[s] = d.get(s, 0) + 1
  p = p * 10 % 2019
print(sum(x * (x - 1) // 2 for x in d))


from collections import defaultdict

d = defaultdict(int)
d[0] = 1
s, p = 0, 1
for c in reversed(input()):
  s = (s + p * int(c)) % 2019
  d[s] = d.get(s, 0) + 1
  p = p * 10 % 2019
print(sum(x * (x - 1) // 2 for x in d.values()))


Verdicts: Wrong Answer

Accepted
Problem: Given is a string S consisting of digits from `1` through `9`.  Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:  Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

Submission attempts (in order):
from functools import reduce

n = int(input())  
l = [int(x) for x in list(str(n))]

num=len(l)
count=0
sum=0
for i in range(num-3): 
    for j in range(3,num):
        if i>=j or j-i<3:
            pass
        else:
            for x in l[i:j+1]:
                sum=sum+x
            if sum%3==0:
                new_n = int(reduce(lambda x, y: x + y, [str(x) for x in l[i:j+1]]))
                if new_n%2019==0:
                  count=count+1  
print(count)
    

input()
s=s[::-1]
n=len(s)
 
count=[0]*2019
count[0]=1
num,d=0,1
 
for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1
 
ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)

nput()
s=s[::-1]
n=len(s)
 
count=[0]*2019
count[0]=1
num,d=0,1
 
for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1
 
ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)

s=input()
s=s[::-1]
n=len(s)
 
count=[0]*2019
count[0]=1
num,d=0,1
 
for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1
 
ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: Given is a string S consisting of digits from `1` through `9`.  Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:  Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

Submission attempts (in order):

s=list(input())[::-1] 
n=len(s)
amari_lis=[0]*2019 # 
amari_lis[0]=1 

num=0
kurai=1
for keta in s:
    num+=int(keta)*kurai
    num%=2019
    amari_lis[num]+=1
    kurai*=10
    kurai%=2019 

ans=0
for i in amari_lis:
    ans+=i*(i-1)/2 

print(ans)

s=list(input())[::-1] 
n=len(s)
amari_lis=[0]*2019 # 
amari_lis[0]=1 

num=0
kurai=1
for keta in s:
    num+=int(keta)*kurai
    num%=2019
    amari_lis[num]+=1
    kurai*=10
    kurai%=2019 

ans=0
for i in amari_lis:
    ans+=i*(i-1)/2 

print(int(ans))

Verdicts: Wrong Answer

Accepted
Problem: Given is a string S consisting of digits from `1` through `9`.  Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:  Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

Submission attempts (in order):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=SI()
n=len(s)
beki=[0 for i in range(n+1)]
beki[0]=1
for i in range(n):
    beki[i+1]=(beki[i]*10)%2019


#k=int(s)
dp=[0 for i in range(n)]
dp[-1]=int(s[-1])
for i in range(n):
    j=n-i-1
    dp[j-1]=(dp[j]+int(s[j-1])*beki[i+1])%2019
#print(dp)
ans=0
u=Counter(dp)
for i in u:
    ans+=(u[i]*(u[i]-1))//2
print(ans)
            


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=SI()
n=len(s)
beki=[0 for i in range(n+1)]
beki[0]=1
for i in range(n):
    beki[i+1]=(beki[i]*10)%2019


#k=int(s)
dp=[0 for i in range(n)]
dp[-1]=int(s[-1])
#print(dp[3])
for i in range(n-1):
    j=n-i-1
    
    dp[j-1]=(dp[j]+int(s[j-1])*beki[i+1])%2019

#print(dp)
ans=0
u=Counter(dp)
#print(u)
for i in u:
    if i==0:
        ans+=(u[i]*(u[i]+1))//2
    else:
        ans+=(u[i]*(u[i]-1))//2
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given is a string S consisting of digits from `1` through `9`.  Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:  Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

Submission attempts (in order):
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = readline().decode()
n = list(reversed(n))

x = 1
count = [0 for _ in range(2019)]
MOD = 2019
acc = 0

count[0] = 1
ans = 0

for c in n:
    a = x * int(c)
    acc += a
    acc %= MOD
    ans += count[acc]
    count[acc] += 1
    x = (x * 10) % MOD

print(ans)


import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = readline().decode()
n = list(reversed(n))

x = 1
count = [0 for _ in range(2019)]
MOD = 2019
acc = 0

count[0] = 1
ans = 0

for c in n:
    a = x * int(c)
    acc += a
    acc %= MOD
    ans += count[acc]
    count[acc] += 1
    x = (x * 10) % MOD

print(ans)


import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = input()
n = reversed(n)

x = 1
count = [0 for _ in range(2019)]
MOD = 2019
acc = 0
count[0] = 1
ans = 0

for c in n:
    a = x * int(c)
    acc += a
    acc %= MOD
    ans += count[acc]
    count[acc] += 1
    x = (x * 10) % MOD

print(ans)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given is a string S consisting of digits from `1` through `9`.  Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:  Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

Submission attempts (in order):
S=input()
ans=0
N=len(S)
for i in range(N-2):
  s=S[i:i+3]
  for j in range(i+3,N):
    s+=S[j]
    print(s)
    if int(s)%2019==0:
      ans+=1
print(ans)

S=input()
ans,n=0,len(S)
dp=[0]*(2019)
s,dp[0],k=0,1,1
for i in S[::-1]:
  s=(s+int(i)*k)%2019
  k=(k*10)%2019
  ans+=dp[s]
  dp[s]+=1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given is a string S consisting of digits from `1` through `9`.  Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:  Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

Submission attempts (in order):
def main():
    S = input()
    work, temp = [0] * 2019, 0
    work[0] = 1
    a = 1
    for s in S:
        temp += int(s) * a
        work[temp%2019] += 1
        a *= 10
        a %= 2019
    print(sum([w*(w-1)//2 for w in work]))
main()

def main():
    S = input()
    N = len(S)
    S = int(S)
    work, temp = 0, [0] * 2019, 0
    for i in range(N+1): work[(S % 10**i) % 2019] += 1
    print(sum([w*(w-1)//2 for w in work]))
main()

def main():
    S = input()
    work, temp = [0] * 2019, 0
    work[0] = 1
    a = 1
    for s in S[::-1]:
        temp += int(s) * a
        work[temp%2019] += 1
        a *= 10
        a %= 2019
    print(sum([w*(w-1)//2 for w in work]))
main()

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Given is a string S consisting of digits from `1` through `9`.  Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:  Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

Submission attempts (in order):
s = input()
n = len(s)
cnt = 0
for i in range(n-2):
    for j in range(i+3, n+1):
        if int(s[i:j]) % 2019 == 0:
            print(i, j)
            cnt += 1

print(cnt)

s = input()[::-1]
 
sum_of_digits = 0
 
cnts = [0] * 2019
 
cnts[0] = 1
 
d = 1
 
for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019
    cnts[sum_of_digits] += 1
 
ans = 0

for cnt in cnts:
    ans += cnt * (cnt - 1) // 2
 
print(ans)


Verdicts: Wrong Answer

Accepted