akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : ATcoder.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string>
using namespace std;


int main() {
	string S;
	cin>>S;
	int t=S.size(),e=0;
	for(int i=0;i<S.size();++i){
		if(S[i]=='A')t=min(t,i);
		if(S[i]=='Z')e=max(e,i);
	}
	cout<<e-t+1<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main(){
  int N, Q;
  while(cin >> N >> Q, N){
    map<int, string> M;
    map<string, int> E;
    string eraname;
    int eb, w;
    for(int i = 0; i < N; ++i){
      cin >> eraname >> eb >> w;
      M[w-eb] = eraname;
      E[eraname] = w;
    }
    for(int i = 0; i < Q; ++i){
      cin >> w;
      int t = 0;
      eraname = "Unknown";
      for(map<int, string>::iterator iter = M.begin(); iter != M.end(); ++iter){
	if(iter->first < w && w <= E[iter->second]){
	  eraname = iter->second;
	  t = w - iter->first;
	}else if(iter->first >= w) break;
      }
      cout << eraname;
      if(t) cout << " " << t;
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3348
#include<bits/stdc++.h>
using namespace std;

string s1,s2,ans;
int n,m;
bool f;

int main(){
	cin>>s1>>s2;
	n=(int)s1.size();
	m=(int)s2.size();
	ans="~";
	for(int i=n-m;i>=0;i--){
		f=true;
		for(int j=0;j<m;j++)
			if(s1[i+j]!='?'&&s1[i+j]!=s2[j]){
				f=false;
				break;
			}
		if(f){
			
			string t="";
			for(int j=0;j<i;j++) {
				if(s1[j]=='?') t+='a';
				else t+=s1[j];
			}
			for(int j=0;j<m;j++) t+=s2[j];
			for(int j=i+m;j<n;j++) {if(s1[j]=='?')t+='a';else t+=s1[j];}
			ans=min(ans,t);
		}
	}
	if(ans=="~") puts("UNRESTORABLE");
	else cout<<ans<<endl;
	return 0;
}
//Dubious Document

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
t = [0]
for i in range(n):
    t.append(list(input()))
del t[0]

a = 0
b = 0
ab = 0
ba = 0
for i in range(n):
    temp = "".join(t[i])
    ab += temp.count("AB")
    if t[i][-1] == "A" and t[i][0] == "B":
        ba += 1
    elif t[i][0] == "B":
        b += 1
    elif t[i][-1] == "A":
        a += 1

if a == 0 and b == 0:
    temp = max(0,ba - 1)
else:
    temp = min(a,b) + ba

print(ab + temp)


Measured memory_bytes: 47192
#include <bits/stdc++.h>
/*
#include <cstdio>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>
 */
using namespace std;
#define LSON            id << 1 , l , mid
#define RSON            id << 1 | 1 , mid + 1 , r
#define LS              id << 1
#define RS              id << 1 | 1
#define ROOT            1 , 1 , n
#define CLR(x , y)      memset(x , y , sizeof(x))
#define LOWBIT(x)       x & (-x)
#define FORN(i , a , n)  for(int i = (a) ; i <= (n) ; ++i)
#define FORP(i , n , a)  for(int i = (n) ; i >= (a) ; --i)
#define CASE(x)		printf("Case %d: ", x)
#define CASE#(x) printf("Case #%d: " , x)
#define SFD(x)      scanf("%lf" , &x)
#define SFC(x)      scanf(" %c" , &x)
#define SFS(x)      scanf(" %s" , x)
#define SFI(x)      scanf("%d" , &x)
//#define SFL(x)      scanf("%lld" , &x)
#define SFI64(x)    scanf("%I64d" , &x)
#define PFF(x)         printf("%f" , x)
#define PFD(x)         printf("%lf" , x)
#define PFI(x)         printf("%d" , x)
#define PFC(x)         printf("%c" , x)
#define PFS(x)         printf("%s" , x)
#define PFI64(x)       printf("%I64d" , x)
//#define PFL(x)         printf("%lld" , x)
#define SPACE          printf(" ")
#define PUT            puts("")
#define TEST           printf("pass\n");
#define LPUP(i , j , k) for(int i = j ; i <= k ; ++i)
#define LPDW(i , j , k) for(int i = j ; i >= k ; --i)
#define PB(x)          push_back(x)
#define ALL(A)         A.begin(), A.end()
#define SZ(A)          int((A).size())
#define LBD(A, x)      (lower_bound(ALL(A), x) - A.begin())
#define UBD(A, x)      (upper_bound(ALL(A), x) - A.begin())
//#define LOCAL
static const double PI = acos(-1.0);
static const double EPS = 1e-8;
static const int SEED = 131;
static const int OO = 0X3fffffff;
typedef unsigned long long ULL;
typedef long long LL;
typedef double DB;
inline int read1()
{
    int x = 0;
    int f = 1 ; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {x = (x << 1) + (x << 3) + (ch - '0'); ch = getchar();}
    x *= f;
    return x;
}

struct buf
{
	operator int()
	{
		int x = 0 , y = 0 , c = getchar();
		while(c < 48)
			y = c == 45 , c = getchar();
		while(c > 47)
			x = (x << 1) + (x << 3) + (c - 48) , c = getchar();
		return y ? -x : x;
	}
}read;



inline void write(int x)
{
    int y = 10 , len = 1;
	if(x < 0)
	{
		putchar('-');
		x = -x;
	}
    while(y <= x)
    {
        y *= 10;
        ++len;
    }
    while(len--)
    {
        y /= 10;
        putchar(x / y + 48);
        x %= y;
    }
}

/************************Little Pea****************************/

static const int MAXN = 1e5 + 10;
char s[MAXN];

int main()
{
#ifdef LOCAL
    freopen("G:\\desktop\\littlepea\\in.data" , "r" , stdin);
#endif
    SFS(s + 1);
    int si = strlen(s + 1);
    printf("%c%d%c\n" , s[1] , si - 2 , s[si]);

#ifdef LOCAL
    fclose(stdin);fclose(stdout);
#endif
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+3;
int t=0, id=0, Next[maxn],in[maxn],out[maxn];
int fa[maxn][20], len[maxn];
struct node
{
    int v, next;
}edge[maxn<<1];
void add_edge(int u, int v)
{
    edge[t] = {v, Next[u]};
    Next[u] = t++;
    edge[t] = {u, Next[v]};
    Next[v] = t++;
}
 
void dfs(int cur, int pre, int d)
{
    fa[cur][0] = pre;
    len[cur] = d;
    for(int i=1; i<20; ++i)
        fa[cur][i] = fa[fa[cur][i-1]][i-1];
    in[cur] = ++id;
    for(int i=Next[cur]; i!=-1; i=edge[i].next)
    {
        int v = edge[i].v;
        if(v == pre) continue;
        dfs(v, cur, d+1);
    }
    out[cur] = id;
}
int main()
{
    int n, a, b;
     cin>>n;
    memset(Next, -1, sizeof(Next));
    for(int i=1; i<n; ++i)
    {
        cin>>a>>b;
        add_edge(a, b);
    }
    dfs(1, 0, 0);
    int tmp=(len[n]-1)/2, now=n;
    for(int i=0; i<20;i++)
        if(tmp>>i&1){
		now = fa[now][i];
		}
    int l = n-(out[now]-in[now]+1)-len[n]/2-1;
    int h = out[now]-in[now]+1-tmp-1;
    if(len[n]&1)
    {
        if(l <= h){
		cout<<"Snuke";
		}
        else {
        	cout<<"Fennec";
		}
    }
    else
    {
        if(h <= l){
        	cout<<"Fennec";
		} 
        else{ 
        cout<<"Snuke";
		}
    }
    return 0;
}

Measured memory_bytes: 15872
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N, M, a[200001], b[200001];
	scanf("%d %d", &N, &M);
	for (i = 1; i <= M; i++) scanf("%d %d", &(a[i]), &(b[i]));

	int flag[2][200001] = {}, ans = 0;
	for (i = 1; i <= M; i++) {
		if (a[i] == 1) flag[0][b[i]] = 1;
		if (b[i] == 1) flag[0][a[i]] = 1;
		if (a[i] == N) flag[1][b[i]] = 1;
		if (b[i] == N) flag[1][a[i]] = 1;
	}
	for (i = 1; i <= N; i++) if (flag[0][i] & flag[1][i] == 1) ans = 1;
	
	if (ans == 1) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3328
import math

def cmb(n, r):
    if(n - r < r): r = n - r
    if(r == 0): return(1)
    if(r == 1): return(n)

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if(pivot > 1):
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if(numerator[k] > 1):
            result *= int(numerator[k])

    return(result)


data = input().split(' ')
x = int(data[0])
y = int(data[1])
if(2 * x - y < 0 or 2 * y - x < 0):
    print(0)
elif((2 * x - y) % 3 != 0 or (2 * y - x) % 3 != 0):
    print(0)
else:
    a = (2 * x - y) // 3
    b = (2 * y - x) // 3

    result = cmb(a + b,a)

    print(result % (10**9 + 7))


Measured memory_bytes: 45580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String n;
		n = sc.next();
		
		sc.close();
		String r = "";
		int l = n.length();
		for(int i = 0; i < l; ++i) {
			r += n.charAt(l - i - 1);
		}
		
		if(n.equals(r))
		System.out.println("Yes");
		else System.out.println("No");
		
	}

}


Measured memory_bytes: 20820
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d%d",&A,&B);
    if((A==3)&&(B==1) ||(A==1)&&(B==3))
        printf("2");

    if((A==1)&&(B==2)||(A==2)&&(B==1))
        printf("3");
    if((A==3)&&(B==2)||(A==2)&&(B==3))
        printf("1");
    return 0;
}


Measured memory_bytes: 128
//shara's here
//私は私は大きい男の子
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAAADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
#include <bits/stdc++.h>
using namespace std;
typedef string s;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 10;
const ll MINF = -(1e18 + 10);
#if defined(BANYANYA)
#include "/home/xsharawi/Desktop/cpp/debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define vl vector<ll>
#define vll vector<vector<ll> >
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int main(){
	ll x,y,cnt=0,k=0;
	cin>>x>>y;
	while(x>0){
	x/=y;
	cnt++;	
	}
	cout<<cnt<<endl;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	






return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 256
// Compiled with: g++ -Wall -std=c++14 -pthread

#include <bits/stdc++.h>

using namespace std;
const int N = 20+5;

int n;
int a[N];
int main(){
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int cnt = 0;
    for(int i=1; i<n-1; i++){
        if ((a[i]>a[i-1] && a[i] < a[i+1]) || (a[i] < a[i-1] && a[i] > a[i+1])) {
             cnt++;
        }
    }
    cout << cnt << endl;                                                                        
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int M;
  cin>>M;
  cout<<48-M<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int d(int a ,int b){
  int s=0;
  while(a<b){
    a*=2;
    s++;
  }
  return s;
}
int pow(int a){
  int b=1;
  for(int i=0;i<a;i++){
      b*=2;
  }
  return b;
}
int main() {
  double n,k;
  cin>>n>>k;
  double ans=0;
  for(int i=1;i<=n;i++){
    ans+=1/(n*pow(d(i,k)));
  }
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*; 
	public class Main {
	public static void main( String[] args) {			
					
					Scanner in = new Scanner(System.in);
					long a = in.nextInt();
					long s = 0;
					
					for(long i = 1;i<=a;i++) {
						if(i%3==0||i%5==0) {
							continue;
						}
						else {
							s = s+i;
						}
					}
					System.out.println(s);
					
			}}

Measured memory_bytes: 35752
class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        if n < r:
            return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

comb = Combination(2 * 10 ** 6 + 5)

def g(r,c):
    return comb(r+c+2,r+1) - 1

def main():
    r1, c1, r2, c2 = map(int, input().split())
    r1 -= 1
    c1 -= 1
    MOD = 10 ** 9 + 7
    ans = g(r2,c2)
    ans -= g(r2,c1)
    ans -= g(r1,c2)
    ans += g(r1,c1)
    print(ans % MOD)


if __name__ == "__main__":
    main()

Measured memory_bytes: 131924
import java.util.Arrays;
import java.util.Scanner;
import static java.lang.Math.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int temp[]=new int[3];
		for(int i = 0;i < n; i++){
			for(int j = 0;j < 3; j++)	temp[j]=sc.nextInt();
			Arrays.sort(temp);
			
		
			if(temp[0]*temp[0]+temp[1]*temp[1]==temp[2]*temp[2])System.out.println("YES");
			else System.out.println("NO");

		}
	}
}

Measured memory_bytes: 23576
n = int(input())
lst = list(map(int, input().split()))
cnt = 0
slst = []
for i in range(n):
  dif = sum(lst[:i+1]) - sum(lst[i+1:])
  if dif < 0:
    dif *= -1
  slst.append(dif)
print(min(slst))


Measured memory_bytes: 2940
x = int(input())

A = int(x / 1000)
B = int(x / 100) 
C = int(x / 10) 
D = x

x4 = A
x3 = B - A*10
x2 = C - B * 10
x1 = D - C * 10

if x4 == x3 and x3 == x2:
  print('Yes')
  
elif x3 == x2 and x2 == x1:
  print('Yes')
  
else:
  print('No')

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int n;
    char buf[30];

    fgets(buf, sizeof(buf), stdin);

    n= atoi(buf);

    int a=n;
    int b=n*n;
    int c=n*n*n;

    int x=a+b+c;
    
    printf("%d\n", x);
}

Measured memory_bytes: 1612
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using static System.Console;

namespace ABC128B
{
    static class Program
    {
        static void Main(string[] args)
        {
            var n = ReadLine().TryParse<int>();
            var list = new List<Tuple<int, string, int>>();
            foreach (var i in Enumerable.Range(1, n))
            {
                var v = ReadLine().SplitTryParseToList<string>();
                list.Add( Tuple.Create(i, v[0],int.Parse(v[1])));
            }

            var l = list.OrderBy(x => x.Item2).ThenByDescending(y => y.Item3);

            foreach (var tuple in l)
            {
                WriteLine(tuple.Item1);
            }
        }

        public static T TryParse<T>(this String input)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                if (converter != null)
                {
                    return (T)converter.ConvertFromString(input);
                }
                else
                {
                    throw new InvalidCastException("");
                }
            }
            catch
            {
                throw new InvalidCastException(typeof(T) + " is not supported.");
            }
        }

        public static List<T> SplitTryParseToList<T>(this String input)
        {
            return input.Split().Select(n => n.TryParse<T>()).ToList();
        }

        public static List<T> ListSwap<T>(this List<T> list, Int32 index1, Int32 index2)
        {
            var t = list[index1];
            list[index1] = list[index2];
            list[index2] = t;
            return list;
        }

        public static List<Tuple<T, int>> DuplicateCount<T>(this IEnumerable<T> list)
        {
            return list
                .GroupBy(i => i)
                .Where(g => g.Any())
                .Select(g => Tuple.Create(g.Key, g.Count()))
                .ToList();
        }
        public static List<Tuple<T, int>> DuplicateSort<T>(this IEnumerable<Tuple<T, int>> list)
        {
            return list.OrderByDescending((x) => x.Item2).ToList();
        }
        public static List<T> ReadLineOne<T>(int n)
        {
            var list = new List<T>();
            foreach (var i in Enumerable.Range(1, n))
            {
                list.Add(Console.ReadLine().TryParse<T>());
            }
            return list;
        }
        public static void PrintAll<T>(this IEnumerable<T> list)
        {
            foreach (var i in list)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 14688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i,n) for (int i = 1; i < (int)(n+1); i++)
#define N_MAX 3010

int main() {
  int N;
  vector<long double> p(N_MAX);
  vector<vector<long double>> dp(N_MAX, vector<long double> (N_MAX));
  long double res = 0;

  cin >> N;
  rep(i,N){
    cin >> p.at(i+1);
  }

  dp.at(0).at(0) = 1.0;
  for(int i = 1; i < N+1; i++){
    for(int j = 0; j < i+1; j++){
      if(j == 0){
        dp.at(i).at(j) = dp.at(i-1).at(j)*(1-p.at(i));
      }
      else if(j < i){
        dp.at(i).at(j) = dp.at(i-1).at(j)*(1-p.at(i)) + dp.at(i-1).at(j-1)*p.at(i);
      }
      else{
        dp.at(i).at(j) = dp.at(i-1).at(j-1)*p.at(i);
      }
    }
  }

  for(int i = N/2+1; i <= N; i++){
    res += dp.at(N).at(i);
  }

  cout << fixed << setprecision(10) << res << endl;

  return 0;
}

Measured memory_bytes: 144128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  REP(i,1,n+1){
    t1 = n / i;
    ans += ((i+t1 * i) * t1 / 2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int D;
  cin >> D;
  string s;

  switch (D)
  {
  case 25:
    s = "Christmas";
    break;
  case 24:
    s = "Christmas Eve";
    break;
  case 23:
    s = "Christmas Eve Eve";
    break;
  case 22:
    s = "Christmas Eve Eve Eve";
    break;
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

#define rep(i,n) for (int i=0;i<(n);i++)
#define Graph vector<vector<int>>

int main() {
  
  int H,W;
  scanf("%d%d",&H,&W);

  Graph A( H , vector<int> (W,0) );
  Graph count( H , vector<int> (W,0) );
  queue< pair<int,int> > que;

  rep(y,H){
    rep(x,W){

      char a;
      cin >> a;
      if( a == '#' ){
       A[y][x]=1;
       que.push( make_pair(x,y) );
      }
   
    }
  }

  vector<int> dx = { 0, 1, 0, -1 };
  vector<int> dy = { 1, 0, -1, 0 };
  int res = 0;
  
  while( !que.empty() ){

        pair<int,int> v = que.front();
        que.pop();

        int x = v.first;
        int y = v.second;

        rep(i,4) {

            int nv_x = x + dx[i];
            int nv_y = y + dy[i];

            //通れるか？
            if ( nv_x < 0 || nv_x >= W ) continue;
            if ( nv_y < 0 || nv_y >= H ) continue;
            if ( A[nv_y][nv_x] == 1 ) continue;
            
            A[nv_y][nv_x] = 1;
            count[nv_y][nv_x] = count[y][x] +1;
            res = count[nv_y][nv_x];
            que.push( make_pair(nv_x,nv_y) );

        }
    }
   
  printf("%d\n", res );
  return 0;

}


Measured memory_bytes: 16272
#include <bits/stdc++.h>
using namespace std;
int n,i,j,v[100010],ok[100010],curent,q,a,b;
int main()
{
    cin>>n;
    ok[1]=ok[2]=1;
    for(i=1;i<=n;i++)
        v[i]=i;
    curent=1;
    cin>>q;
    for(i=1;i<=q;i++)
    {
        cin>>a>>b;
        if(a==curent)
            curent=b;
        else if(b==curent)
            curent=a;
        swap(v[a],v[b]);
        if(curent>1)
            ok[v[curent-1]]=1;
        if(curent<n)
            ok[v[curent+1]]=1;
    }
    cout<<count(ok+1,ok+n+1,1);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=55;
int a[maxn][maxn];
int main()
{
    IO;
    int n,m;
    cin >> n >> m;mm(a,0);
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            char x;
            cin >> x;
            a[i][j]=x=='#';
        }
    }
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
            if(a[i][j]&&!a[i][j+1]&&!a[i][j-1]&&!a[i+1][j]&&!a[i-1][j])re cout<<"No\n",0;
    puts("Yes");
    re 0;
}

Measured memory_bytes: 256
N, K = input().split()
A = input().split()

dic = {}
for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

li  = [0] * len(dic)
i   = 0
for d in dic:
    li[i] = dic[d]
    i += 1

total = 0
li.sort()
if len(li) > int(K):
    total += sum(li[:len(li)-int(K)])

print(total)

Measured memory_bytes: 36204
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
p=10**9+7
n, m = map(int, input().split())
a = list(int(input()) for i in range(m))

safe = [1]*(n+1)
for aa in a:
    safe[aa]=0

dp = [0]*(n+1)
dp[0] = 1

if safe[1]:dp[1]=1

for i in range(2,n+1):
    if not safe[i]:
        continue

    dp[i] = dp[i-1]%p+dp[i-2]%p

print(dp[-1]%p)

Measured memory_bytes: 8604
#include <iostream>
#include <algorithm>
#include <functional>
#include <math.h>
using namespace std;
int main(){
  int h,w;
  while(1){
    cin>>h>>w;
    if(h==0&&w==0)break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cout<<'#';
      }
      cout<<'\n';
    }
    cout<<'\n';
  }
  return 0;
}



Measured memory_bytes: 3024
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 100005, M = 200005;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}

template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x + '0');
	else write(x / 10), putchar(x % 10 + '0');
}

