akhauriyash/Code-Regression huggingface dataset:
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    string a,b,c;
    cin>>a>>b>>c;
    cout<<a[0]<<b[0]<<c[0]<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3636
#include<stdio.h>

int main(){
  int i,x,y;
  int result = 0;
  
  if(scanf("%d %d", &x, &y) < 1){
    exit(1);
  }
  
  for(i = 0; i < 2; i++){
      if(x > y){
          result += x;
          x--;
      }else{
          result += y;
          y--;
      }
  }
  

  printf("%d", result);
  return 0;
}


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

using namespace std;

int main() {
    string S;
    cin >> S;
    int len = S.length();
    vector<int> candidates;
    for (int i = 3; i <= len; i++) {
        for (int bit = 0; bit < pow(3, i); bit++) {
            int n = bit;
            string s;
            for (int j = 0; j < i; j++) {
                switch (n % 3) {
                    case 0:
                        s += '3';
                        break;
                    case 1:
                        s += '5';
                        break;
                    case 2:
                        s += '7';
                        break;
                }
                n /= 3;
            }
            bool ok = s.find('3') != string::npos &&
                s.find('5') != string::npos &&
                s.find('7') != string::npos;
            if (ok) {
                candidates.push_back(stoi(s));
            }
        }
    }
    int N = stoi(S);
    int ans = 0;
    for (auto i : candidates) {
        if (i <= N) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b;
  cin>>a>>b;
  if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]){
    cout<<"YES\n";
  }else{
    cout<<"NO\n";
  }
}


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

int main() {
  int N, K;
  int sum = 1;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    if(sum < K){
      sum *= 2;
    }
    else{
      sum += K;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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;
}

ll M = 1000000007;

void solve()
{
	ll n;
	cin>>n;
	//char a='a';
	
	deque<char>ans;
	while(n>0){
		ll k=n%26;
		if(k==0){
			k=25;
		}else{
			k--;
		}
		char tmp='a'+k;
		ans.push_front(tmp);
		n-=k;
		n/=26;
	}
	rep(i,size(ans)){
		cout<<ans[i];
	}
	cout<<endl;

}

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


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

int main(){
    int N; ll K; 
    cin >> N >> K;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    vector<int> went_place;
    vector<int> ord(N+1, -1);
    int c = 1, l = 0;
    {
        int v = 1;
        while(ord[v] == -1){
            ord[v] = went_place.size();
            went_place.push_back(v);
            v = A[v-1];
        }
        c = went_place.size() - ord[v];
        l = ord[v];//例外サイズ
    }

    if(K < l) cout << went_place[K] << endl;
    else{
        K -= l;
        K %= c;
        cout << went_place[l+K] << endl;
    }
    
}

Measured memory_bytes: 5888
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		sc.close();

		int max = 0;
		int ans = 0;
		for (int i = 0; i < c.length; i++) {
			if (c[i] == 'A' || c[i] == 'C' || c[i] == 'G' || c[i] == 'T') {
				ans++;
				max = Math.max(max, ans);
			} else {
				ans = 0;
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 35408
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] ds = new int[N];

		for(int i=0; i<N; i++) {
			ds[i] = sc.nextInt();
		}Arrays.sort(ds);

		int kasane = 0;
		int top = 0;
		for(int j=0; j<N; j++) {
			if(top < ds[j]) {
				kasane += 1;
				top = ds[j];
			}
		}
		System.out.println(kasane);

	}

}


Measured memory_bytes: 23764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb push_back
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

const int mod = 1e9 + 7;

int n, m;
char S[200020];
ll res[200020];
ll D[200020], sum[200020];

