akhauriyash/Code-Regression huggingface dataset:
import std.stdio : write, writeln, writefln, stdin;
import std.array;
import std.range;

void main(){
	string[char] en = [
		' '	: "101",
		'\''	: "000000",
		','	: "000011",
		'-'	: "10010001",
		'.'	: "010001",
		'?'	: "000001",
		'A'	: "100101",
		'B'	: "10011010",
		'C'	: "0101",
		'D'	: "0001",
		'E'	: "110",
		'F'	: "01001",
		'G'	: "10011011",
		'H'	: "010000",
		'I'	: "0111",
		'J'	: "10011000",
		'K'	: "0110",
		'L'	: "00100",
		'M'	: "10011001",
		'N'	: "10011110",
		'O'	: "00101",
		'P'	: "111",
		'Q'	: "10011111",
		'R'	: "1000",
		'S'	: "00110",
		'T'	: "00111",
		'U'	: "10011100",
		'V'	: "10011101",
		'W'	: "000010",
		'X'	: "10010010",
		'Y'	: "10010011",
		'Z'	: "10010000",
	];
	char[string] de = [
		"00000" : 'A',
		"00001" : 'B',
		"00010" : 'C',
		"00011" : 'D',
		"00100" : 'E',
		"00101" : 'F',
		"00110" : 'G',
		"00111" : 'H',
		"01000" : 'I',
		"01001" : 'J',
		"01010" : 'K',
		"01011" : 'L',
		"01100" : 'M',
		"01101" : 'N',
		"01110" : 'O',
		"01111" : 'P',
		"10000" : 'Q',
		"10001" : 'R',
		"10010" : 'S',
		"10011" : 'T',
		"10100" : 'U',
		"10101" : 'V',
		"10110" : 'W',
		"10111" : 'X',
		"11000" : 'Y',
		"11001" : 'Z',
		"11010" : ' ',
		"11011" : '.',
		"11100" : ',',
		"11101" : '-',
		"11110" : '\'',
		"11111" : '?',
	];
	
	while(true){
		string str = readln.chomp;
		if(stdin.eof) break;
		string p;
		foreach(c; str){
			p~=en[c];
		}
		string[] q;
		while(p.length>0){
			if(p.length < 5){
				q ~= p.take(p.length).array.to!string ~ repeat('0').take(5-p.length).array.to!string;
				for(auto l=p.length; 0<l; --l){
					p.popFront;
				}
			}else{
				q ~= p.take(5).array.to!string;
				foreach(i; 5.iota){
					p.popFront;
				}
			}
		}
		
		string ans;
		foreach(ite; q){
			ans ~= de[ite];
		}
		
		ans.writeln;
	}
}


import std.stdio : readln, chomp;
import std.conv : to;
import std.string : split;
shared string[] input;
shared string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

void next(T)(ref T v){
	v = next!T();
}

bool hasNext(){
	if(input.length > 0){
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return true;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}

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

int H, W;
char c[32][32];

int tomatu;
int iguti[32 * 32][2];

int main(void) {
	int i, j;
	int igarasihiromi = 0;
	if (scanf("%d%d", &H, &W) != 2) return 1;
	for (i = 0; i < H; i++) {
		if (scanf("%31s", c[i]) != 1) return 1;
	}
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (c[i][j] == 'B') {
				iguti[tomatu][0] = i;
				iguti[tomatu][1] = j;
				tomatu++;
			}
		}
	}
	for (i = 0; i < tomatu; i++) {
		for (j = i + 1; j < tomatu; j++) {
			int futigamimai = abs(iguti[i][0] - iguti[j][0]) + abs(iguti[i][1] - iguti[j][1]);
			if (futigamimai > igarasihiromi) igarasihiromi = futigamimai;
		}
	}
	printf("%d\n", igarasihiromi);
	return 0;
}



Measured memory_bytes: 2144
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>

using namespace std;