struct edge {
	int to, nxt, cap;
} graph[(N << 2) + (M << 1)];
int head[N << 1], cur[N << 1], dep[N << 1], par[N << 1], n, s, t, cnt = 0;
bool vis[N << 1];
queue<int> q;

void addedge (int u, int v, int cap) {
	edge e = {v, head[u], cap};
	graph[head[u] = cnt++] = e;
}

bool bfs () {
	for (int i = s; i <= t; i++) cur[i] = head[i], dep[i] = -1;
	q.push(s), dep[s] = 0;
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (int i = head[u]; ~i; i = graph[i].nxt) {
			int v = graph[i].to;
			if (graph[i].cap && dep[v] == -1) {
				q.push(v);
				dep[v] = dep[u] + 1;
			}
		}
	}
	return dep[t] > 0;
}
int dfs (int u, int rest) {
	if (u == t || !rest) return rest;
	int flow = 0;
	for (int &i = cur[u]; ~i; i = graph[i].nxt) {
		int v = graph[i].to;
		if (dep[v] == dep[u] + 1 && graph[i].cap) {
			int go = dfs(v, min(rest, graph[i].cap));
			graph[i].cap -= go, graph[i ^ 1].cap += go;
			rest -= go, flow += go;
			if (!rest) break;
		}
	}
	return flow;
}

