TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.  Given is a string S. Find the minimum number of hugs needed to make S palindromic.

Submission attempts (in order):
n = input()
n = list(n)
print(n)
m = len(n) 
A = 0
if m % 2 == 0:
    K = int(m/2)
    a = n[0:K]
    n.reverse()
    b = n[0:K]
else:
    K = int((m - 1) / 2)
    a = n[0:K]
    n.reverse()
    b = n[0:K]
for i, value in enumerate(a):
    if value != b[i]:
        A = A + 1

print(A)

n = input()
n = list(n)
m = len(n) 
A = 0
if m % 2 == 0:
    K = int(m/2)
    a = n[0:K]
    n.reverse()
    b = n[0:K]
else:
    K = int((m - 1) / 2)
    a = n[0:K]
    n.reverse()
    b = n[0:K]
for i, value in enumerate(a):
    if value != b[i]:
        A = A + 1

print(A)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.  Given is a string S. Find the minimum number of hugs needed to make S palindromic.

Submission attempts (in order):
s = list(input())
s_re = s[::-1]
ans =0
for i in range(s//2):
    if s[i] != s_re[i]:
        ans += 1
print(ans)


s = list(input())
length = len(s)
ans = 0
print(s)
for i in range(len(s)//2):
    if s[i] != s[-i-1]:
        ans += 1

print(ans)



s = list(map(str,input().split()))
length = len(s)
ans = 0
for i in range(len(s)//2):
    if s[i] == s[-i-1]:
        ans += 1

print(ans)



s = list(input())

length = len(s)

print(s)
for i in range(len(s)//2):
    if s[i] != s[-i-1]:
        ans += 1

print(ans)



s = list(input())

length = len(s)
ans= 0
for i in range(len(s)//2):
    if s[i] != s[-i-1]:
        ans += 1

print(ans)



Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.  Given is a string S. Find the minimum number of hugs needed to make S palindromic.

Submission attempts (in order):
S = input()
cnt = 0
for i in range(len(S)):
    if S[i]!=S[len(S)-1-i]:
        cnt += 1
print(cnt)

S = input()
cnt = 0
for i in range(len(S)):
    if S[i]!=S[len(S)-1-i]:
        cnt += 1
print(cnt//2)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.  Given is a string S. Find the minimum number of hugs needed to make S palindromic.

Submission attempts (in order):
S = input()

count=0

for i in range(len(S) // 2):
    if S[i] != RS[-1-i]:
        count += 1

print(count)


S = input()

count=0

for i in range(len(S) // 2):
    if S[i] != RS[-i-1]:
        count += 1

print(count)

S = input()
RS = reversed(S)

count=0

for i in range(len(S) // 2):
    if S[i] != RS[i]:
        count += 1

print(count)
        


S = input()


count=0

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

print(count)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.  Given is a string S. Find the minimum number of hugs needed to make S palindromic.

Submission attempts (in order):
s=input()
n=len(s)
les = 0
for i in range(n):
  if s[i] != s[n - i - 1]:
    les += 1
print(les / 2)

s=input()
n=len(s)
res = 0
for i in range(n):
  if s[i] != s[n - i - 1]:
    res += 1
print(int(res / 2))

Verdicts: Wrong Answer

Accepted
Problem: Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.  Given is a string S. Find the minimum number of hugs needed to make S palindromic.

Submission attempts (in order):
word = list(input())

count = 0  

if len(word) % 2 == 0:  
	for i in range(0,int(len(word)/2)):
    	if word[i] != word[int(len(word))-1-i]:
        	count += 1    
    print(count)

else:
	for j in range(0,int((len(word)+1)/2-1)):
    	if word[j] != word[int(len(word))-1-j]:
        	count += 1            
    print(count)


word = list(input())

count = 0  

if len(word) % 2 == 0:  
	for i in range(0,int(len(word)/2)):
    	if word[i] != word[len(word)-1-i]:
        	count += 1    
    print(count)

else:
	for j in range(0,int((len(word)+1)/2-1)):
    	if word[j] != word[len(word)-1-j]:
        	count += 1            
    print(count)

word = list(input())

count = 0  

if len(word) % 2 == 0:  
  for i in range(0,int(len(word)/2)):
    if word[i] != word[int(len(word))-1-i]:
      count += 1    
  print(count)

else:
  for j in range(0,int((len(word)+1)/2-1)):
    if word[j] != word[int(len(word))-1-j]:
      count += 1
  print(count)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
import sys
input = sys.stdin.readline
import numpy as np

n,k = map(int,input().split())
a = np.array([0]+[int(i) for i in input().split()])
np.cumsum(a,out=a)
a = [(ai-i)%k for i,ai in enumerate(a)]
print(a)
from collections import Counter,deque
c = Counter({a[0]:1})
d = deque([a[0]])
ans = 0
for j,aj in enumerate(a[1:]):
  ans += c[aj]
  if j-k >= -2:
    p = d.popleft()
    c.update({p:-1})
  d.append(aj)
  c.update({aj:1})
  
print(ans)

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

n,k = map(int,readline().split())
if k == 1:
  print(0)
  exit()
  
a = [0]+[int(i) for i in readline().split()]
for i in range(1,n+1):
  a[i] = a[i-1]+a[i]
  
a = [(ai-i)%k for i,ai in enumerate(a)]
#print(a)
from collections import Counter,deque
c = Counter({a[0]:1})
d = deque([a[0]])
ans = 0
cnt = 1
for j,aj in enumerate(a[1:]):
  ans += c[aj]
  d.append(aj)
  c.update({aj:1})
  cnt += 1
  if cnt >= k:
    p = d.popleft()
    c.update({p:-1})
  
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
s = 0
S = [0]
for i, a in enumerate(A):
    s += a
    S.append(s % K)

cnt = 0
dic = {}

for i, s in enumerate(S):
    x = (s - i) % K

    if x in dic:
        cnt += dic[x]
        dic[x] += 1
    else:
        dic[x] = 1

    K_prev = i - K + 1

    if K_prev >= 0:
        y = (S[K_prev] - (K_prev)) % K
        dic[y] -= 1


print(cnt)


from collections import defaultdict
import bisect

N, K = map(int, input().split())
A = list(map(int, input().split()))

s = 0
S = [0]
for i, a in enumerate(A):
    s += a
    S.append(s % K)

cnt = 0
dic = {}

for i, s in enumerate(S):
    x = (s - i) % K

    if x in dic:
        cnt += dic[x]
        dic[x] += 1
    else:
        dic[x] = 1

    K_prev = i - K + 1

    if K_prev >= 0:
        y = (S[K_prev] - (K_prev)) % K
        dic[y] -= 1


print(cnt)

Verdicts: Runtime Error

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
import sys

input = lambda: sys.stdin.readline().rstrip()


def comb(n, k):

    if n < k:
        return 0

    m = 1
    for i in range(n, n - k, -1):
        m = m * i

    n = 1
    for i in range(1, k + 1):
        n = n * i

    return (m // n)


def solve():

    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    S = [0 for _ in range(N + 1)]

    for i in range(N):
        S[i + 1] = S[i] + A[i] - 1

    if N < K:
        d = dict()
        for i in range(N + 1):
            k = S[i] % K
            if d[k]:
                d[k] += 1
            else:
                d[k] = 1

        ans = 0
        for k, v in d.items():
            ans += comb(v, 2)

        print(ans)
        exit()

    elif N >= K:

        ans = 0
        d = dict()

        # first
        kf = S[0] % K
        for i in range(K):
            k = S[i] % K
            if k in d:
                d[k] += 1
            else:
                d[k] = 1

        for k, v in d.items():
            ans += comb(v, 2)

        # slide
        for i in range(1, N + 1 - K):
            d[kf] -= 1
            kf = S[i] % K
            k = S[i + K] % K
            if k in d:
                ans += d[k]
                d[k] += 1
            else:
                d[k] = 1

    print(ans)
    exit()


if __name__ == '__main__':
    solve()


import sys
import bisect
input = lambda: sys.stdin.readline().rstrip()


def solve():

    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    S = [0 for _ in range(N + 1)]

    for i in range(N):
        S[i + 1] = S[i] + A[i] - 1

    d = dict()
    for i in range(N + 1):
        k = S[i] % K
        if k in d:
            d[k].append(i)
        else:
            d[k] = [i]

    # print(d)

    ans = 0
    for k, v in d.items():
        if len(v) <= 1:
            continue
        else:
            for i in range(len(v)):
                s = v[i] + K - 1
                si = bisect.bisect_right(v, s)
                ans += (si - i) - 1
                # print(i, si)

    print(ans)


if __name__ == '__main__':
    solve()


Verdicts: Runtime Error

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

cnt = {0:1}

ans = 0

for i in range(1, n+1):
    left = i - k + 1
    if left >= 0:
        ldif = (a[left] - left) % k
        if ldif < 0: ldif += k
        cnt[ldif] -= 1
    
    a[i] += a[i-1]
    dif = (a[i] - i) % k
    if dif < 0: dif += k
    if dif not in cnt:
        cnt[dif] = 0
        
    ans += cnt[dif]
    cnt[dif] += 1

print(ans)

n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

cnt = {0:1}

ans = 0

for i in range(1, n+1):
    left = i - k
    if left >= 0:
        ldif = (a[left] - left) % k
        if ldif < 0: ldif += k
        cnt[ldif] -= 1
    
    a[i] += a[i-1]
    dif = (a[i] - i) % k
    if dif < 0: dif += k
    if dif not in cnt:
        cnt[dif] = 0
        
    ans += cnt[dif]
    cnt[dif] += 1

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
 
 
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    
    ans = 0
    ruiseki = [0]
    d = defaultdict(int)
    d[0]=1
    for i in range(n):
        if i - k + 1>= 0:
            d[ruiseki[i - k+1]]-=1
        ruiseki.append((ruiseki[i] + a[i] - 1)%k)
        ans += d[ruiseki[i+1]]
        d[ruiseki[i + 1]] += 1
    print(ans)
 
 
if __name__ == '__main__':
    main()

from collections import defaultdict 
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    
    ans = 0
    ruiseki = [0]
    d = defaultdict(int)
    d[0]=1
    for i in range(n):
        if i - k + 1>= 0:
            d[ruiseki[i - k+1]]-=1
        ruiseki.append((ruiseki[i] + a[i] - 1)%k)
        ans += d[ruiseki[i+1]]
        d[ruiseki[i + 1]] += 1
    print(ans)
 
 
if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
n,k = map(int,input().split())
l = list(map(int,input().split()))
mo = [0]
mod = [0]
for i in range(n):
    a = l[i]%k
    mo.append((a+mo[-1])%k)
    mod.append((mo[-1]-(i+1))%k)
dic = {0:1}
le = 1
ans = 0
for i in range(1,n+1):
    if le < k:
        if mod[i] in dic:
            ans += dic[mod[i]]
            dic[mod[i]] += 1
        else:
            dic[mod[i]] = 1
        le += 1
    else:
        dic[mod[i-k]] -= 1
        if mod[i] in dic:
            ans += dic[mod[i]]
            dic[mod[i]] += 1
        else:
            dic[mod[i]] = 1
    print(dic)
print(ans)


from collections import defaultdict
n,k = map(int,input().split())
l = list(map(int,input().split()))

mod = [0]
for i in range(n):
    a = (l[i]-1)%k
    mod.append((mod[-1]+a)%k)
dic = defaultdict(int)
ans = 0
for i in range(n+1):
    if i < k:
        ans += dic[mod[i]]
        dic[mod[i]] += 1
    else:
        dic[mod[i-k]] -= 1
        ans += dic[mod[i]]
        dic[mod[i]] += 1
    
print(ans)


Verdicts: Runtime Error

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
from collections import defaultdict, deque

N, K = map(int, input().split())
A = list(map(int, input().split()))

cumA = [0] * (N + 1)
for i in range(1, N + 1):
    cumA[i] = (cumA[i - 1] + A[i - 1]) % K

ans = 0
cnt = defaultdict(int)
cnt[0] += 1
que = deque([])

for i, c in enumerate(cumA[1:], start=1):
    if i > K:
        cnt[que.popleft()] -= 1
    ans += cnt[c % K - i]
    cnt[-(-c % K) - i] += 1
    que.append(-(-c % K) - i)

print(ans)

from collections import Counter, deque

N, K = map(int, input().split())
A = list(map(int, input().split()))
INF = 10**18

cnt = Counter()
cnt[0] = 1
que = deque([0])
sumR = 0
ans = 0
for right, a in enumerate(A, start=1):
    if len(que) >= K:
        cnt[que.popleft()] -= 1
    sumR = (a + sumR) % K
    D = (sumR - right) % K
    ans += cnt[D]
    cnt[D] += 1
    que.append(D)
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
n,k=map(int,input().split())
a=list(map(lambda x:(int(x)-1)%k,input().split()))
s=[0]
for i in a:
    s.append((s[-1]+i)%k)
s.append(0)
mp={}
ans=0
for i in range(len(s)):
    if i-k>=0:
        mp[s[i-k]]-=1
    if s[i] in mp:
        ans+=mp[s[i]]
    if s[i] in mp:
        mp[s[i]]+=1
    else:
        mp[s[i]]=1
print(ans)


n,k=map(int,input().split())
a=list(map(lambda x:(int(x)-1)%k,input().split()))
s=[0]
for i in a:
    s.append((s[-1]+i)%k)
mp={}
ans=0
for i in range(len(s)):
    if i-k>=0:
        mp[s[i-k]]-=1
    if s[i] in mp:
        ans+=mp[s[i]]
        mp[s[i]]+=1
    else:
        mp[s[i]]=1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
from itertools import accumulate
from collections import Counter
N,K,*A = map(int, open(0).read().split())
A = [a-1 for a in A]
B = [0]+[b%K for b in accumulate(A)]
if K>N:
  Cnt = Counter(B)
  ans = sum(v*(v-1)//2 for v in Cnt.values())
else:
  Cnt = Counter(B[:K])
  ans = sum(v*(v-1)//2 for v in Cnt.values())
  for i in range(N-K):
    Cnt[B[i]] -= 1
    ans += Cnt[B[i+K]]
    Cnt[B[i+K]] += 1
print(ans)

from itertools import accumulate
from collections import Counter
N,K,*A = map(int, open(0).read().split())
A = [a-1 for a in A]
B = [0]+[b%K for b in accumulate(A)]
if K>N:
  Cnt = Counter(B)
  ans = sum(v*(v-1)//2 for v in Cnt.values())
else:
  Cnt = Counter(B[:K])
  ans = sum(v*(v-1)//2 for v in Cnt.values())
  for i in range(N+1-K):
    Cnt[B[i]] -= 1
    ans += Cnt[B[i+K]]
    Cnt[B[i+K]] += 1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
d = {}
S = []
N,K = map(int,input().split())
A = list(map(int,input().split()))
s = 0
for i in range(N):
    s = (s+A[i]-i-1)%K
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
    if s not in S:
        S.append(s)
ans = 0
for i in range(len(S)):
    x = S[i]
    y = d[x]
    ans += (y*(y-1))//2
print(ans)

N,K = map(int,input().split())
S = []
d = {}
A = list(map(int,input().split()))
ans = 0
sum =0
for i in range(1,N+1):
    sum += A[i-1] % K
    s = (sum - i) % K
    if i > K:
        x = S.pop(0)
        d[x] -= 1
    elif i < K:
        if s == 0:
            ans += 1
    if s not in d:
        d[s] = 0
    ans += d[s]
    d[s] += 1
    S.append(s)
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
import sys
input = sys.stdin.readline
import numpy as np
from collections import defaultdict

N,K = map(int,input().split())

A = [0] + [int(i)-1 for i in input().split()]


Acum = np.cumsum(A)
Acum = [i%K for i in Acum]

answer = 0
counter = defaultdict(int)



for j,x in enumerate(Acum):
    if j == 0:
        continue
    
    answer += counter[x]
    
    counter[x] += 1
    
    if j-K-1 >= 0:
        
        counter[Acum[j-K+1]] -= 1

print(answer)

import sys
input = sys.stdin.readline
import numpy as np
from collections import defaultdict

N,K = map(int,input().split())

A = [0] + [int(i)-1 for i in input().split()]


Acum = np.cumsum(A)
Acum = [i%K for i in Acum]

answer = 0
counter = defaultdict(int)


# 1 <= j <= N

for j,x in enumerate(Acum):
    
    answer += counter[x]
    
    counter[x] += 1
    
    if j-K+1 >= 0:
        
        counter[Acum[j-K+1]] -= 1

print(answer)

Verdicts: Wrong Answer

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
import numpy
N,K=map(int,input().split())

if K==1:
    print(0)
    exit(0)

A=list(map(int,input().split()))
S=[0]+list(numpy.cumsum(A)) 
S2=[(S[i]-i)%K for i in range(N+1)]
print(A,S,S2)

d = {}
ans = 0
for j in range(1,N+1):
    if j>K-1:
        if S2[j-K] in d:
            d[S2[j-K]] -= 1
        
    if S2[j-1] in d:
        d[S2[j-1]] += 1
    else:
        d[S2[j-1]] = 1
        
    if S2[j] in d:
        ans += d[S2[j]]
print(ans)

import numpy
N,K=map(int,input().split())

if K==1:
    print(0)
    exit(0)

A=list(map(int,input().split()))
S=[0]+list(numpy.cumsum(A)) 
S2=[(S[i]-i)%K for i in range(N+1)]

d = {}
ans = 0
for j in range(1,N+1):
    if j>K-1:
        if S2[j-K] in d:
            d[S2[j-K]] -= 1
        
    if S2[j-1] in d:
        d[S2[j-1]] += 1
    else:
        d[S2[j-1]] = 1
        
    if S2[j] in d:
        ans += d[S2[j]]
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
import sys
import numpy as np
from collections import defaultdict

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array([0] + lr())
A = (A-1) % K
Acum = A.cumsum()
counter = defaultdict(int)
answer = 0
for i, x in enumerate(Acum):
    answer += counter[x]
    counter[x] += 1
    if i >= K-1:
        counter[Acum[i-(K-1)]] -= 1

print(answer)



for i in range(len(Acum)):
    x = Acum(i)
    answer += counter[x]
    counter[x] += 1
    if i >= K-1:
        counter[Acum[i-(K-1)]] -= 1

print(answer)
# 27

import sys
import numpy as np
from collections import defaultdict

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array([0] + lr())
A = (A-1) % K
Acum = A.cumsum()
counter = defaultdict(int)
answer = 0
for i, x in enumerate(Acum):
    answer += counter[x]
    counter[x] += 1
    if i >= K-1:
        counter[Acum[i-(K-1)]] -= 1

print(answer)


import sys
import numpy as np
from collections import defaultdict

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array([0] + lr())
A = (A-1) % K
Acum = A.cumsum()
counter = defaultdict()
answer = 0
for i, x in enumerate(Acum):
    answer += counter[x]
    counter[x] += 1
    if i >= K-1:
        counter[Acum[i-(K-1)]] -= 1

print(answer)


import sys
import numpy as np
from collections import defaultdict

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array([1] + lr())
A = (A-1) % K
N += 1

Acum = (A.cumsum() % K).tolist()
answer = 0
dic = defaultdict(int)
for i, cur in enumerate(Acum): 
    answer += dic[cur]
    dic[cur] += 1
    if i >= K-1:
        vanish = Acum[i-(K-1)]
        dic[vanish] -= 1

print(answer)
# 10

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
import bisect

n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n - 1):
  a[i] -= 1
  a[i + 1] += a[i]
a[n - 1] -= 1

memo = {0 : []}
for i in range(n):
  if a[i] % k not in memo.keys():
    memo[a[i] % k] = [i]
  else:
    memo[a[i] % k].append(i)

ans = bisect.bisect_left(memo[0], k - 1)

for i in memo.keys():
  for j in range(len(memo[i]) - 1):
    ans += bisect.bisect_left(memo[i], memo[i][j] + k) - 1 - j

print(memo)
print(ans)

import bisect

n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n - 1):
  a[i] -= 1
  a[i + 1] += a[i]
a[n - 1] -= 1

memo = {0 : []}
for i in range(n):
  if a[i] % k not in memo.keys():
    memo[a[i] % k] = [i]
  else:
    memo[a[i] % k].append(i)

ans = bisect.bisect_left(memo[0], k - 1)

for i in memo.keys():
  for j in range(len(memo[i]) - 1):
    ans += bisect.bisect_left(memo[i], memo[i][j] + k) - 1 - j

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
from collections import defaultdict
n, k = map(int, input().split())


a = list(map(lambda x: int(x) - 1, input().split()))
s = [0] * (n + 1)
for i in range(n):
	s[i + 1] = (s[i] + a[i]) % k

mp = defaultdict(int)

print(s)
ans = 0
for i in range(n + 1):
	ans += mp[s[i]]
	mp[s[i]] += 1
	if i >= k - 1:
		mp[s[i - k + 1]] -= 1
print(ans)


from collections import defaultdict
n, k = map(int, input().split())

a = list(map(lambda x: int(x) - 1, input().split()))
s = [0] * (n + 1)
for i in range(n):
	s[i + 1] = (s[i] + a[i]) % k

mp = defaultdict(int)

ans = 0
for i in range(n + 1):
	ans += mp[s[i]]
	mp[s[i]] += 1
	if i >= k - 1:
		mp[s[i - k + 1]] -= 1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
N, K = map(int, input().split())
A = [int(a) - 1 for a in input().split()]
B = [0] + A
for i in range(1, N+1):
    B[i] += B[i-1]
    B[i] %= K

D = {}
s = 0
t = 0
ans = 0
for i in range(N+1):
    s = B[i]
    if s in D:
        ans += D[s]
        D[s] += 1
    else:
        D[s] = 1
    if i >= K - 2:
        t = B[i-K+2]
        D[t] -= 1
print(ans)

N, K = map(int, input().split())
A = [0] + [int(a) - 1 for a in input().split()]
for i in range(1, N+1):
    A[i] = (A[i] + A[i-1]) % K

D = {0: 1}
ans = 0
for i in range(1, N+1):
    if i >= K:
        D[A[i-K]] -= 1
    a = A[i]
    if a not in D: D[a] = 0
    ans += D[a]
    D[a] += 1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

#n = int(input())
n,k = [int(i) for i in input().split()]
a = [int(i)-1 for i in input().split()]


acc = [0]
for ai in a:
    acc.append((acc[-1]+ai)%k)

#print(acc)
ans = 0
d = {}
for num,i in enumerate(acc):
    #print(d,num)
    if num >= k-1:
        d[acc[num-k+1]] -= 1
    #print(d,num)
    if i in d:
        ans += d[i]
        d[i] += 1
    else:
        d[i] = 1
    #print(ans)

print(ans)

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

#n = int(input())
n,k = [int(i) for i in input().split()]
a = [int(i)-1 for i in input().split()]


acc = [0]
for ai in a:
    acc.append((acc[-1]+ai)%k)

#print(acc)
ans = 0
d = {}
for num,i in enumerate(acc):
    #print(d,num)
    if num >= k:
        d[acc[num-k]] -= 1
    #print(d,num)
    if i in d:
        ans += d[i]
        d[i] += 1
    else:
        d[i] = 1
    #print(ans)

print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
from itertools import accumulate
from math import factorial as fc

def cmb_2(n):
    return n*(n-1)//2

N,K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
A = [i-1 for i in A]

sumA = list(accumulate(A))
sumA = [0]+[i % K for i in sumA]
x = sumA[:K]
modmap = [0]*K
for i in x:
    modmap[i] += 1

ans = 0
for i in range(K):
    ans += cmb_2(modmap[i],2)

for i in range(N-K+1):
    modmap[sumA[K+i]] += 1
    modmap[sumA[i]] -= 1
    ans += modmap[sumA[K+i]]-1

print(ans)

import sys
from itertools import accumulate
from collections import defaultdict
input = sys.stdin.readline
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = [i-1 for i in a]
suma = [0]+list(accumulate(a))
suma = [i%k for i in suma]
rem = defaultdict(int)
ans = 0
if k > n:
    for i in range(n+1):
        x = suma[i]
        rem[x] += 1
    for s in rem.values():
        ans += s*(s-1)//2
    print(ans)
    exit()
for i in range(k):
    x = suma[i]
    rem[x] += 1
for s in rem.values():
    ans += s*(s-1)//2
for i in range(n-k+1):
    rem[suma[i]%k] -= 1
    rem[suma[i+k]%k] += 1
    ans += rem[suma[i+k]] -1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
from collections import defaultdict
d=defaultdict(int)
N,K=map(int,input().split())
A=list(map(int,input().split()))
S=[None]*N
S[0]=0
cnt=0
d[0]=1
for i in range(1,N):S[i]=(S[i-1]+A[i]-1)%K
for i in range(N):
  if i-K>=0:
    d[S[i]]-=1
  cnt+=d[S[i]]
  d[S[i]]+=1
print(cnt)

from collections import defaultdict
d=defaultdict(int)
N,K=map(int,input().split())
A=[0]+list(map(int,input().split()))
S=[None]*(N+1)
S[0]=0
cnt=0
d[0]=1
for i in range(1,N+1):
  S[i]=(S[i-1]+A[i]-1)%K
for i in range(1,N+1):
  if i-K>=0:
    d[S[i-K]]-=1
  cnt+=d[S[i]]
  d[S[i]]+=1
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
import sys
from collections import Counter
from itertools import accumulate
read = sys.stdin.read

N, K, *A = map(int, read().split())
a = list(accumulate([0] + A))
a = [(a[i] - i) % K for i in range(N + 1)]


def cmb(x):
    return x * (x - 1) // 2


answer = 0
if N < K:
    for i in Counter(a).values():
        answer += cmb(i)
else:
    dic = Counter(a[:K])
    for i in dic.values():
        answer += cmb(i)
    print([0] + A)
    print(a)
    print(dic)
    here = K
    for i, x in enumerate(a[K:]):
        dic[a[i]] -= 1
        answer += dic[x]
        dic[x] += 1

print(answer)

import sys
from itertools import accumulate
read = sys.stdin.read

N, K, *A = map(int, read().split())
a = list(accumulate([0] + A))
print(a)
left = 0
right = 1
pair = []
while right <= N:
    r = (a[right] - a[left]) % K
    if r == right - left:
        pair.append((left, right))
        if right == left + 1:
            right += 1
        else:
            left += 1
    elif r > right - left and left + 1 < right:
        left += 1
    else:
        right += 1

right -= 1
while left < N:
    r = (a[right] - a[left]) % K
    if r == right - left:
        pair.append((left, right))
    left += 1

print(len(pair))

import sys
from collections import Counter
from itertools import accumulate
read = sys.stdin.read

N, K, *A = map(int, read().split())
a = list(accumulate([0] + A))
a = [(a[i] - i) % K for i in range(N + 1)]


def cmb(x):
    return x * (x - 1) // 2


answer = 0
if N <= K:
    for i in Counter(a).values():
        answer += cmb(i)
else:
    dic = Counter(a[:K])
    for i in dic.values():
        answer += cmb(i)

    here = K
    while here <= N:
        if here >= K - 1:
            dic[a[here - K - 1]] -= 1
        if a[here] in dic:
            answer += dic[a[here]]
            dic[a[here]] += 1
        else:
            dic[a[here]] = 1
        here += 1
    print(answer)


import sys
from collections import Counter
from itertools import accumulate
read = sys.stdin.read

N, K, *A = map(int, read().split())
a = list(accumulate([0] + A))
a = [(a[i] - i) % K for i in range(N + 1)]

answer = 0
if N < K:
    for i in Counter(a).values():
        answer += i * (i - 1) // 2
else:
    dic = Counter(a[:K])
    for i in dic.values():
        answer += i * (i - 1) // 2
    here = K
    for i, x in enumerate(a[K:]):
        dic[a[i]] -= 1
        answer += dic[x]
        dic[x] += 1

print(answer)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
n,k = map(int,input().partition())
a = list(map(int,input().split()))
b = [0]*(n+1)

c=0
for i,d in enumerate(a):
    c += d-1
    c%= k
    b[i+1] = c

B = {}
count = 0
for i , d in enumerate(b):
    if i > k:
        B[b[i-k]] -= 1
        
    if d in B:
        count += B[d]
        B[d] += 1
    else:
        B[d] = 1
        
print(count)

n, k = map(int, input().split())
m = list(map(int, input().split()))
T = [0] * (n + 1)

b = 0
for i, a in enumerate(m):
    b += a - 1
    b %= k
    T[i + 1] = b

tmp = {}
count = 0

for i, b in enumerate(T):
    if i >= k:
        tmp[T[i - k]] -= 1

    if b in tmp:
        count += tmp[b]
        tmp[b] += 1
    else:
        tmp[b] = 1

print(count)

Verdicts: Runtime Error

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
ans=0
AA=[A[0]-1]
for i in range(1,n):
  AA.append((AA[-1]+A[i]-1)%k)
import collections
d=collections.defaultdict(int)
d[0]+=1
for i in range(n):
  
  if i+1>=k:
    d[AA[i-k]]-=1
  ans+=d[AA[i]]
  d[AA[i]]+=1
print(ans)


n,k=map(int,input().split())
A=[int(i) for i in input().split()]
ans=0
AA=[(A[0]-1)%k]
for i in range(1,n):
  AA.append((AA[-1]+A[i]-1)%k)
import collections
d=collections.defaultdict(int)
d[0]+=1
for i in range(n):
  
  if i+1>=k:
    d[AA[i-k]]-=1
  ans+=d[AA[i]]
  d[AA[i]]+=1
print(ans)


n,k=map(int,input().split())
A=[int(i) for i in input().split()]
ans=0
AA=[(A[0]-1)%k]
for i in range(1,n):
  AA.append((AA[-1]+A[i]-1)%k)
import collections
d=collections.defaultdict(int)
d[0]+=1
for i in range(n):
  if i+1==k:
    d[0]-=1
  elif i+1>=k:
    d[AA[i-k]]=max(0,d[AA[i-k]]-1)
  ans+=d[AA[i]]
  d[AA[i]]+=1
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.  Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from different positions, even if they are equal sequences.

Submission attempts (in order):
N, K = [int(n) for n in input().split()]

A = [int(n) for n in input().split()]

for i in range(N+1,K+1):
    if K % i == 0:
        K = i
        break

count = 0
for i in range(1,N+1):
    A[i-1] = (A[i-1]+K-1) % K

check = {0: 0}

s = 0
for i in range(1,N+1):
    s += A[i-1]
    if s >= K:
        s -= K
    if s in check:
        count += check[s]
    if s not in check:
        check[s] = 1
    else:
        check[s] += 1

print(count)

N, K = [int(n) for n in input().split()]

A = [int(n) for n in input().split()]

for i in range(N+1,K+1):
    if K % i == 0:
        K = i
        break

count = 0
for i in range(1,N+1):
    A[i-1] = (A[i-1]+K-1) % K

check = {0: True}

s = 0
for i in range(1,N+1):
    s += A[i-1]
    if s >= K:
        s -= K
    if s in check:
        count += 1
    check[s] = True

print(count)

N, K = [int(n) for n in input().split()]

A = [int(n) for n in input().split()]

count = 0
for i in range(1,N+1):
    A[i-1] = A[i-1]-1

check = {0: [0,1,[0]]}

s = 0
for i in range(1,N+1):
    s = (s + A[i-1]) % K
    if s in check:
        j = check[s][0]
        l = check[s][1]
        while j < l and i - check[s][2][j] >= K:
            j += 1
        check[s][0] = j
        count += l - j
        check[s][2].append(i)
        check[s][1] = l + 1
    else:
        check[s] = [0,1,[i]]

print(count)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given are a positive integer N and a string S of length N consisting of lowercase English letters.  Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.

Submission attempts (in order):
N = int(input())
S = input()
print(S[0:len(S) // 2],S[len(S) // 2:])
if S[0:len(S) // 2] == S[len(S) // 2:]:
	print("Yes")
else:
	print("No")


N = int(input())
S = input()
if S[0:len(S) // 2] == S[len(S) // 2:]:
	print("Yes")
else:
	print("No")


Verdicts: Wrong Answer

Accepted
Problem: Given are a positive integer N and a string S of length N consisting of lowercase English letters.  Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.

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

cnt=0
if N%2==1:
    print('No')
else:
    for i in range(int(N/2)):
        if S[i]==S[int(N/2)+i]:
            cnt+=1
        else:
            print('No')
            break
    if cnt==int(N/2):
    print('Yes')

N = int(input())
S = str(input())

cnt=0
if N%2==1:
    print('No')
else:
    for i in range(int(N/2)):
        if S[i]==S[int(N/2)+i]:
            cnt+=1
        else:
            print('No')
            break
    if cnt==int(N/2):
        print('Yes')

Verdicts: Runtime Error

Accepted
Problem: Given are a positive integer N and a string S of length N consisting of lowercase English letters.  Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.

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

a = len(s)
b = a // 2
print(s[b : a])
if n % 2 == 1 :
  print("No")
else :
  if s[:b] == s[b : a] :
    print('Yes')
  else :
    print('No')
    

n = int(input())
s = input()

a = len(s)
b = a // 2

if n % 2 == 1 :
  print("No")
else :
  if s[:b] == s[b : a] :
    print('Yes')
  else :
    print('No')

Verdicts: Wrong Answer

Accepted
Problem: Given are a positive integer N and a string S of length N consisting of lowercase English letters.  Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.

Submission attempts (in order):
import sys


def main(n: int, s: str):
    if n//2 != 0:
        print('No')

    if s[0:n/2] == s[n/2:]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    args = [input() for i in range(2)]
    main(int(args[0]), args[1])


import sys


def main(n: int, s: str):
    if n % 2 != 0:
        print('No')
        return

    p = int(n / 2)
    if s[:p] == s[p:]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    args = [input() for i in range(2)]
    main(int(args[0]), args[1])


Verdicts: Runtime Error

Accepted
Problem: Given are a positive integer N and a string S of length N consisting of lowercase English letters.  Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.

Submission attempts (in order):
N=int(input("Enter"))
S=input()
count=0
if N%2!=0:
  print("No")
elif len(S)!=N:
    print("No")
else:
  for i in range(int(len(S)/2)):
    if S[i]!=S[int(len(S)/2)+i]:
      print("No")
      break
    count+=1
  if count==len(S)/2:
    print("Yes")

N=int(input())
S=input()
count=0
if N%2!=0:
  print("No")
else:
  for i in range(len(S)/2):
    if S[i]!=S[len(S)/2+i]:
      print("No")
      break
    count+=1
  if count==len(S)/2:
    print("Yes")

N=int(input())
S=input()
count=0
if N%2!=0:
  print("No")
else:
  for i in range(len(S)/2):
    if S[i]!=S[len(S)/2+i]:
      print("No")
      break
    count+=1
  if count=len(S)/2:
    print("Yes")

N=int(input())
S=input()
if N%2!=0:
  print("No")
else:
  half=N//2-1
  T1=[]
  T2=[]
  for i in range(half+1):
    T1.append(S[i])
  for j in range(half+1,len(S)):
    T2.append(S[j])
  if T1==T2:
      print("Yes")
  else:
      print("No")


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: Given are a positive integer N and a string S of length N consisting of lowercase English letters.  Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.

Submission attempts (in order):
n=int(input())
s=list(input())
t=n//2
if len(s)!=n:
    print('no')
if n%2 !=0:
    print('no')
elif s[0:t]==s[t:n]:
    print('yes')
else:
    print('no')

n=int(input())
s=list(input())
t=n//2
if len(s)!=n:
    print('no')
if n%2 !=0:
    print('no')
elif s[0:t]==s[t:n]:
    print('yes')
elif s[0:t]!=s[t:n]:
    print('no')

n=int(input())
s=list(input())
t=n//2
if n%2 !=0:
    print('no')
elif s[0:t]==s[t:n]:
    print('yes')
else:
    print('no')

n=int(input())
s=list(input())

if n%2 !=0:
    print('no')
else:
    a=n//2
    t=s[0:a]
    if t+t==s:
        print('yes')
    else:
        print('no')

N=int(input())
S=input()

if N%2 !=0:
    print('no')
else:
    a=N//2
    t=S[0:a]
    if t+t==S:
        print('yes')
    else:
        print('no')

n=int(input())
s=list(input())
t=n//2
if len(s)!=n:
    print('no')
if n%2 !=0:
    print('no')
elif s[0:t]==s[t:n]:
    print('yes')

N = int(input())
S = input()

if N % 2 != 0:
  print("No")
else:
  a = N // 2
  T = S[0:a]
  if T + T == S:
    print("Yes")
  else:
    print("No")


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given are a positive integer N and a string S of length N consisting of lowercase English letters.  Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.

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

if s%2 != 0:
  print('No')
elif s == s[:n/2]*2:
  print('Yes')
else:
  print('No')

n = int(input())
s = str(input())

if n%2 != 0:
  print('No')
elif s == s[:n/2]*2:
  print('Yes')
else:
  print('No')


N = int(input())
S = str(input())

if S[:int(N/2)] == S[int(N/2):]:
    print("Yes")
else:
    print("No")


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given are a positive integer N and a string S of length N consisting of lowercase English letters.  Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.

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

is_even = N % 2 == 0
S1 = S[0:int(len(S) / 2)]
S2 = S[int(len(S) / 2):]

answer = True if is_even and S1 == S2 else False

print(answer)


N = int(input())
S = input()

is_even = N % 2 == 0
S1 = S[0:int(len(S) / 2)]
S2 = S[int(len(S) / 2):]

answer = 'Yes' if is_even and S1 == S2 else 'No'

print(answer)


Verdicts: Wrong Answer

Accepted
Problem: Given are a positive integer N and a string S of length N consisting of lowercase English letters.  Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.

Submission attempts (in order):
n=int(input())
s=input()
if n%2==1:
  print("No")
  exit()
for i in range((n//2)-1):
  if a[i]!=a[-i-1]:
    print("No")
    exit()
print("Yes")

n=int(input())
s=input()
if n%2!=0:
  print("No")
  exit()
for i in range(n//2+1):
  if a[i]!=a[-i-1]:
    print("No")
    exit()
print("Yes")

n=int(input())
s=input()
l=len(s)
s2=s.pop(l//2)
print("Yes" if s==s2 else "No")
  

n=int(input())
s=input()
if n%2==1:
  print("No")
  exit()
for i in range(n//2):
  if s[i]!=s[-i-1]:
    print("No")
    exit()
print("Yes")

n=int(input())
s=input()
if n%2==1:
  print("No")
  exit()
for i in range(n//2):
  if s[i]!=s[n//2+i]:
    print("No")
    exit()
print("Yes")

Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: Given are a positive integer N and a string S of length N consisting of lowercase English letters.  Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.

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

if N % 2 != 0:
    print("No")
else:
    center = N // 2
    for i in range(0,center):
        print(S[i],S[i+center])
        if S[i] != S[i+center]:
            print("No")
            break
        if i == center-1:
            print("Yes")


N = int(input(""))
S = input("")

if N % 2 != 0:
    print("No")
else:
    center = N // 2
    for i in range(0,center):
        if S[i] != S[i+center]:
            print("No")
            break
        if i == center-1:
            print("Yes")


Verdicts: Wrong Answer

Accepted
Problem: Given are a positive integer N and a string S of length N consisting of lowercase English letters.  Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.

Submission attempts (in order):
a=int(input())
b=list(input())
count=0
if(a%2==1):
  print('No')
else:
  for i in range(a/2):
    if(b[i]==b[i+a/2]):
      count+=1
  if(count==a/2):
    print('Yes')
  else:
    print('No')

a=int(input())
b=list(input())
count=0
if(a%2==0):
    a=int(a/2)
    for i in range(a):
        if(b[i]==b[i+a]):
          count+=1
    if(count==a):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Verdicts: Runtime Error

Accepted