int main() {
	scanf("%d%d", &n, &m);
	scanf("%s", S + 1);
	if(S[1] == 'B') {
		for(int i=1;i<=m;i++) S[i] = (S[i] == 'B' ? 'R' : 'B');
	}
	int all_r = 1;
	for(int i=1;i<=m;i++) if(S[i] != 'R') all_r = 0;
	if(all_r) {
		int dp[200020][2] = {};
		dp[1][0] = 1; dp[1][1] = 0;
		for(int i=2;i<=n;i++) {
			dp[i][0] = (dp[i-1][0] + dp[i-1][1]) % mod;
			dp[i][1] = dp[i-1][0];
		}
		int ans = (dp[n][0] + dp[n][1]) % mod;
		memset(dp, 0, sizeof dp);
		dp[1][0] = 0; dp[1][1] = 1;
		for(int i=2;i<=n;i++) {
			dp[i][0] = (dp[i-1][0] + dp[i-1][1]) % mod;
			dp[i][1] = dp[i-1][0];
		}
		ans = (ans + dp[n][0]) % mod;
		printf("%d\n", ans);
		return 0;
	}
	while(S[m] == 'R') --m;
	vector <int> v;
	for(int i=1, c=0;i<=m;i++) {
		if(S[i] == 'R') ++c;
		if(S[i] == 'R' && (i == m || S[i+1] == 'B')) {
			v.pb(c);
			c = 0;
		}
	}
	
	if(n % 2) {
		puts("0");
		return 0;
	}
	int lmn = n - 1;
	if(v[0] % 2) lmn = min(lmn, v[0]);
	else lmn = min(lmn, v[0] + 1);
	for(int i=1;i<szz(v);i++) {
		if(v[i] % 2) {
			lmn = min(lmn, v[i]);
		}
	}
	lmn = (lmn + 1) / 2;
	
	int sn = n / 2;
	
	D[0] = sum[0] = 1;
	for(int i=1;i<=sn;i++) {
		D[i] = (sum[i-1] - (i-lmn-1 < 0 ? 0 : sum[i-lmn-1]));
		if(D[i] < 0) D[i] += mod;
		sum[i] = (sum[i-1] + D[i]) % mod;
	}
	
	ll ans = 0;
	for(int i=1;i<=lmn;i++) {
		ans = (ans + (2 * i) * D[sn - i]) % mod;
	}
	printf("%lld\n", ans);
	
	return 0;
}


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

int main()
{
   long long int i,j,x;
   cin>>x;
   for(i=-2000;i<=2000;i++)
   {
       for(j=-2000;j<=2000;j++)
       {
           if(pow(i,5)-pow(j,5)==x)
           {
               cout<<i<<" "<<j<<endl;
               return 0;
           }
       }
   }
    return 0;
}


Measured memory_bytes: 4132
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=10000;
typedef struct P { int x,idx; } R;
bool operator<(const P &a,const P &b) { if(a.x!=b.x) return a.x<b.x; return a.idx<b.idx; }

int n;
int a[MAXN],b[MAXN];
P p[2*MAXN];
int pos[2*MAXN];
int lb[2*MAXN],ub[2*MAXN];

set<int> lft;
bool been[2*MAXN];
int comp[2*MAXN],ncomp;
int lst[2*MAXN],nlst;

int other(int id) { return id==-1?-1:id<n?id+n:id-n; }
int getedge(int at) {
	int l=lb[pos[at]],r=ub[pos[at]],a=pos[at],b=pos[other(at)];
	for(set<int>::iterator it=lft.lower_bound(l);it!=lft.end()&&*it<=r;++it) if(*it!=a&&*it!=b) return other(p[*it].idx);
	return -1;
}
int getredge(int at) {
	int l=lb[pos[other(at)]],r=ub[pos[other(at)]],a=pos[at],b=pos[other(at)];
	for(set<int>::iterator it=lft.lower_bound(l);it!=lft.end()&&*it<=r;++it) if(*it!=a&&*it!=b) return p[*it].idx;
	return -1;
}

void dfs1(int at,int dep=0) {
	been[at]=true; lft.erase(pos[other(at)]);
	//REP(i,dep) printf(" "); printf("dfs1(%d%c)\n",at%n+1,at<n?'A':'B');
	while(true) {
		int to=getedge(at);
		if(to==-1) break;
		dfs1(to,dep+1);
	}
	lst[nlst++]=at;
}
void dfs2(int at,int c,int dep=0) {
	comp[at]=c; lft.erase(pos[at]);
	//REP(i,dep) printf(" "); printf("dfs2(%d%c,%d)\n",at%n+1,at<n?'A':'B',c);
	while(true) {
		int to=getredge(at);
		if(to==-1) break;
		dfs2(to,c,dep+1);
	}
}