int maxflow () {
	int res = 0;
	while (bfs()) res += dfs(s, n + 1);
	return res;
}

void dfs2 (int u) {
	vis[u] = true;
	for (int i = head[u]; ~i; i = graph[i].nxt) {
		int v = graph[i].to;
		if (graph[i].cap && !vis[v]) par[v] = u, dfs2(v);
	}
}

vector<pair<int, int> > e;
int main () {
	read(n);

	s = 0, t = n << 1;
	for (int i = s; i <= t; i++) head[i] = -1, vis[i] = false;
	for (int i = 1; i <= n; i++) addedge(s, i, 1), addedge(i, s, 0);

	for (int i = 1; i < n; i++) {
		int c;
		read(c);
		for (int j = 0; j < c; j++) {
			int x;
			read(x);
			addedge(x, n + i, 1), addedge(n + i, x, 0);
		}
		addedge(n + i, t, 1), addedge(t, n + i, 0);
	}

	int x = maxflow();
	dfs2(s);

	bool flag = (x == n - 1);
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) flag = false;
	}

	if (flag) {
		e = vector<pair<int, int> > (n);
		for (int i = 1; i <= n; i++) {
			if (par[i] != s) e[par[i] - n] = make_pair(i, par[par[i]]);
		}

		for (int i = 1; i < n; i++) {
			write(e[i].first), putchar(' ');
			write(e[i].second), putchar('\n');
		}

	}
	else puts("-1");
	return 0;
}