int main(){
	int N, M;
	long long result = 0;
	cin >> N >> M;
	vector<int> A(N), sum(N + 1);
	map<int, int> m;

	for (int i = 0; i < N; ++i){
		cin >> A[i];
	}

	sum[0] = 0;
	for (int i = 0; i < N; ++i){
		sum[i + 1] = (A[i] + sum[i]) % M;
	}

	for (int i = 0; i < N + 1; ++i){
		result += m[sum[i]]++;
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 3968
# -*- coding: utf-8 -*-
# @Time    : 2020/3/1 19:59
# @Author  : DIRICHLET
# @File    : main.py


b=[[0,0,0],[0,0,0],[0,0,0]]
#print(b)
m={}
for i in range(3):
    t=list(map(int,input().split()))
    k=0
    for j in t:
        m[j]=(i,k)
        k+=1
n=int(input())
for i in range(n):
    t=int(input())
    if t in m:
        #print(m[t])
        b[m[t][0]][m[t][1]]=1
for i in b:
    ans=1
    for j in i:
        ans*=j
    if ans==1:
        print('Yes')
        exit()
for i in range(3):
    ans=1
    for j in range(3):
        ans*=b[j][i]
    if ans==1:
        print('Yes')
        exit()
if b[0][0]*b[1][1]*b[2][2]==1:
    print('Yes')
    exit()
if b[0][2]*b[1][1]*b[2][0]==1:
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[105];
int main()
{
    ll n,mi=1e18,t;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int p=1;p<=100;p++){
        t=0;
        for(int i=0;i<n;i++) t+=(a[(i+p)%n]-p)*(a[(i+p)%n]-p);
        mi=min(mi,t);
    }
    cout<<mi<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int INF = 1e8;
const int MAX_V = 256;
const int MAX_R = 1024;
int dl[MAX_V][MAX_V];
int ds[MAX_V][MAX_V];
int dp[MAX_R][MAX_V];
int Z[MAX_R];
int N, M;

void floyd()
{
    for (int k = 0; k < N; ++k)
    {
        for (int i = 0; i < N; ++i)
        {
            for (int j = 0; j < N; ++j)
            {
                dl[i][j] = min(dl[i][j], dl[i][k] + dl[k][j]);
                ds[i][j] = min(ds[i][j], ds[i][k] + ds[k][j]);
            }
        }
    }
}

int main()
{
    while (scanf("%d%d", &N, &M) == 2 && N)
    {
        fill(dl[0], dl[0] + MAX_V * MAX_V, INF);
        fill(ds[0], ds[0] + MAX_V * MAX_V, INF);
        for (int i = 0; i < N; ++i)
        {
            dl[i][i] = ds[i][i] = 0;
        }
        int x, y, t;
        char s;
        for (int i = 0; i < M; ++i)
        {
            scanf("%d%d%d", &x, &y, &t);
            cin >> s;
            --x, --y;
            if (s == 'L')
            {
                dl[x][y] = min(dl[x][y], t);
                dl[y][x] = dl[x][y];
            }
            else
            {
                ds[x][y] = min(ds[x][y], t);
                ds[y][x] = ds[x][y];
            }
        }
        int R;
        scanf("%d", &R);
        for (int i = 0; i < R; ++i)
        {
            scanf("%d", &Z[i]);
            --Z[i];
        }
        floyd();
        fill(dp[0], dp[0] + MAX_R * MAX_V, INF);
        dp[0][Z[0]] = 0;
        for (int i = 1; i < R; ++i)
        {
            for (int j = 0; j < N; ++j)
            {
                for (int k = 0; k < N; ++k)
                {
                    if (j == k)
                    {
                        dp[i][j] = min(dp[i][j], dp[i - 1][k] + dl[Z[i - 1]][Z[i]]);
                    }
                    else
                    {
                        dp[i][j] = min(dp[i][j], dp[i - 1][k] + dl[Z[i - 1]][k] + ds[k][j] + dl[j][Z[i]]);
                    }
                }
            }
        }
        int res = *min_element(dp[R - 1], dp[R - 1] + N);
        printf("%d\n", res);
    }
}












Measured memory_bytes: 4696
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    println!("{}", (a + b) % 24);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f // -Wall
using namespace std;

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

/*============ Header Template ============*/

const int N = 200000 + 5;
const int mo = 1000000007;
const int M = 2000;

int n;
int a[N], b[N];
int c[(M << 1) + 5][(M << 1) + 5];
LL f[N], inv[N];

void exgcd(LL a, LL b, LL &x, LL &y) {
	if (b == 0) {x = 1, y = 0; return;}
	exgcd(b, a % b, y, x);
	y -= x * (a / b);
}

LL C(int n, int m) {return m > n ? 0 : f[n] * inv[m] % mo * inv[n - m] % mo;}

void pre() {
	f[0] = 1;
	for (int i = 1; i <= 8000; i++) f[i] = f[i - 1] * i % mo;
	LL y; exgcd(f[8000], mo, inv[8000], y);
	for (int i = 7999; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mo;
}

int main() {
	read(n); pre();
	for (int i = 1; i <= n; i++) read(a[i]), read(b[i]);
	for (int i = 1; i <= n; i++) c[-b[i] + M][-a[i] + M]++;
	for (int i = 0; i <= M * 2; i++)
		for (int j = 0; j <= M * 2; j++) {
			(c[i][j + 1] += c[i][j]) %= mo;
			(c[i + 1][j] += c[i][j]) %= mo;
		}
	LL ans = 0;
	for (int i = 1; i <= n; i++) (ans += c[b[i] + M][a[i] + M]) %= mo;
	for (int i = 1; i <= n; i++) {
		LL tmp = C(a[i] + b[i] + a[i] + b[i], a[i] + a[i]);
		(ans -= tmp) %= mo;
	}
	ans = ans * inv[2] % mo;
	printf("%lld\n", (ans + mo) % mo);
	return 0;
}

Measured memory_bytes: 64640
#include <bits/stdc++.h>
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
bool ok(int a){
    vector<int>V;
    while(a > 0){
        V.PB(a%10);
        a /= 10;
    }
    if(V.size()==1)return true;
    REP(i,V.size()-1){
        if(V[i] - V[i+1] != 1)return false;
    }
    return true;
}
int main(){
    int n;
    int a[1000];
    cin >> n;
    REP(i,n)cin >> a[i];
    int ans=-1;
    REP(i,n)for(int j=i+1;j<n;j++){
        if(ans >= a[i] * a[j])continue;
        if(ok(a[i]*a[j])){
            ans = a[i] * a[j];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3168
//Catchharsh
    //I Luv Kunj017
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (ll x,ll n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    int main()
    {   
         IOS;
         ll n,m,i,j,k;
         cin>>n;
         vector<ll> v(n+1);
         vector<ll> v1(n);
         for(i=0;i<=n;i++)
          cin>>v[i];
        for(i=0;i<n;i++)
          cin>>v1[i];
        ll ans=0;
        for(i=0;i<n;i++)
           {
             if(v1[i]<v[i])
             {
              ans+=v1[i];
             }
             else
             {
               ans+=v[i];
                v1[i]-=v[i];
                v[i]=0;
                if(v1[i]<v[i+1])
                {
                  ans+=v1[i];
                  v[i+1]-=v1[i];
                }
                else
                {
                  ans+=v[i+1];
                  v[i+1]=0;
                }
             }
             // cout<<v[i]<<" "<<v[i+1]<<" "<<ans<<endl;
           }
           cout<<ans;
         
    }

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

int a,b,c,d,e;

int main() {
	cin>>a>>b;
	int sum=0,i=1,bul=1,har=1;
	bool done=0;
	for(int i=1;i<=12;i++) {
		for(int j=1;j<=31;j++) {
			if(i==j) sum++;
			if(i==a&&j==b) done=1;
			if(done) break; 
		}
		if(done) break;
	}
	cout<<sum<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n; cin >> n;
	vector<pair<pair<string, int>, int>> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first.first >> a[i].first.second;
		a[i].first.second *= -1;
		a[i].second = i + 1;
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		cout << a[i].second << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin>>n;
    int s[n],c[n],f[n];
    rep(i,n-1) cin>>c[i]>>s[i]>>f[i];

    int ans[n];
    ans[n-1]=0;
    rep(i,n-1){
        int time=s[i]+c[i];
        for(int j=i+1;j<n-1;j++){
            //cout<<time<<" "<<s[j]<<" "<<f[j]<<" "<<(time-s[j]+f[j]-1)/f[j]<<endl;
            if(time<=s[j]) time=(s[j]+c[j]);
            else time=((time-s[j]+f[j]-1)/f[j])*f[j]+s[j]+c[j];
            //cout<<((time-s[j]+f[j]-1)/f[j])<<endl;
        }
        ans[i]=time;
    }
    rep(i,n) cout<<ans[i]<<endl;

}



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

int main() {
  string A,B,C;
  cin >> A >> B >> C;
  
  A[0] -= 32;
  B[0] -= 32;
  C[0] -= 32;
  cout << A[0] << B[0] << C[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a1,a2,a3,a4,b1,b2,b3,b4,b5,b6,b7,b8;
  cin >> a1 >> a2 >> a3 >> a4 >> b1 >> b2 >> b3 >> b4 >> b5 >> b6 >> b7 >> b8;
  cout << a1 << a2 << a3 << a4 << ' ' << b1 << b2 << b3 << b4 << b5 << b6 << b7 << b8 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int n,m,k;
int a[200005],b[200005];
long long suma[200005],sumb[200005];
int find(long long a[],long long k,int n){
	int l=0,r=n-1;
	while(l<r){
		int mid=(l+r+1)/2;
		if(a[mid]<=k){
			l=mid;
		}
		else{
			r=mid-1;
		}
	}
	if(a[l]>k) return -1;
		return l;
}
int main(){
	
	cin>>n>>m>>k;
	rep(i,0,n) scanf("%d",&a[i]);
	rep(i,0,m) scanf("%d",&b[i]);
	
	rep(i,0,n) suma[i+1]=suma[i]+a[i];//[0,i)
	rep(i,0,m) sumb[i+1]=sumb[i]+b[i];
	
	//
	long long tmp;
	int pt;
	int maxx=0;
	rep(i,0,n+1) 
	{
		tmp=k-suma[i];
		if(tmp<0) break;
		//pt=upper_bound(sumb,sumb+m+1,tmp)-sumb;
		pt=find(sumb,tmp,m+1);// 小于等于tmp的最大值的下标 
		//cout<<pt<<" "<<i<<endl;
		maxx=max(maxx,pt+i);
	}
	printf("%d\n",maxx);
	return 0;
	
} 

Measured memory_bytes: 8504
N, A = map(int, input().split())
x = list(map(int, input().split()))

max_num = max(x)
max_num = max(A, max_num)
# x_jまでからk枚選んで合計がｓになる選び方の総数。ｓはk*Aにすれば平均がAになる
dp = [[[0 for _ in range(max_num * N + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
#何も選ばないで平均が０
dp[0][0][0] = 1

for j in range(N+1):
  for k in range(j+1):
    for s in range(max_num * k + 1):
      if j >= 1 and s < x[j - 1]:
        # j番目を選んでk+1個を選んだ際に平均がAにならない場合
        dp[j][k][s] = dp[j - 1][k][s]
      elif j >= 1 and k >= 1 and s >= x[j - 1]:
        # j番目をえらんでk+1個選んで平均がAになるものがあるなら、j-1番までの合計はs-x_j-1なので、その数を足している
        dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
 

ans = 0
# 合計がkAになるものを加算
for k in range(1, N + 1):
  ans += dp[N][k][k*A]
print(ans)

Measured memory_bytes: 65504
N = int(input())
A = list(map(int,input().split()))
ans = right = total = 0
for left in range(N):
    while right < N and total ^ A[right] == total + A[right]:
        total += A[right]
        right += 1
    ans += right - left
    if left == right:
        right += 1
    else:
        total -= A[left]
print(ans)

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

using namespace std;

int main()
{
  int N, M;
  int dp1[200000], dp2[200000];
  vector< int > line[100001];
  iota(dp1, dp1 + 200000, 0);
  iota(dp2, dp2 + 200000, 0);

  scanf("%d %d", &N, &M);
  for(int i = 0; i < M; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    line[a].push_back(b);
  }
  for(int i = 0; i < 100001; i++) {
    for(auto& j : line[i]) {
      dp2[j - 1] = dp2[j];
      dp1[j] = dp1[j - 1];
    }
  }
  for(int i = 0; i < N; i++) {
    if(i > 0) putchar(' ');
    printf("%d", dp2[i] - dp1[i] + 1);
  }
  puts("");
}

Measured memory_bytes: 10228
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<ll>> cnt(10, vector<ll>(10, 0));
    for(int i = 1; i <= n; i++) {
        string num = to_string(i);
        int a = (int)(num.front() - '0');
        int b = (int)(num.back() - '0');
        cnt[a][b]++;
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        string num = to_string(i);
        int a = (int)(num.front() - '0');
        int b = (int)(num.back() - '0');
        ans += cnt[b][a];
    }
    cout << ans << endl;
}

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

int tip(int a, int b, int c, int d) {
	if (a + b > c + d) return 0;
	if (a + b < c + d) return 2;
	return 1;	
}

int main() {
	char result[3][10] = {"Left", "Balanced", "Right"};
	
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	
	printf("%s", result[tip(a, b, c, d)]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, K;
    cin >> N >> K;

    if(K == 0){
        cout << N * N << endl;
        return 0;
    }

    ll ans = 0;
    rep(b, 1, N+1){
        ll bb = N/b;
        //cerr << b << " " << bb << endl;
        ans += max(b - K, 0LL) * bb;
        ans += max(N - b * bb - K + 1, 0LL);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,M;
  scanf("%d %d",&N,&M);
  int H[100002],d[100002];
  for(int i=1;i<=N;i++){
    scanf("%d",H+i);
    d[i]=1;
  }
  int A,B;
  for(int i=1;i<=M;i++){
    scanf("%d %d",&A,&B);
    if(H[A]<H[B]) d[A]=0;
    else if(H[A]>H[B]) d[B]=0;
    else{
      d[A]=0;
      d[B]=0;
    }
  }
  for(int i=2;i<=N;i++)
    d[1]+=d[i];
  printf("%d\n",d[1]);
  return 0;
}

Measured memory_bytes: 2492
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int L[1010][1010];

int main()
{
	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		L[0][0] = L[0][1] = L[1][0] = 0;
		string s1, s2;
		cin >> s1 >> s2;

		for (int j = 1; j <= s1.size(); j++) {
			for (int k = 1; k <= s2.size(); k++) {
				if (s1[j - 1] == s2[k - 1]) {
					L[j][k] = L[j - 1][k - 1] + 1;
				}
				else {
					L[j][k] = max(L[j-1][k],L[j][k-1]);
				}
			}
		}
		cout << L[s1.size()][s2.size()] << endl;
	}
	return	0;
}

Measured memory_bytes: 7084
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <deque>
#include <string.h>
#include <math.h>

using namespace std;

#define PI 3.141592653589793
#define epsilon 0.000000001
#define INF 1000000000000000000
#define MOD 1000000007

int main(){
    //freopen("grass.in", "r", stdin); freopen("grass.out", "w", stdout);
    int N, M, K; cin >> N >> M >> K;
    for(int i = 0; i <= N; i++){
        if(N-2*i == 0){
            /*if(K-i*M == 0){
                cout << "Yes\n";
                return 0;
            }*/
            continue;
        }
        int j = (K-i*M)/(N-2*i);
        if(j*(N-2*i) == (K-i*M) && j > -1 && j < M+1){
            //cout << i << " " << j << endl;
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N; cin>>N;
  vector<ll>Z(N+1,0);
  for(int i=0; i<N-1; i++){
    ll A; cin>>A;
    Z[A]++;
  }
  for(int i=1; i<=N; i++){
    cout<<Z[i]<<endl;
  }
}

Measured memory_bytes: 4840
a,b,m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int,input().split())) for _ in range(m)]


yes_m = a[xyc[0][0]-1]+b[xyc[0][1]-1] - xyc[0][2]

for i in range(1,m):
    if yes_m > a[xyc[i][0]-1]+b[xyc[i][1]-1] - xyc[i][2]:
        yes_m = a[xyc[i][0]-1]+b[xyc[i][1]-1] - xyc[i][2]

no_m = min(a)+min(b)

print(min(no_m,yes_m))


Measured memory_bytes: 38568
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100000+7;
int n,c,k,t[maxn];
int main()
{
	scanf("%d%d%d",&n,&c,&k);
	--c;
	for(int i=1;i<=n;++i)
		scanf("%d",&t[i]);
	sort(t+1,t+n+1);
	int rest=c,ans=1,lastt=t[1];
	for(int i=2;i<=n;++i)
	{
		if(lastt+k>=t[i] && rest>0)--rest;
		else
		{
			rest=c;
			++ans;
			lastt=t[i];
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>

int main()
{
  char t[100000000];
  int len=0;
  
  scanf("%s",t);
  len=strlen(t);
  
  for(int i=0;i<len;i++)
  {
    if(t[i]=='?' && t[i-1]=='P'){
      t[i]='D';
    }else if(t[i]=='?'){
      t[i]='D';
    };
  };
  printf("%s",t);
  
  return 0;
};
      



Measured memory_bytes: 2348
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

bool isPrime(int n){
    for(int i = 2; i*i <=n ;i++){
        if(n % i == 0) return false;
    }
    return n != 1;
}

signed main(){
    int n;
    cin >> n;
    int ans = 0;
    rep(i, 0, n){
        int a;
        cin >> a;
        if(isPrime(a)) ans++;
    }
    cout << ans << endl;
}

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

const double PI = acos(-1);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

void solve_abc_c() {
	ll n, m;
	ll k;
	ll h, w;
	//ll x;
	//ll a;
	//string s;
	string s_ans;
	ll l_ans = 0;
	double d_ans = 0;

	cin >> n;

	mint ans;
	mint x1, x2, x3;
	x1 = 10;
	x2 = 9;
	x3 = 8;
	rep(i, n - 1) {
		x1 *= 10;
		x2 *= 9;
		x3 *= 8;
	}
	ans = x1 - (mint)2 * x2 + x3;

	cout << ans.x << "\n";
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(15);

	solve_abc_c();

	return 0;
}


Measured memory_bytes: 3656
line = gets.split(' ').map(&:to_i)

W = line[0]
H = line[1]
x = line[2]
y = line[3]
r = line[4]

if (x + r) > W || (x - r) < 0 || (y + r) > H || (y - r) < 0
  puts "No"
elsif
  puts "Yes"
end




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

int main()
{
	int64_t x;
	cin >> x;

	vector<int64_t> as(1000);
	for (int64_t i = 0; i < 1000; i++)
	{
		as[i] = (i * i * i * i * i);
	}

	for (int64_t i = 0; i < 1000; i++)
	{
		{
			auto itr = lower_bound(as.begin(), as.end(), as[i] - x);

			if (itr != as.end() && as[i] - *itr == x)
			{
				cout << i << ' ' << distance(as.begin(), itr) << endl;
				return 0;
			}
		}

		{
			auto itr = lower_bound(as.begin(), as.end(), x - as[i]);

			if (itr != as.end() && as[i] + *itr == x)
			{
				cout << i << ' ' << -distance(as.begin(), itr) << endl;
				return 0;
			}
		}
	}

	cout << "404" << endl;

	return 0;
}

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

using namespace std;

int main()
{
    int a[26];
    for(int i=0;i<26;i++)
    {
        a[i]=0;
    }
    int n,x=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        a[s[i]-'a']++;
    }
    for(int i=0;i<26;i++)
    {
        if(a[i]%2!=0)
        {
            x=1;
            break;
        }
    }
    if(x==1)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 256
S = input()
s = ['01', '10']
 
ans = 0
count = len(S)
i = 0
while count >= 2:
    if S[i:i + 2] in s:
        S = S[:i] + S[i + 2:]
        ans += 2
        count -= 1
        i -= 1
    else:
        i += 1
        count -= 1
 
print(ans)

Measured memory_bytes: 3428
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	a := readInt()
	b := readInt()
	fmt.Println(a * b)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

ll a[100010];
ll b[100010];
ll c[100010];

ll happy[100010][3];

int main(){
  int N;
  cin >> N;
  rep(i,N) cin >> a[i] >> b[i] >> c[i];

  rep(i,N+1)rep(j,3) happy[i][j] = 0;

  for(int i = 0; i < N; i++){
    chmax(happy[i+1][0], happy[i][1] + a[i]);
    chmax(happy[i+1][0], happy[i][2] + a[i]);
    chmax(happy[i+1][1], happy[i][0] + b[i]);
    chmax(happy[i+1][1], happy[i][2] + b[i]);
    chmax(happy[i+1][2], happy[i][0] + c[i]);
    chmax(happy[i+1][2], happy[i][1] + c[i]);
  }

  ll answer = max(max(happy[N][0], happy[N][1]), happy[N][2]);

  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 5120
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n, p, d1, d2;
	static int[][]info;
	static int[] distance, number;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
		while(read()){
			slove();
		}
	}
	static boolean read(){
		n = sc.nextInt();
		if(n == 0)
			return false;
		
		info = new int[n][3];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < 3; j++){
				info[i][j] = sc.nextInt();
			}
		}
		return true;
	}
	static void slove(){
		distance = new int[n];
		number = new int[n];
		for(int i = 0; i < n; i++){
			distance[i] = info[i][1] + info[i][2];
			number[i] = info[i][0];
		}
		//java.util.Arrays.sort(distance);
		int max = 0;
		int index = 0;
		for(int j = 0; j < n; j++){
			if(max < distance[j]){
				max = distance[j];
				index = number[j];
			}
		}
		System.out.print(index + " ");
		System.out.println(max);
	}
}

Measured memory_bytes: 16000
def main():
    n,h = map(int,input().split())
    a,b = [],[]
    for i in range(n):
        x,y = map(int,input().split())
        a.append(x)
        b.append(y)

    max_a = max(a)
    b.sort()
    b.reverse()

    now = 0
    ans = 0
    for i in range(n):
        now += max(b[i],max_a)
        ans += 1
        if now>=h:
            return ans

    rem = h-now
    ans += (rem+max_a-1)//max_a
    return ans

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1)res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}

struct Combination{
    vector<ll> fac,finv,inv;
    Combination(int mx){init(mx);}
    void init(int mx){
        fac.resize(mx+1);
        finv.resize(mx+1);
        inv.resize(mx+1);
        fac[0]=fac[1]=1;
        finv[0]=finv[1]=1;
        inv[1]=1;
        for(int i=2;i<=mx;i++){
            fac[i]=fac[i-1]*i%mod;
            inv[i]=mod-inv[mod%i]*(mod/i)%mod;
            finv[i]=finv[i-1]*inv[i]%mod;
        }
    }
    ll operator()(int n,int k){
        if(n<k)return 0;
        return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
    }
};

int main(){
    int k;
    cin>>k;
    string s;
    cin>>s;
    int n=s.size();
    ll ans=modpow(26,n+k);
    Combination comb(n+k);
    rep(i,n){
        ans-=comb(n+k,i)*modpow(25,n+k-i);
        ans%=mod;
    }
    ans=(ans+mod)%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 51112
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
#define endl             "\n"
// -----------------<Container manipulation / traversal macros>------------------
#define mp                 make_pair
#define pb                 push_back
#define ff                 first
#define ss                 second
#define sz(x)             ((int)((x).size()))
#define all(x)             (x).begin(),(x).end()
#define rep(i,n)         for(ll (i)=0;(i)<(n);(i)++)
#define forn(i,a,b)     for(ll (i)=(a);(i)<=(b);(i)++)
#define fill(l,a)        memset((l) , (a) , sizeof(l))
// -----------------<Some common useful functions>------------------
#define maX(a,b)        ( (a) > (b) ? (a) : (b))
#define miN(a,b)        ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)   ( (n >> b) & 1)
#define INDEX(arr,i)      ( lower_bound(all(arr),i)-arr.begin())
#define in(b,a)         ( (b).find(a) != (b).end())
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector< std::vector<ll> > matrix;
typedef map<ll,ll> mii;
typedef vector<pii> vpii;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}
ll lcm(ll a,ll b)
{
    return(a/gcd(a,b)*b);
}
/*ll power(ll a,ll b,ll p)
{
    ll res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}*/
/*ll b_search(ll arr[],ll n,ll s)
{
    ll l=0,r=n-1;
    while(l<=r)
    {
        ll mid=l+(r-l)/2;
        if(arr[mid]==s)
        return(mid);
        if(arr[mid]<s)
        l=mid+1;
        else
        r=mid-1;
    }
    return(-1);
}*/
void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll c1=c/b;
    ll c2=a/d;
    while(a>0 || c>0)
    {
        c=c-b;
        if(c<=0)
        {
            cout<<"Yes";
            return;
        }
        a-=d;
        if(a<=0)
        {
            cout<<"No";
            return;
        }
    }
}

int main()
{
    IOS
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);
}


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

int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a>k){
    cout << ":(" << endl;
  }
  else{
    cout << "Yay!" << endl;
  }
}

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

#define debug printf("fuck %d\n", __LINE__);

inline int read() {
	int res = 0, bo = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if (ch == '-') bo = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') { res = (res << 1) + (res << 3) + ch - '0'; ch = getchar(); }
	return bo * res;
}

template<typename T> void read(T &x) { x = read(); }
template<typename T, typename ...Argv> void read(T &a, Argv &...argv) { read(a); read(argv...); }

const int N = 2005;
struct Edge {
	int to;
	Edge *nxt;
	Edge(int to, Edge *nxt) : to(to), nxt(nxt) {}
} *head[N];
char s[N];
int f[N], g[N], siz[N];

void dfs(int x, int fa) {
	siz[x] = s[x] == '1'; int Max = 0; f[x] = 0;
	for (Edge *i = head[x]; i; i = i->nxt) {
		if (i->to == fa) continue;
		dfs(i->to, x);
		siz[x] += siz[i->to], g[i->to] += siz[i->to];
		g[x] += g[i->to]; 
		if (g[Max] <= g[i->to]) Max = i->to;
	}
	if (!Max) return; 
	if (g[Max] * 2 <= g[x]) f[x] = g[x] / 2;
	else f[x] = g[x] - g[Max] + std::min(f[Max], (2 * g[Max] - g[x]) / 2);
}

int main() {
	int n = read();
	scanf("%s", s + 1);
	for (int i = 1; i < n; ++ i) {
		int u = read(), v = read();
		head[u] = new Edge(v, head[u]);
		head[v] = new Edge(u, head[v]);
	}
	int ans = n * n;
	for (int i = 1; i <= n; ++ i) {
		for (int j = 1; j <= n; ++ j) f[j] = g[j] = siz[j] = 0;
		dfs(i, 0);
		if (f[i] * 2 >= g[i]) ans = std::min(ans, g[i] / 2);
	}
	std::cout << (ans == n * n ? -1 : ans) << std::endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2100,mod=1000000007;
int n,K;
int jc[N*N],njc[N*N],f[N][N];
int qpow(int x,int y)
{
	int ret=1;
	while(y)
	{
		if(y&1)ret=(ll)ret*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}
	return ret;
}
void init()
{
	jc[0]=njc[0]=1;
	for(int i=1;i<=n*K;i++)jc[i]=(ll)jc[i-1]*i%mod;
	njc[n*K]=qpow(jc[n*K],mod-2);
	for(int i=n*K-1;i>=1;i--)njc[i]=(ll)njc[i+1]*(i+1)%mod;
}
int C(int x,int y){return (ll)jc[x]*njc[y]%mod*njc[x-y]%mod;}
int main()
{
	//freopen("tt.in","r",stdin);
	scanf("%d%d",&n,&K);
	if(K==1)return puts("1"),0;
	init();
	f[0][0]=1;
	for(int i=0;i<=n;i++)
		for(int j=i;j<=n;j++)
		{
			if(i<j)(f[i+1][j]+=f[i][j])%=mod;
			if(j!=n)(f[i][j+1]+=(ll)f[i][j]*C((K-1)*(j+1)+i-1,K-2)%mod)%=mod;
		}
	printf("%d\n",(ll)f[n][n]*jc[n]%mod);
	return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define pi 3.14159265358979323846

using namespace std;

int main(){
	long long int a;	cin >> a;
	double b;	cin >> b;
	long long int ans;

	ans = (long long int)(b * 100 + 0.5);
	ans *= a;
	ans /= 100;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3704
def main(N,M):
    if N >= 3 and M >= 3:
        return (N-2)*(M-2)
    elif N <= 2 and M <= 2:
        return 0 if (N*M) % 2 == 0 else 1
    else:
        if min(N,M) == 1:
            return max(N,M)-2
        else:
            return 0
N,M = map(int,input().split())
print(main(N,M))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            int D = int.Parse(s[0]);
            int X = int.Parse(s[1]);

            int ans = 0;
            for(int i = 1; i <= N; i++)
            {
                int tmp = int.Parse(Console.ReadLine());
                if(D%tmp !=0)
                {
                    ans += (D / tmp) + 1;
                }
                else
                {
                    ans += D / tmp;
                }
                
            }
            Console.WriteLine(ans + X);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll n,m,k;
int main()
{
	cin >>n>>m;
	k=1;
	for (int i=1;;i++)
	{
		k*=m;
		if (n<k)
		{
			cout <<i;
			return 0;
		}
	}
	return 0;
} 

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
a=sorted(map(int,input().split()))
c=0
for i in range(n-1):
    if a[i]*2<a[i+1]:
        c=i+1
    a[i+1]+=a[i]
print(n-c)

Measured memory_bytes: 14320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	string S;
	cin >> S;
	int a = S.size();
	if(S[0] == 'k' && S[a-6] == 'e' && S[a-5] == 'y' && S[a-4] == 'e' && S[a-3] == 'n' && S[a-2] == 'c' && S[a-1] == 'e'){
		cout << "YES" << endl;
		return 0;
	}
	if(S[0] == 'k' && S[1] == 'e' && S[a-5] == 'y' && S[a-4] == 'e' && S[a-3] == 'n' && S[a-2] == 'c' && S[a-1] == 'e'){
		cout << "YES" << endl;
		return 0;
	}
	if(S[0] == 'k' && S[1] == 'e' && S[2] == 'y' && S[a-4] == 'e' && S[a-3] == 'n' && S[a-2] == 'c' && S[a-1] == 'e'){
		cout << "YES" << endl;
		return 0;
	}if(S[0] == 'k' && S[1] == 'e' && S[2] == 'y' && S[3] == 'e' && S[a-3] == 'n' && S[a-2] == 'c' && S[a-1] == 'e'){
		cout << "YES" << endl;
		return 0;
	}if(S[0] == 'k' && S[1] == 'e' && S[2] == 'y' && S[3] == 'e' && S[4] == 'n' && S[a-2] == 'c' && S[a-1] == 'e'){
		cout << "YES" << endl;
		return 0;
	}if(S[0] == 'k' && S[1] == 'e' && S[2] == 'y' && S[3] == 'e' && S[4] == 'n' && S[5] == 'c' && S[a-1] == 'e'){
		cout << "YES" << endl;
		return 0;
	}if(S[0] == 'k' && S[1] == 'e' && S[2] == 'y' && S[3] == 'e' && S[4] == 'n' && S[5] == 'c' && S[6] == 'e'){
		cout << "YES" << endl;
		return 0;
	}if(S[a-7] == 'k' && S[a-6] == 'e' && S[a-5] == 'y' && S[a-4] == 'e' && S[a-3] == 'n' && S[a-2] == 'c' && S[a-1] == 'e'){
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int isPrime(int);

int main()
{
  int a[10000];
  int n=0,i,j,x;

  scanf("%d",&x);
  for(i = 0;i < x;i++){
    scanf("%d",&a[i]);
  }

  for(i = 0;i < x;i++){
    if(isPrime(a[i]) == 1) n++;
  }

  printf("%d\n",n);

  return 0;
}

int isPrime(int x)
{
  int count=0,i=3;
  if(x == 2) return 1;
  else if(x < 2 || x % 2 == 0) return 0;

  else{
    while(i <= sqrt(x)){
      if(x % i == 0) return 0;
      i = i+2;
    }
  }
  return 1;
}



Measured memory_bytes: 2120
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

// 入力
int N;
long long item[110][2];

// DP テーブル
long long dp[110][100010];

int main() {
    int N, W; cin >> N >> W;
    for (int i = 0; i < N; ++i) {
        cin >> item[i][0] >> item[i][1];
    }

    // 初期化 (最大問題なので 0 に初期化)
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= W; ++j) {
            dp[i][j] = 0;
        }
    }

    // 初期条件
    for (int i = 0; i <= W;i++) {
        dp[0][i] = 0;
    }
    // ループ
    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0;sum_w < W + 1; ++sum_w) {
            if (sum_w - item[i][0] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - item[i][0]] + item[i][1]);
            }
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
    // 答え
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ? "Possible" : "Impossible") << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
INF = 10**18
sys.setrecursionlimit(10**6)
import math
D = 10 ** 9 + 7


# 組み合わせの総数 nCr
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

S = int(input())

max_length = S // 3

total = 0
for i in range(max_length):
    N = (S + i) - 3 * (i + 1)
    add = combinations_count(N, i)
    total += add
    total %= D

print(total)

Measured memory_bytes: 80256
def main():
    import sys
    input = sys.stdin.readline
 
    l, r = [int(i) for i in input().split()]
 
    if(r - l) >= 2019:
        print(0)
        exit()
    
    minmod = float('inf')
 
    for i in range(l, r):
        for j in range(i+1, r+1):
            temp = (i*j)%2019
            if(temp < minmod):
                minmod = temp
 
            #print("i = {}, j = {}, temp = {}, minmod = {}".format(i, j, temp, minmod))
 
    print(minmod)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 40048
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp; 
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

int main() {
    int N;
    int W[100];

    cin >> N;
    for (int i = 0; i < N; i++) cin >> W[i];

    int sumFrom0 = 0;
    int sumFromN = 0;
    for (int i = 0; i < N; ++i) sumFromN += W[i]; 
    
    int min = sumFromN - sumFrom0;
    for (int i = 0; i < N - 1; ++i) {
        sumFromN -= W[i];
        sumFrom0 += W[i];
        int diff = abs(sumFromN - sumFrom0);
        if (diff < min) min = diff;
    }

    cout << min;

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;

int main(){
	while(1){
		int i,j=0,k,n,r,a[51],b[51],p,c;
		for(i=0;i<51;i++){
			a[i]=i;
			b[i]=i;
		}
		cin>>n>>r;
		if(n==0&&r==0)break;
		//a[0]はつかわない
		for(i=0;i<r;i++){
			cin>>p>>c;
			for(j=p;j<p+c;j++){
				a[j-p+1]=b[j];
			}
			for(j=1;j<p;j++){
				a[c+j]=b[j];
			}
			for(j=0;j<=n;j++){
				b[j]=a[j];
			}
		}
		cout<<n+1-a[1]<<endl;
	}
    return 0;
}

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

int calc(map<pair<int, int>, int> &mp, int x, int y)
{
    return mp[{x, y}] + mp[{x-1, y-1}] + mp[{x-1, y}] + mp[{x, y-1}];
}

void solve()
{
    int n;
    cin >> n;
    int ans = -1;
    map<pair<int, int>, int> mp;
    vector<pair<int, int>> p;
    for (int i = 0; i < n; i++)
    {
        int x, y, num;
        cin >> x >> y >> num;
        mp[{x, y}] = num;
        p.push_back({x, y});
    } 
    for (int i=0;i<n;i++){
        int x=p[i].first;
        int y=p[i].second;
        ans=max(ans,calc(mp,x,y));
        ans=max(ans,calc(mp,x+1,y));
        ans=max(ans,calc(mp,x,y+1));
        ans=max(ans,calc(mp,x+1,y+1));
    }

    cout << ans << " / " << 1 << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 59784
#include<iostream>//第3题
#include<string>
#include<algorithm>
using namespace std;
int main()
{
 int num=0,a=0,b=10000;
 string s;
 cin >> s;
 for (int i = 0; i < s.length()-2; i++)
 {
  num = 0;
  a = 100;
  for (int j = 0; j < 3; j++)
  {
   num =num+ (s[i + j]-'0') * a;
   a = a /10;
  }
  b = min(abs(num - 753),b);
 }
 cout << b;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<ll,pair<ll,ll> > pp;
pp mm[100001];
ll d[100001];

int main(){
    ll n,h;
    ll ans=0;
    cin>>n>>h;
    ll di,hi,ch=h;
    for(int i=0;i<n-1;++i){
        cin>>di>>hi;
        mm[i].first=ch+hi<=h||ch<0 ? hi:h-ch;mm[i].second.first=i;mm[i].second.second=ch;
        d[i]=di;
        ch -= di;
    }
    int l=0;
    for(int i=0;i<n;++i){
        ch=mm[i].second.second;
        if(ch<=0){
            pp t=*max_element(mm+l,mm+i);
            hi=t.first;
            int ch2=t.second.second;
            i=t.second.first;l=i;
            int div;
            if(-ch/hi+1>(h-ch2)/hi){
                div=(h-ch2)/hi;
                ans+=div;
                ch=ch2+hi*div;
            } 
            else{
                div=-ch/hi+1;
                ans+=div;
                ch=min(h,ch2+hi*div); 
            }             
        }
        hi=mm[i].first;
        mm[i].first=ch+hi>h ? h-ch:hi;
        mm[i].second.second=ch; 
        mm[i+1].second.second= ch-d[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6224
n, k = map(int, input().split())

ans = 0
for b in reversed(range(1, n+1)):
    if b == k:
        break
    y_cnt = b-k
    p, q = divmod(n, b)
    ans += y_cnt*p
    if q == 0:
        continue
    if k <= q:
        ans += q-max(k-1, 0)
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define int long long
#define inf 1e9
#define mod 1000000007

void solve()
{
	int X;
	cin >> X;
	int amt = 100;
	int cnt = 0;
	while (amt < X)
	{
		amt += amt / 100;
		cnt++;
	}
	cout << cnt;
}

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
using namespace std;
  int N;
  int a[109];
  int same,cnt;
int main(){
  cin >> N;
  same=1;
  for(int i=0;i<N;i++){
      cin >> a[i];
      if(i!=0){
        if(a[i]==a[i-1]){
          if(i==N-1){
            same++;
            cnt+=same/2;
          }else{
            same++;
          }
        }else if(same>1){
          cnt+=same/2;
          same=1;
        }
      }
  }
  cout << cnt << "\n";
}

Measured memory_bytes: 256