bool ok(int D) {
	REP(i,2*n) { int l=-1,h=2*n; while(l+1<h) { int m=l+(h-l)/2; if(p[m].x>p[i].x-D) h=m; else l=m; } lb[i]=h; } //p[?].x>p[i].x-D
	REP(i,2*n) { int l=-1,h=2*n; while(l+1<h) { int m=l+(h-l)/2; if(p[m].x<p[i].x+D) l=m; else h=m; } ub[i]=l; } //p[?].x<p[i].x+D
	//REP(i,2*n) printf("%d=%d (%d%c): %d..%d\n",i,p[i].x,p[i].idx%n+1,p[i].idx<n?'A':'B',lb[i],ub[i]);

	REP(i,2*n) been[i]=false,comp[i]=-1; nlst=ncomp=0;
	lft.clear(); REP(i,2*n) lft.insert(i);
	REP(i,2*n) if(!been[i]) dfs1(i);
	reverse(lst,lst+nlst);
	lft.clear(); REP(i,2*n) lft.insert(i);
	REP(i,2*n) if(comp[lst[i]]==-1) dfs2(lst[i],ncomp++);
	REP(i,n) if(comp[i]==comp[i+n]) return false;
	return true;
}

int solve() {
	REP(i,n) p[i].x=a[i],p[i].idx=i,p[i+n].x=b[i],p[i+n].idx=i+n; sort(p,p+2*n);
	REP(i,2*n) pos[p[i].idx]=i;

	//int tst=4; printf("ok(%d)=%d\n",tst,ok(tst)?1:0); exit(0);
	int l=0,h=1000000001;
	while(l+1<h) {
		int m=l+(h-l)/2;
		if(ok(m)) l=m; else h=m;
	}
	return l;
}

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d%d",&a[i],&b[i]);
	printf("%d\n",solve());
}

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


Measured memory_bytes: 2432
#include <iostream>
#include <vector>

using namespace std;

class CStrings
{
	vector<char> BefStr, AftStr, InpStr;
public:
	CStrings(){}
	
	void setGraph();
	void setInput();
	void restoration();

	void printStr();
};
void CStrings::setGraph()
{
	char buf;

	cin>>buf;
	BefStr.push_back(buf);
	cin>>buf;
	AftStr.push_back(buf);
}
void CStrings::setInput()
{
	char buf;

	cin>>buf;
	InpStr.push_back(buf);
}
void CStrings::restoration()
{
	for(unsigned int i = 0; i < InpStr.size(); i++){
		for(unsigned int j = 0; j < BefStr.size(); j++){
			if(InpStr[i] == BefStr[j]){
				InpStr[i] = AftStr[j];
				break;
			}
		}
	}
}
void CStrings::printStr()
{
	vector<char>::iterator it = InpStr.begin();
	while(it != InpStr.end()){
		cout<<*it;
		it++;
	}
	cout<<endl;
}

int main()
{
	int n, m;

	while(1){
		cin>>n;
		if(n == 0) return 0;

		CStrings cs;
		for(int i = 0; i < n; i++) cs.setGraph();

		cin>>m;
		for(int i = 0; i < m; i++) cs.setInput();

		cs.restoration();

		cs.printStr();
	}
}

Measured memory_bytes: 1120
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

int count(int n) {
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (n % i == 0) cnt++;
	}
	return cnt;
}