Measured memory_bytes: 21632
#include<bits/stdc++.h>
using namespace std;

int main(void) {
    int n, m;
    cin >> n >> m;

    vector<vector<int>> G(n), rG(n);
    vector<int> out(n);
    for(int i=0; i<n+m-1; i++) {
        int a,b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        rG[b].push_back(a);
        out[a]++;
    }

    vector<int> ord(n);
    {
        int x = 0;
        queue<int> q;
        for(int i=0; i<n; i++)
            if(out[i] == 0) q.push(i);

        while(!q.empty()) {
            int v = q.front(); q.pop();
            ord[v] = ++x;
            for(auto &i: rG[v])
                if(--out[i] == 0) q.push(i);
        }
    }

    for(int i=0; i<n; i++) {
        int r = 0, mx = 1e9;
        for(auto &j: rG[i])
            if(ord[j] < mx)
                r = j+1, mx = ord[j];
        cout << r << endl;
    }
}


Measured memory_bytes: 12544
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    map<string,int> mp;
    for(int i = 0; i < N;i++){
        string S; cin >> S;
        mp[S]++;
    }
    
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>

#define MAX_N 1000000

using namespace std;

bool criba[MAX_N + 1];
int ocurrences[MAX_N + 1];

int main()
{
    int N, i, A, j, counter;

    scanf("%d", &N);
    memset(ocurrences, 0, sizeof ocurrences);
    for(i = 0; i < N; ++i){
        scanf("%d", &A);
        ++ocurrences[A];
    }

    memset(criba, 0, sizeof criba);
    for(i = 1; i <= MAX_N; ++i)
        if(ocurrences[i]){
            j = (ocurrences[i] > 1) ? i : 2 * i;

            while(j <= MAX_N){
                if(ocurrences[j])
                    criba[j] = true;
                j += i;
            }
        }

    counter = 0;
    for(i = 0; i <= MAX_N; ++i)
        if(!criba[i])
            counter += ocurrences[i];
    printf("%d", counter);

    return 0;

}


Measured memory_bytes: 6616
class SegmentTree():
    def __init__(self,arr,func=min,ie=2**63):
        self.n = 2**(len(arr)-1).bit_length()
        self.ie = ie
        self.func = func
        self.tree = [ie for _ in range(2*self.n)]
        for i in range(len(arr)):
            self.tree[self.n+i-1] = arr[i]
        for i in range(self.n-1)[::-1]:
            self.tree[i] = func(self.tree[2*i+1],self.tree[2*i+2])

    def set(self,index,x):
        index += self.n-1
        self.tree[index] = x
        while index:
            index = (index-1)//2
            self.tree[index] = self.func(self.tree[2*index+1],self.tree[2*index+2])

    def query(self,left,right):
        if right <= left:
            return self.ie
        left += self.n-1
        right += self.n-2
        tmp_l = self.ie
        tmp_r = self.ie
        while right-left>1:
            if left & 1 == 0:
                tmp_l = self.func(tmp_l,self.tree[left])
            if right & 1 == 1:
                tmp_r = self.func(self.tree[right],tmp_r)
                right -= 1
            left = left//2
            right = (right-1)//2
        if left == right:
            tmp_l = self.func(tmp_l,self.tree[left])
        else:
            tmp_l = self.func(self.func(tmp_l,self.tree[left]),self.tree[right])
        return self.func(tmp_l,tmp_r)