int main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i+=2) {
		if (count(i) == 8) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3616
S = input()
RL = []
ans = [0 for i in range(len(S))]
for i in range(len(S)-1):
    if S[i:i+2] == 'RL':
        RL.append(i)
        ans[i] += 1
        ans[i+1] += 1

for i in range(RL[0]):
    if S[i] == 'L':
        ans[0] += 1
    else:
        if (RL[0] - i)%2 == 1:
            ans[RL[0]+1] += 1
        else:
            ans[RL[0]] += 1

for i in range(len(RL)-1):
    for j in range(RL[i]+2,RL[i+1]):
        if S[j] == 'L':
            if (j-RL[i])%2 == 1:
                ans[RL[i]+1] += 1
            else:
                ans[RL[i]] += 1
        else:
            if (RL[i+1]-j)%2 == 1:
                ans[RL[i+1]+1] += 1
            else:
                ans[RL[i+1]] += 1

for i in range(RL[-1]+2,len(S)):
    if S[i] == 'R':
        ans[-1] += 1
    else:
        if (i-RL[-1])%2 == 1:
            ans[RL[-1]+1] += 1
        else:
            ans[RL[-1]] += 1
print(*ans)

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  vector<ll>num(n+10);
  vector<ll>num2(n+10);
  for(int i=1;i<=n;i++){
    cin>>num[i];
    if(num[i]>0)num2[i]+=num[i];
    num[i]+=num[i-1];
    num2[i]+=num2[i-1];
  }
  ll ans=0;
  if(n==1)ans=max(0LL,num[1]);
  for(int i=0;i<=n-k;i++){
    ans=max(ans,num2[i]+max(0LL,num[i+k]-num[i])+num2[n]-num2[i+k]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
NL=input().split()
N=int(NL[0])
L=int(NL[1])

S=[]
rank=[]
for i in range(N):
    S.append(input())
    rank.append(0)
temp=[]
for i in range(N):
    for j in range(N):
        if(S[i]<S[j]):
           temp.append(int(1))
        else:
            temp.append(int(0))        

for i in range(N*N):
    a=i%N
    rank[a]+=temp[i]
j=0
moji=""
for i in range(N):
    for j in range(N):
        if(i==rank[j]):
            moji=moji+S[j]
print(moji)

Measured memory_bytes: 3188
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException{
	BufferedReader br =
	    new BufferedReader(new InputStreamReader(System.in));

	String str = br.readLine();
	String[] str2 = str.split(" ",0);
	int num1 = Integer.parseInt(str2[0]);
	int num2 = Integer.parseInt(str2[1]);
	if (num1==num2) {
	    System.out.println("a == b");
	}
	else if(num1<num2){
	    System.out.println("a < b");
	}
	else{
	    System.out.println("a > b");

	}
       

    }
}

Measured memory_bytes: 24248
import sys
sys.setrecursionlimit(1000000)

def val_add(i,con,val):
    if con[i] :
        for j in con[i]:
            val[j]+=val[i]
            val_add(j,con,val)

def tree(i,con):
    if not con[i]: pass
    else :
        for j in con[i]:
            con[j].remove(i)
            tree(j,con)

def main():
    n,q=map(int,input().split())
    con=[[] for _ in range(n)]
    val=[0]*n
    for _ in range(n-1):
        a,b=map(int,input().split())
        con[a-1].append(b-1)
        con[b-1].append(a-1)

    tree(0,con)

    for _ in range(q):
        p,x=map(int,input().split())
        val[p-1]+=x

    val_add(0,con,val)


    print(" ".join(map(str,val)))

main()

Measured memory_bytes: 236260
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cstdint>
using namespace std;
static const long long MOD = 1000000007LL;
#define REP(i,n) for(int i = 0; i < (int)(n); i++)

int main(){
  char c;
  int mod = 1000000007;
  int d[13] = {1};
  while(cin >> c){
    int e[13] = {0};
    REP(i, 13){
      REP(j, 10) if(c == '?' || c == '0' + j){
        (e[(i * 10 + j) % 13] += d[i]) %= mod;
      }
    }
    REP(i, 13){
      d[i] = e[i];
    }
  }
  cout << d[5] << endl;
  return 0;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
n = N % 26
s = gets.chomp.split("").map(&:ord)

s.map! do |i|
  i += n
  i -= 26 if i >= 91
  i
end
ans = []
s.each do |i|
  ans << i.chr
end
an = ans.join("")
puts an


Measured memory_bytes: 2812
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        l: f64
    };

    let x = l / 3_f64;
    let res = x * x * x;
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2252
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy

H, W, K = map(int, input().split())
dump(H, W, K)
c = []
for i in range(H):
    c.append(input())
dump(c)
ans = 0
for rows, columns in it.product(it.product({True, False}, repeat=H), it.product({True, False}, repeat=W)):
    rIdx = {i for i, ri in enumerate(rows) if ri}
    cIdx = {j for j, cj in enumerate(columns) if cj}
    dump(rIdx, cIdx)
    cnt = 0
    for i in range(H):
        for j in range(W):
            if (i not in rIdx) and (j not in cIdx) and (c[i][j] == '#'):
                cnt += 1
    dump(cnt)
    if cnt == K:
        ans += 1
print(ans)


Measured memory_bytes: 9692
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n;
int main() {
	cin >> n;
	if (n >= 65 and n <= 90)cout << 1 << endl;
	else if (n >= 97 and n <= 122)cout << 2 << endl;
	else cout << 0 << endl;
}



Measured memory_bytes: 3100
n = int(input())
a = list(input().split())

for i in a:
    i = int(i)
    if i % 2 != 1:
        if (i % 3 == 0) or (i % 5 == 0):
            pass
        else:
            print("DENIED")
            exit(0)
print("APPROVED")

Measured memory_bytes: 2940
#include <stdio.h>

int main(void) {
	int n;
	scanf("%d",&n);
	int i,j,w[n],t=0,s,sa,f=99999;
	for(i=0;i<n;i++){
		scanf("%d",&w[i]);
		t+=w[i];
	}
	for(i=0;i<n;i++){
		s=0;
		for(j=0;j<=i;j++){
			s+=w[j];
		}
		
		sa=t-s;
		
		if(s<=sa){
			if(sa-s<f){
				f=sa-s;
			}
		}else{
			if(s-sa<f){f=s-sa;}
		}
	}
	
	
	printf("%d",f);
	// your code goes here
	return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    long long a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int q;
    cin>>q;
    while(q--)
    {
        int k;
        cin>>k;
        cout<<binary_search(a,a+n,k)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3872
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const in maxn= 2e5+99;
const in inf = 1e14;

int main()
{
    IOS;
    in a,b;
    cin >> a >> b;
    if (a*500 >= b) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n; cin >> n;
    map<string, ll> mp;
    bool ans = true;

    string word;
    string pre_word;

    rep(i, n){
        cin >> word;
        if(i > 0){
            // 末尾チェック
            if(word[0] != pre_word[pre_word.size()-1]) ans = false;
        }
        mp[word]++;
        if(mp[word] > 1) ans = false;
        pre_word = word;
    }

    (ans) ? Yes() : No();
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
my_dict = dict()
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
for item in a_list:
    if item in my_dict:
        my_dict[item] = my_dict[item] + 1
    else:
        my_dict[item] = 1

for i in range(m):
    b, c = map(int, input().split())
    if c in my_dict:
        my_dict[c] = my_dict[c] + b
    else:
        my_dict[c] = b

items_sorted = sorted(my_dict.items(), reverse=True)

ret = 0
rest = n

for item in items_sorted:
    if item[1] <= rest:
        ret = ret + item[0] * item[1]
        rest = rest - item[1]
    else:
        ret = ret + item[0] * rest
        break

print(ret)


Measured memory_bytes: 89752
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
const int N = 1e6 + 5;
typedef long long ll;
using namespace std; 

int n, m, d[N], p[N], f[N], Q; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

ll mabs(ll x) { return x < 0 ? -x : x; }

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> (), m = read <int> ();
	for(int i = 1; i <= n; i++) d[i] = read <int> ();
	p[0] = m;
	for(int i = 1; i <= n; i++)
	{
		if(d[i] < 2 * p[i - 1]) p[i] = mabs(p[i - 1] - d[i]);
		else p[i] = p[i - 1]; 
	}
	f[n + 1] = 1;
	for(int i = n; i >= 1; i--)
		f[i] = (d[i] < 2 * f[i + 1] ? (f[i + 1] + d[i]) : f[i + 1]);
	Q = read <int> ();
	for(int x, i = 1; i <= Q; i++)
	{
		x = read <int> ();
		if(f[x + 1] > p[x - 1]) puts("NO");
		else puts("YES"); 
	}
	return 0; 
}


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

int main(){
    int n; cin >> n;
    int number[n];

    for(int i=0;i<n;i++){
        cin >> number[i];
        cout << number[i];
        if(i<n-1)cout << " ";
        else cout << endl;
    }

    for(int i=1;i<n;i++){
        int sub = number[i];
        int j = i-1;

        while(j >= 0 && number[j]>sub){
            number[j+1]=number[j];
            j--;
        }

        number[j+1] = sub;

        for(int k=0;k<n;k++){
            cout << number[k];
            if(k<n-1)cout << " ";
            else cout << endl;
        }

    }


}


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


int main(){

  int x, y;
  cin >> x;
  cin >> y;

  int leg = 0;
  // i = # of crane
  for (int i=0; i!=(x+1); ++i){
    leg = 4*i + 2*(x-i);
    if(leg == y){
      cout << "Yes" << endl;
      return 0;
    } 
  }
  cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3580
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
using namespace std;

int a,b;

int main(){
  cin >> a >> b;
  if(a >=13) cout << b << endl;
  else if(a >= 6) cout << b/2 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }







void solve(){
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;

}




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


    solve(); 


    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", &s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define sz(x) x.size()
#define rep(n) for (int i = 0; i < n; i++)
#define repc(i, n) for (int i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
using namespace std;

// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<ii> vii;

template <typename T>
T modpow(T base, T exp, T modulus)
{
  base %= modulus;
  T result = 1;
  while (exp > 0)
  {
    if (exp & 1)
      result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

ll lcm(ll a, ll b) { return (a * (b / __gcd(a, b))); }

// Some contants
const ll inf = 1e12 + 7;
const double eps = 1e-9;
const long double pi = 1.00 * acos(-1.00);

int n, m;
const int MAXN = 2 * 1e5 + 7;
ll parent[MAXN];
vlli SSZ;

ll Find(ll x){
    ll tx, rx;
    tx = x;
    while (parent[tx] > 0)
        tx = parent[tx];
    // for path compression
    while (x != tx)
    {
        rx = parent[x];
        parent[x] = tx;
        x = rx;
    }

    return tx;
}

void Union(ll i, ll j)
{
    ll ti = Find(i), tj = Find(j);
    if (ti == tj)
        return;
    if (SSZ[ti] >= SSZ[tj])
    {
        parent[tj] = ti;
        SSZ[ti] += SSZ[tj];
    }
    else
    {
        parent[ti] = tj;
        SSZ[tj] += SSZ[ti];
    }
}

void solve()
{
    cin >> n >> m;
    SSZ.assign(n + 1, 1);
    clr(parent);
    // repc(i, n){
    //     parent[i+1] = i + 1;
    // }
    repc(i, m)
    {
        ll a, b;
        cin >> a >> b;
      
        Union(a, b);
      
    }
    ll ans = INT_MIN;
    FOR(i, 1, n + 1)
    {
        ans = max(ans, SSZ[i]);
    }

    cout << ans << endl;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    /*
    #ifndef ONLINE_JUDGE
        freopen("./input.txt", "r", stdin);
        freopen("./output.txt", "w", stdout);
    #endif

    */

    solve();

    return 0;
}


Measured memory_bytes: 6324
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

#define sz(x) (int)(x.size())
#define fr(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
/////////////////

int const N = 2e5 + 41;

int n;
vector<int> e[N];

int dfs(int u, int p){
	int r = 0;
	fr(i, 0, sz(e[u])){
		int to = e[u][i];
		if(to == p) continue;
		r ^= (dfs(to, u) + 1);
	}
	return r;
}

void solve(){
	cin >> n;
	fr(i, 0, n-1){
		int u, v;
		cin >> u >> v;
		--u;--v;
		e[u].pb(v);
		e[v].pb(u);
	}
	if(dfs(0, -1)) cout << "Alice";
	else cout << "Bob";
	cout << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()


int main() {
    int N;
    cin >> N;  
    vector<string> s(N);
    int ans = 0;
    int cntA,cntB,cntBA;
    cntA=0;
    cntB=0;
    cntBA=0;

    FOR(i,0,N){
        cin >> s[i];

        FOR(j,0,s[i].size()-1){
            if(s[i][j]=='A'&&s[i][j+1]=='B')ans++;
        }

        char start = s[i][0];
        char end = s[i][s[i].size()-1];
        if(start=='B'&&end=='A')cntBA++;
        else if(end=='A')cntA++;
        else if(start=='B')cntB++;

    }
    


    if(cntA|cntB){
        ans += cntBA+min(cntA,cntB);
    }else{
        ans += max(0,cntBA-1);
    }

    cout << ans << endl;

}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p(n), c(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    rep(i,n) cin >> c[i];
    ll ans = -1e18;
    rep(si,n){
        int x = si;
        vector<int> s;
        ll tot = 0;
        while(1){
            x = p[x];
            s.push_back(c[x]);
            tot += c[x];
            if(x == si) break;
        }
        int l = s.size();
        ll t = 0;
        rep(i,l){
            t += s[i];
            if(i+1 > k) break;
            ll now = t;
            if(tot > 0){
                ll e = (k-(i+1))/l;
                now += tot*e;
            }
            ans = max(ans, now);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int H, W, K;
    cin >> H >> W >> K;
    string c[H];
    for (int i = 0; i < H; i++) {
        cin >> c[i];
    }
    int ans = 0;
    for (int i = 0; i < (1<<H); i++) {
        for (int j = 0; j < (1<<W); j++) {
            int cnt = 0;
            for (int k = 0; k < H; k++) {
                if ((i & (1<<k)) != 0) continue;
                for (int l = 0; l < W; l++) {
                    if ((j & (1<<l)) != 0) continue;
                    if (c[k][l] == '#') cnt++;
                }
            }
            if (cnt == K) ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3496
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,rk;
	scanf("%d",&rk);
	a=rk/100;
	b=rk%100;
	if(a>0 && a<13 && b>0 && b<13) printf("AMBIGUOUS\n");
	else if(a==0 && b>12 || b==0 && a>12 || a>12 && b>12 || a==0 && b==0) printf("NA\n");
	else if(a>12 || a==0) printf("YYMM\n");
	else printf("MMYY\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a[3];
  int n;
  int i,j;
  int tmp;
  scanf("%d",&n);
  while(n>0){
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  for(i=0;i<3;i++){
    for(j=2;j>i;j--){
      if(a[j]<a[j-1]){
	tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
      }
    }
  }
  if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2])printf("YES\n");
  else printf("NO\n");
  n--;
  }
  return 0;
}

Measured memory_bytes: 580
using System;

class Code_01
{

    public static void Main()
    {
        string Datas = Console.ReadLine();
        int N = int.Parse(Datas.Split(' ')[0]);
        int K = int.Parse(Datas.Split(' ')[1]);
        int DIGIT = 0;
        while (true)
        {
           
          
            if (N >= K)
            {

                N /= K;
                DIGIT++;
            }
            else
            {
                DIGIT++;
                break;
            }
           
        }
        Console.WriteLine(DIGIT);

    }
}



Measured memory_bytes: 13140
lis1 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())

print(lis1[k])

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return ('0' <= c && c <= '9')?(c - '0'):-1;}

// TODO: write
int main() {
  string s;cin>>s;
  rep(i,s.size())cout<<'x';
  cout<<endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int M = sc.nextInt();

            char[] C = new char[N];
            Arrays.fill(C, '#');

            for (int i = 0; i < M; i++) {
                int s = sc.nextInt() - 1;
                char c = (char) (sc.nextInt() + '0');

                if (C[s] != '#' && C[s] != c) {
                    System.out.println(-1);
                    return;
                }

                C[s] = c;
            }

            if (C[0] == '0' && N > 1) {
                System.out.println(-1);
                return;
            }

            if (C[0] == '#' && N == 1) {
                System.out.println(0);
                return;
            }

            for (int i = 0; i < N; i++) {
                if (C[i] == '#') {
                    if (i == 0) {
                        C[i] = '1';
                    } else {
                        C[i] = '0';
                    }
                }
            }

            System.out.println(String.valueOf(C));
        }
    }

}


Measured memory_bytes: 22612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"-----------"<<endl;
#define ll long long
#define P pair<int,int>
#define mk make_pair
#define en endl
#define RE return 0
#define int ll

signed main(){
  int n;
  cin>>n;
  
  int ans=0;
  for(int j=19; j<=n; j++){
    int cnt=0;
    for(int i=1; i*i<=j; i++){
      if(i*i==j) continue;
      if(j%i==0) {
        cnt++;
      }
    }
    if(cnt==4&&j%2) {
      ans++;
    }
  }
  cout<<ans<<en;
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;

int main(){
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	if(abs(a-x)<abs(b-x)) printf("A\n");
	else printf("B\n");
	return 0;
} 

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [int(input()) for _ in range(N)]
B = [int(input()) for _ in range(M)]

votes = [0] * N
for x in B:
    for i, v in enumerate(A):
        if x - v > -1:
            votes[i] += 1
            break
print(votes.index(max(votes)) + 1)

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

double length(int x1, int y1, int x2, int y2)
{
    return sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
}

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> p(n);
    for (int i = 0; i < n; i++) { p[i] = i+1; }
    std::vector<int> x(n);
    std::vector<int> y(n);
    for (int i = 0; i < n; i++) { std::cin >> x[i] >> y[i]; }

    std::vector<double> len;
    do {
        // for (int i = 0; i < n; i++) { std::cout << p[i]; } std::cout << std::endl;
        double l = 0;
        for (int i = 1; i < n; i++) {
            int now = p[i]-1;
            int prev = p[i-1]-1;
            l += length(x[prev], y[prev], x[now], y[now]);
        }
        len.push_back(l);
    } while (std::next_permutation(p.begin(), p.end()));

    double ans = 0;
    for (size_t i = 0; i < len.size(); i++) {
        // std::cout << len[i] << std::endl;
        ans += len[i];
    }

    // std::cout << ans / len.size() << std::endl;
    printf("%.7f\n", ans / len.size());
    return 0;
}


Measured memory_bytes: 892
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                int N = sc.nextInt();
                int[] H = new int[N];
                for(int i = 0; i < N; i++) {
                        H[i] = sc.nextInt();
                } 
                int cnt = 0, max = 0, h = H[0];
                for(int i = 1; i < N; i++) {
                        if(h >= H[i]) cnt++;
                        else cnt = 0;
                        if(max < cnt) max = cnt;
                        h = H[i];
                } 
                sc.close();
                System.out.println(max);
        }
}


Measured memory_bytes: 50520
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  vd x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  double xl = -1, xr = 1001;
  double ans = 1e9;
  rep(i, 60) {
    vd xn = {(2 * xl + xr) / 3, (xl + 2 * xr) / 3};
    vd r(2, 0);
    rep(k, 2) {
      double yl = -1, yr = 1001;
      rep(j, 60) {
        double yll = (2 * yl + yr) / 3;
        double yrr = (yl + 2 * yr) / 3;
        double dl = 0, dr = 0;
        rep(i, n) {
          dl = max(dl, sqrt(pow(xn[k] - x[i], 2) + pow(yll - y[i], 2)));
          dr = max(dr, sqrt(pow(xn[k] - x[i], 2) + pow(yrr - y[i], 2)));
        }
        if(dl > dr)
          yl = yll;
        else
          yr = yrr;
      }
      rep(i, n) r[k] =
          max(r[k], sqrt(pow(xn[k] - x[i], 2) + pow(yl - y[i], 2)));
    }
    if(r[0] > r[1])
      xl = xn[0];
    else
      xr = xn[1];
    ans = min(ans, min(r[0], r[1]));
  }
  printf("%.18f\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,t;
  cin >> s >> t;
  char c;
  for(int i=0; i<s.size(); i++) {
    if(s == t) {
      cout << "Yes" << endl;
      return 0;
    }
    string t = s.substr(s.size()-1);
    s.insert(0,t);
    s.pop_back();
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
#define MAX 100005
#define NIL -1
   
typedef struct{ int p, l, r;}Node;
Node T[MAX];
int n, H[MAX], D[MAX],S[MAX];
int getD(int);
int getH(int);
int getS(int);
void print(int);
 
 
   
int main(){
  int i, j, d, v, c,l,r;
     
  scanf("%d",&n);
     
  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r = NIL;
  }
     
  for ( i = 0; i < n; i++ ){
    scanf("%d", &l);
    for(j = 0; j < 2; j++){
      scanf("%d", &v);
      if(v != -1){
	T[v].p = l;
	if(j == 0) T[l].l = v;
	else T[l].r = v;
      }
    }
  }
     
   
  for ( i = 0; i < n; i++ ){
    D[i] = getD(i);
    H[i] = getH(i);
    S[i] = getS(i);
  }
   
  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}
 
 
int getD(int u){
  if(T[u].p == NIL) return 0;
  return getD(T[u].p) + 1;
  
}

int getH(int u){
  int a = 0, b = 0;
  if(T[u].l != -1) a = getH(T[u].l) + 1;
  if(T[u].r != -1) b = getH(T[u].r) + 1;
  return a>b ? a : b;
}

int getS(int u){
  if(T[u].p == NIL)return NIL;
  else if(T[T[u].p].l != u && T[T[u].p].l != NIL)return T[T[u].p].l;
  else if(T[T[u].p].r != u && T[T[u].p].r != NIL)return T[T[u].p].r;
  else return NIL;
}

void print(int u){
  int deg=0;
  printf("node %d: parent = %d, sibling = %d, ",u,T[u].p,S[u]);
  if(T[u].l != NIL)deg++;
  if(T[u].r != NIL)deg++;
  printf("degree = %d, depth = %d, height = %d, ",deg,D[u],H[u]);
  if(T[u].p == NIL)printf("root\n");
  else if(T[u].l == NIL && T[u].r == NIL)printf("leaf\n");
  else printf("internal node\n");
}



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

int main() {
    int D;
    cin >>D;
    if(D==25)cout << "Christmas"<<endl;
    else if(D==24)cout << "Christmas Eve"<<endl;
    else if(D==23)cout << "Christmas Eve Eve"<<endl;
    else cout <<"Christmas Eve Eve Eve"<<endl;
}


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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int x=0;
    int ans = x;
    rep(i,s.size()){
        if(s[i]=='I'){
            x++;
        }
        else{
            x--;
        }
    ans=max(ans,x);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    
    vector<int> ans(n);
    for(int i=0;i<n;i++)ans[i]=0;
    
    for(int i=0;i<n;i++){
        while(v[i]%2==0){
            v[i]=v[i]/2;
            ans[i]++;
            }
        }
    
    sort(ans.begin(),ans.end());
    cout<<ans[0]<<endl;
    return 0;

    }



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

const int N = 110;
double a[N];

int main()
{
    //freopen("in.txt","r",stdin);
    int n, m;
    cin >> n >> m;
    double sum = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    double itm = sum / (4 * m);
    int cnt = 0;
    for(int i = 1; i <= n; i++) {
        if(a[i] >= itm) cnt++;
        if(cnt >= m) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256