def gcd(x,y):
    if x==-1: return y
    if y==-1: return x
    while y: x,y = y,x%y
    return x

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

st = SegmentTree(A,gcd,-1)

maxgcd = 1

for i in range(N):
    maxgcd = max(maxgcd,gcd(st.query(0,i),st.query(i+1,N+1)))

print(maxgcd)

Measured memory_bytes: 75748
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter, defaultdict
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
import copy
import bisect
MOD = 10**9 + 7
from logging import getLogger, StreamHandler, DEBUG, WARNING
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
# handler.setLevel(WARNING)
# logger.setLevel(WARNING)
logger.addHandler(handler)
def main():
    n,k = getList()

    # =================約数列挙=================
    divisors = []
    tmp_div = n + 1
    for i in range(1, int(math.sqrt(n)) + 3):
        if tmp_div * i > n:
            other = n // i
            if i > other:
                break
            elif i == other:
                divisors.append(i)
                break
            else:
                divisors.append(i)
                divisors.append(other)

    divisors.sort()
    n_div = len(divisors)
    # =================約数列挙=================

    # =================dp[0]の作成=============
    diff = [divisors[0]]
    for i, j in zip(divisors, divisors[1:]):
        diff.append(j - i)
    dp = copy.copy(diff)
    # print(dp)
    # =================dp[0]の作成=============

    for iteration in range(k-1):
        dp_copy = []
        tmp = sum(dp) % MOD
        dp_copy.append((tmp * diff[0]) % MOD)
        for cid, dp_content in enumerate(range(n_div - 1)):
            tmp -= dp[n_div - dp_content - 1]
            dp_copy.append((tmp * diff[cid+1]) % MOD)

        dp = copy.copy(dp_copy)

        # print(dp)
    print(sum(dp) % MOD)
    # print(acc)
    # print(n_div)
if __name__ == "__main__":
    main()

Measured memory_bytes: 130268
#include<bits/stdc++.h>
using namespace std;

int main() {
   int n;
   cin >> n;
   map<string,int> gacha;
   int ans = 0;
   for(int i=0; i<n; i++) {
       string temp;
       cin >> temp;
       if(gacha[temp] == 0) ans++;
       gacha[temp]++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 19228
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{


    class Program
    {

        static int Solve(int N, int K, int[] a)
        {

            bool[] dp = new bool[K + 1];

            dp[0] = false;

            for(int i = 1; i <= K; i++)
            {

                for(int j = 0; j < N; j++)
                {
                    if(i - a[j] >= 0)
                    {
                        dp[i] |= !dp[i - a[j]];
                    }
                }

            }

            if (dp[K]) return 1;
            else return 2;

        }
        
        

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);

            int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            if(Solve(N, K, a) == 1)
            {
                Console.WriteLine("First");
            }
            else
            {
                Console.WriteLine("Second");
            }
            
        }
    }
}

Measured memory_bytes: 13288
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String line2 = sc.nextLine();
      
      	if(line2.contains(line)){
      		if(line.charAt(0) == line2.charAt(0)){
      			System.out.println("Yes");
      		}else{
      			System.out.println("No");
      		}
        }else{
          	System.out.println("No");
        }

    }
}

Measured memory_bytes: 35696
# -*- coding: utf-8 -*-

X, Y = map(int, input().split())
mod = 10 ** 9 + 7

times = (X + Y) // 3
if (X + Y) % 3:
    print('0')
    exit()

x = X - times
y = Y - times


def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y


def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


def combination(n, r, mod):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


if y < 0 or x < 0:
    print('0')
    exit()


print(combination(times, y, mod))


Measured memory_bytes: 90584
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

void solve(int N, int M);

void solve(int N, int M) {
  int ans = 0;
  vector<int> C(N + 1, 0);

  for (int i = 0; i < M; i++) {
    int l, r;
    cin >> l >> r;
    C[l - 1] += 1;
    C[r] -= 1;
  }
  for (int i = 0; i < N; i++) {
    if (0 < i) {
      C[i] += C[i - 1];
    }
  }
  for (int c : C) {
    if (c == M) {
      ans += 1;
    }
  }
  cout << ans << endl;
}

int main() {
  int N, M;
  cin >> N >> M;
  solve(N, M);
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    vi a(m), score(n);
    rep(i, m) cin>>a[i];
    rep(i, m){
        rep(j,n){
            int t; cin>>t;
            if (a[i]==t)
                score[j]++;
            else
                score[a[i]-1]++;
        }
    }
    rep(i,n){
        cout<<score[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
#define rev(s) (string((s).rbegin(), (s).rend()))

int main(){
    
    string s;ll k;
    cin>>s>>k;

    int bg=1,ls=1;
    rep(i,s.size()) {
        if (s[i]==s[i+1]) {
            bg++;
        }
        else {
            break;
        }
    }
    rep(i,s.size()) {
        if (s[s.size()-1-i]==s[s.size()-2-i]) {
            ls++;
        }
        else {
            break;
        }
    }

    if (bg+ls>=s.size()) {
        cout<<(s.size()*k)/2<<endl;
        return 0;
    }

    int cnt=0;
    
    if (s[0]==s[s.size()-1]) {
        int joint=bg+ls;
        int p=1;
        for (int i=bg;i<s.size()-1-ls;i++) {
            if (s[i]==s[i+1]) {
                p++;
                if (i==s.size()-1-ls-1) {
                    if (p>1) {
                        cnt+=p/2;
                    }
                }
            }
            else {
                if (p>1) {
                    cnt+=p/2;
                }
                p=1;
            }
        }
        cout<<(joint/2)*(k-1)+cnt*k+ls/2+bg/2<<endl;
    }
    else {
        int p=1;
        rep(i,s.size()-1) {
            if (s[i]==s[i+1]) {
                p++;
                if (i==s.size()-2) {
                    if (p>1) {
                        cnt+=p/2;
                    }
                }
            }
            else {
                if (p>1) {
                    cnt+=p/2;
                }
                p=1;
            }
        }
        cout<<cnt*k<<endl;
    }   
}


Measured memory_bytes: 256
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()

for i in range(1,10):
	if n%i == 0:
		if (n//i)%10 == n//i:
			print("Yes")
			exit()
print("No")

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const LL MOD = 1000000007;

void solve(std::string S){
    int N = 13;
    int x = 1;
    VLL dp(13, 0LL);
    dp[0] = 1;

    RREP(i, S.size()-1) {
        VLL next_dp(13, 0LL);
        if(S[i] == '?') {
            REP(y, 10) {
                REP(j, N) {
                    (next_dp[(j + y * x) % N] += dp[j]) %= MOD;
                }
            }
        } else {
            int y = S[i] - '0';
            REP(j, N) {
                (next_dp[(j + y * x) % N] += dp[j]) %= MOD;
            }
        }

        REP(j, N) dp[j] = next_dp[j];

        x *= 10;
        x %= N;
    }

    cout << dp[5] << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n = s.length();
    vector<string> v;
    for (int i = 0; i < n; i++) {
        string tmp = "";
        for (int j = i; j < min(n, i + 5); j++) {
            tmp += s[j];
            v.push_back(tmp);
        }
    }
 
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << v[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
int main(void){ 
    int N;
        cin>>N;
        int A,B;
        cin>>A>>B;
        
    if(N==1){
        cout<<"Hello World"<<endl;

    }else{
    cout<<A+B<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  long long L, R;
  cin >> L >> R;

  R = min(R, L+2019);

  long long ret = 2020;
  for (long long i = L; i <= R; ++i) {
    for (long long j = i+1; j <= R; ++j) {
      ret = min(ret, (i*j)%2019);
    }
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int Q;
int p[100010], p2[100010];
int cum[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  for (int i = 2; i < 100010; i++) {
    p[i] = 1;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) p[i] = 0;
    }
  }
  for (int i = 3; i < 100010; i += 2) {
    if (p[i] && p[(i + 1) / 2]) p2[i] = 1;
  }
  for (int i = 1; i < 100010; i++) {
    cum[i] = cum[i - 1] + p2[i];
  }

  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << cum[r] - cum[l - 1] << endl;
  }

  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
using namespace std;

int main() {
    int n;
    long long x, min = 9999999, max = -9999999, sum = 0;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (x < min) {
            min = x;
        }
        if (x > max) {
            max = x;
        }
        sum += x;
    }

    printf("%lld %lld %lld\n", min, max, sum);
}

Measured memory_bytes: 1156
#include <iostream>
using namespace std;

long min_kobaisu(long a, long b);

int main(){
	long A,B;

	cin>>A>>B;

	cout<<min_kobaisu(A,B)<<endl;
	return 0;
}

long min_kobaisu(long a, long b){
	int i,k;
	long total=0,judge;

	if(a<b){
		judge=b;
		while(total!=judge){
			total+=a;
			if(total>judge) judge+=b;
		}
		return total;
	}
	if(a>b){
		judge=a;
		while(total!=judge){
			total+=b;
			if(total>judge) judge+=a;
		}
		return judge;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i < N; i++) {
        int j = N - i;
        if (j <= i) break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
*a, = map(int, input().split())
l, r = 0, sum(a)
ans = 10**19
for i in range(N-1):
    l += a[i]
    r -= a[i]
    t = l-r
    if abs(t) < ans:
        ans = abs(t)
print(ans)


Measured memory_bytes: 83280
#include <iostream>

int main() {

    long long a;
    std::cin >> a;
    char s, t, u, v;
    std::cin >> s >> t >> u >> v;
    std::cout << a *
                     (100 * (long long)(s - '0') + 10 * (long long)(u - '0') +
                      (long long)(v - '0')) /
                     100
              << std::endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
using namespace std;

void insertionSort(vector<int> &A,int N){
    for(int j=0;j<N;j++){
        if(j!=0)cout<<" ";
        cout<<A[j];
    }
    cout<<endl;
    for(int i=1;i<N;++i){
        int v=A[i];
        int j=i-1;
        while(j>=0 && A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        for(int j=0;j<N;j++){
            if(j!=0)cout<<" ";
            cout<<A[j];
        }
        cout<<endl;
    }
}

int N;
vector<int> A;

int main(){
    cin>>N;
    A.resize(N);
    for(int i=0;i<N;++i){
        cin>>A[i];
    }
    insertionSort(A,N);
    return 0;
}



Measured memory_bytes: 3092