akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (k == 0) return 1;
	return n * COM(n - 1, k - 1) / k;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin >> n >> k;
    cout << n-k+1 << endl;
    return 0;
}


Measured memory_bytes: 256
program prob5
    implicit none
    integer(16)::N, K, ans
    read(*,*) N, K
    ans = 0
    if(mod(K,2) == 0)then
        ans = ans + ((N+K/2)/K)**3 !それぞれが倍数/2
        ans = ans + (N/K)**3 !それぞれが倍数
    else
        ans = ans + (N/K)**3 !それぞれが倍数
    end if
    write(*,*) ans
    stop
end program

Measured memory_bytes: 2776
#include <stdio.h>
int main()
{
    int n,h,w,a,b,count=0;
    scanf("%d%d%d",&n,&h,&w);
    while(n--)
    {
        scanf("%d%d",&a,&b);
        if(h<=a && w<=b)
        count++;
    }
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 128
line = input().split(' ')
A = int(line[0])
B = int(line[1])
K = int(line[2])

if K < A:
  print(str(A - K) + ' ' + str(B))
else:
  if K - A < B:
    print(str(0) + ' ' + str(B - K + A))
  else:
    print(str(0) + ' ' + str(0))

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std;
 
int main(void) {
  int K, S, ans = 0;
  cin >> K >> S;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      if (S - x -y <= K && x + y <= S) {
        ans++;
      }
    }
  }
  
  
  cout << ans << endl;
}

Measured memory_bytes: 3544
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>

#define int int64_t

using namespace std;

signed main()
{
    int n;
    int ans = 0;
    
    cin >> n;
    
    vector<int> v;
    v.resize(n);
    
    for (int &x:v) {
        cin >> x;
    }
    
    for (int x : v) {
        int c;
        cin >> c;
        if (x - c > 0) {
            ans += x - c;
        }
    }
    
    cout << ans << endl;
    return 0;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define IO ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define ll long long int
const ll MOD=1e9+7;
using namespace std;
int main()
{
	IO;
	int n,sum=0;
	cin>>n;
	while(!n<5)
	{
		if(n>=500)
		{
			sum = sum + 1000;
			n-=500;
		}
		else if(n>=5)
		{
			sum=sum+5;
			n=n-5;
		}
		if(n<5)
		{
			break;
		}
	}
	cout<<sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 100000 + 5
#define Mod 1000000007

int n, ans = 1, A[N], T[N], Max[N];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++)
	{
		scanf("%d", A + i);
		Max[i] = max(Max[i - 1], 2 * (i - 1) - A[i - 1] >> 1);
		T[Max[i]] ++;
	}
	for (int i = 1; i <= Max[n]; i ++)
		T[i] += T[i - 1];
	for (int i = 0; i <= Max[n]; i ++)
		ans = 1LL * ans * (T[i] - i) % Mod;
	for (int i = 1; i < n - Max[n]; i ++)
		ans = 1LL * ans * i % Mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = sc.nextInt();
    if(a > x){
      System.out.println("NO");
    }else{
      if(x - a <= b){
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
    }
  }
}

Measured memory_bytes: 21588
a  = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

for i in b:
    for j in range(3):
        for k in range(3):
            if a[j][k] == i:
                a[j][k] = 0

a_2 = list(zip(*a))
flag_1 = sum(a[0]) == 0 or sum(a[1]) == 0 or sum(a[2]) == 0
flag_2 = sum(a_2[0]) == 0 or sum(a_2[1]) == 0 or sum(a_2[2]) == 0
flag_3 = a[0][0] + a[1][1] + a[2][2] == 0 or a[0][2] + a[1][1] + a[2][0] == 0

print(['No','Yes'][flag_1 or flag_2 or flag_3])

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;
int main(int argc, char const *argv[]){
    ll sum=0;
    string s;
    cin >> s;
    int n=s.size()-1;
    for(int bit=0;bit<(1<<n);bit++){
        ll now=0;
        for(int i=0;i<n+1;i++){
            now*=10;
            now+=(s[i]-'0');
            if(bit&(1<<i)){
                sum+=now;
                now=0;
            }
        }
        sum+=now;
    }
    cout << sum << endl;
    return 0;
}




Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main (){

    int N;
    vector<int> V = {0,0,0};

    cin >> V[0] >> V[1] >> V[2];

    sort(V.begin(),V.end());
    reverse(V.begin(),V.end());

    int S = (V[0]-V[1])+(V[0]-V[2]);

    if(S%2 == 0){
        cout << S/2 <<endl;
        return 0;
    }else{
        int D = S/2;
        cout << D+2 << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string S[999],a;
int P,M[999],O[999],c,C,n,m,i;
int main(){
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>S[i]>>O[i];
	}
	for(i=0;i<n;i++){
		P=0;
		while(P!=S[i].size()){
			cout<<"? "<<S[i]<<endl;
			cin>>a;
			C++;
			if(tolower(a[0])==tolower(S[i][P])){ 
				S[i][P]='_';P++;c++; 
			}
			else{
				M[i]++;
				if(M[i]>O[i]){
					m--;break;
				}
			}
		}
		if(m<=0){ 
			cout<<"! Game Over"<<endl;return 0; 
		}
	}
	cout<<fixed<<setprecision(1)<<"! Game Clear "<<(double)((int)(1000*c/C)/10.0)<<endl;
}

Measured memory_bytes: 1308
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

ll mod = 1000000007;

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

	int n, w;
	cin >> n >> w;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a)); //reverse(all(a));
	int sum = 0;
	rep(i, n) sum += a[i];
	if (sum <= w) {
		cout << 1 << endl;
		return 0;
	}
	int ans = 0;
	for (int x = 0; x < n; x++) {
		vector<vector<int>> dp(210, vector<int>(10010));
		dp[0][0] = 1;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= w; j++) {
				if (i >= x) dp[i + 1][j] += dp[i][j];
				if (j >= a[i] && i != x) {
					dp[i + 1][j] += dp[i][j - a[i]];
				}
				dp[i + 1][j] %= mod;
			}
		}
		for (int k = max(0LL, w - a[x] + 1); k <= w; k++) {
			ans += dp[n][k]; ans %= mod;
		}
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= w; j++) {
				//cout << dp[i][j] << ' ';
			}
			//cout << endl;
		}
		//cout << endl;
	}
	cout << ans << endl;
}



Measured memory_bytes: 19480
#include<bits/stdc++.h>
    using namespace std;
    #define vi vector<int>
    #define all(v) v.begin(), v.end()
    #define ll long long int
    #define ff first
    #define ss second
    #define pb push_back
    using namespace std;
    int main()
    {
       int i,j,k,n,m,d,cnt=0;
       cin>>n>>m>>d;
       for(i=n;i<=m;i++)
       {
           if(i%d==0){
               cnt++;
           }
       }
       cout<<cnt;
    }


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t;
    }
    return n*rep_jijo(n,x-1);
}

int main(){
    string t;
    cin >> t;
    string ans=t;
    int len = t.size();
    rep(i,len){
        if(t[i]=='?')t[i]='D';
    }
    cout << t << endl;
    
    return 0;
}

Measured memory_bytes: 3924
l[4],r[4],i;main(){float a,b;for(;~scanf("%f%f",&a,&b);l[a<0.2?3:a<0.6?2:a<1.1?1:0]++,r[b<0.2?3:b<0.6?2:b<1.1?1:0]++);for(;i<4;i++){printf("%d %d\n",l[i],r[i]);}exit(0);}

Measured memory_bytes: 624
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- // 


void solve(){
	
 int q = read.to!int;
	
 foreach(t; 0 .. q){
  long a = read.to!long;
  long b = read.to!long;
		
  if(a == b) (a * 2 - 2).writeln;
  else{
   long r = sqrt((a * b - 1).to!real).to!long;
   if(r * (r + 1) < a * b) (r * 2 - 1).writeln;
   else (r * 2 - 2).writeln;
  }
 }
	
}

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

using namespace std;
static const int NG = 0;
static const int OK = 1;
static const int UNKNOWN = 2;

class list
{
public:
	int power, motor, cable;
	list(int x, int y, int z)
	{
		power = x;
		motor = y;
		cable = z;
	}
};

void solve()
{
	int a, b, c, N;
	while(cin >> a >> b >> c, a || b || c)
	{
		cin >> N;
		vector<int> item(a + b + c + 1);
		for(int i = 0; i < item.size(); ++i)
		{
			item[i] = UNKNOWN;
		}
		vector<list> lists;
		for(int i = 0; i < N; ++i)
		{
			int d, e, f, g;
			cin >> d >> e >> f >> g;
			if(g == 1)
			{
				item[d] = OK;
				item[e] = OK;
				item[f] = OK;
			}
			else
			{
				lists.push_back(list(d, e, f));
			}
		}	
		for(int i = 0; i < lists.size(); ++i)
		{
			if(item[lists[i].power] == OK && item[lists[i].motor] == OK)
			{
				item[lists[i].cable] = NG;
			}

			if(item[lists[i].power] == OK && item[lists[i].cable] == OK)
			{
				item[lists[i].motor] = NG;
			}

			if(item[lists[i].cable] == OK && item[lists[i].motor] == OK)
			{
				item[lists[i].power] = NG;
			}
		}
		for(int i = 1; i < item.size(); ++i)
		{
			cout << item[i] << endl;
		}
	}
}

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

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

int main(){
    int N;
    cin >> N;
    string ans = "No";
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(N == i*j){
                ans = "Yes";
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
const ll  big =2e5+5;
pair <int,int> p[1005];
ll a[1005],b[1005];

int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
ll n,k;
cin>>n>>k;
ll a[1003];
for(int i=0;i<n;++i)
    cin>>a[i];
sort(a,a+n);
ll sum=0;
for(int i=0;i<k;++i)
    sum+=a[i];
cout<<sum;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <numeric>
#include <vector>
#include <map>
using namespace std;

const long long MOD=1000000007;

int main(){
  long long N; cin >> N;
  
  vector<long long> A(N,0),B(N,0);
  int zerocount=0;
  
  for(long long i=0; i<N; i++){
    long long a,b; cin >> a >> b;
    if(a==0&&b==0){
      zerocount++;
    }else if(a==0){
      b=1;
    }else{
      if(a<0){
        a=-a;
        b=-b;
      }
      long long d=gcd(a,b);
      a=a/d;
      b=b/d;
    }
    A[i]=a;
    B[i]=b;
  }
  
  map<pair<long long,long long>,pair<long long,long long>> m;
  for(long long i=0; i<N; i++){
    if(A[i]==0&&B[i]==0) continue;
    if(B[i]>0){
      pair<long long, long long> k=make_pair(A[i],B[i]);
      if(m.count(k)==1){
        m[k].first++;
      }else{
        m[k]=make_pair(1,0);
      }
    }else{
      pair<long long, long long> k=make_pair(-B[i],A[i]);
      if(m.count(k)==1){
        m[k].second++;
      }else{
        m[k]=make_pair(0,1);
      }
    }
  }
  
  long long result=1;
  for(auto k:m){
    long long x=k.second.first;
    long long y=k.second.second;
    
    long long xx=1;
    long long yy=1;
    for(long long i=0; i<x; i++) xx=(xx*2)%MOD;
    for(long long i=0; i<y; i++) yy=(yy*2)%MOD;
    
    result=(result*((xx+yy+MOD-1)%MOD))%MOD;
  }
  
  result=(result+MOD-1+zerocount)%MOD;
  cout << result << endl;
}

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

main(){

  int i,j;
  int C[37][2];
  int Bub[37][2];
  int Sel[37][2];
  int N;
  int tmpi;
  char tmpc;
  char str[3];
  int mini,isStable;

  scanf("%d",&N);

  for(i=1; i<=N;i++){
    scanf("%s",str);
    C[i][0] = Bub[i][0] = Sel[i][0] = atoi(&str[1]);
    C[i][1] = Bub[i][1] = Sel[i][1] = str[0];
  }

  // bubble
  for (i=1; i<=N; i++){

    for (j=N; j>=i+1; j--){

      if(Bub[j][0] < Bub[j-1][0]){
	
	tmpi = Bub[j][0];
	tmpc = Bub[j][1];
	Bub[j][0] = Bub[j-1][0];
	Bub[j][1] = Bub[j-1][1];
	Bub[j-1][0] = tmpi;
	Bub[j-1][1] = tmpc;

      }

    }

  }

  // selection
  for (i=1; i<=N; i++){
    mini = i;
    for (j=i; j<=N; j++){
      if(Sel[j][0] < Sel[mini][0]){
	mini = j;
      }
    }
    if(Sel[i][0] > Sel[mini][0]){
      
      tmpi = Sel[i][0];
      tmpc = Sel[i][1];
      Sel[i][0] = Sel[mini][0];
      Sel[i][1] = Sel[mini][1];
      Sel[mini][0] = tmpi;
      Sel[mini][1] = tmpc;
      
    }

  }

  isStable = 1;

  // DISPLAY
  for (i=1; i<=N; i++){
    printf("%c%d",Bub[i][1],Bub[i][0]);

    // SAME NUMBER
    if(isStable==1 && i>1 && Bub[i][0] == Bub[i-1][0]){
      for(j=1; j<=N; j++){
	if(C[j][0]==Bub[i][0] && C[j][1]==Bub[i][1]){
	  isStable = 0;
	  break;
	}
	if(C[j][0]==Bub[i-1][0] && C[j][1]==Bub[i-1][1]){
	  break;
	}
      }
    }

    if(i!=N){
      printf(" ");
    }
  }

  printf("\n");
  if(isStable==1){
    printf("Stable");
  }else{
    printf("Not stable");
  }
  printf("\n");

  isStable = 1;

  for (i=1; i<=N; i++){
    printf("%c%d",Sel[i][1],Sel[i][0]);

    // SAME NUMBER
    if(isStable==1 && i>1 && Sel[i][0] == Sel[i-1][0]){
      for(j=1; j<=N; j++){
	if(C[j][0]==Sel[i][0] && C[j][1]==Sel[i][1]){
	  isStable = 0;
	  break;
	}
	if(C[j][0]==Sel[i-1][0] && C[j][1]==Sel[i-1][1]){
	  break;
	}
      }
    }

    if(i!=N){
      printf(" ");
    }
  }

  printf("\n");
  if(isStable==1){
    printf("Stable");
  }else{
    printf("Not stable");
  }
  printf("\n");

  return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans;

    if(n%2==0){
        ll dp[(n/2)+1][2];
        dp[0][0]=dp[0][1]=0;
        rep(i,n/2){
            dp[i+1][0]=dp[i][0]+a[i*2];
            dp[i+1][1]=max(dp[i][0],dp[i][1])+a[2*i+1];
        }
        ans=max(dp[n/2][0],dp[n/2][1]);
    }
    else{
        ll dp[(n/2)+1][2][2];
        rep(i,2)rep(j,2) dp[0][i][j]=0;
        rep(i,n/2){
            dp[i+1][0][0]=dp[i][0][0]+a[i*2];
            dp[i+1][1][0]=max(dp[i][0][0],dp[i][1][0])+a[2*i+1];
            if(i!=0) dp[i+1][0][1]=max(dp[i][0][0],max(dp[i][0][1]+a[2*i],dp[i][1][0]));
            else dp[i+1][0][1]=0;
            //dp[i+1][1][1]=max(dp[i][1][1],dp[i][1][0])+a[2*i+1];
        }
        ans=max(max(dp[n/2][0][0],dp[n/2][1][0]),dp[n/2][0][1]+a[n-1]);
    }

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


Measured memory_bytes: 7996
#include<iostream>
#include<string>

using namespace std;

int main() {
	int ans = 0, n, ml, tl;
	string t, m;
	cin >> t >> n;
	tl = t.size();
	for (int i = 0; i < n; i++) {
		cin >> m;
		ml = m.size();
		m = m + m;
		for (int i = 0; i < ml; i++) {
			if (m.substr(i, tl) != t) continue;
			ans++;
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();

            for (int i = 0; i < 26; i++) {
                char tmp = (char) ('a' + i);
                if (!S.contains(String.valueOf(tmp))) {
                    out.print(String.valueOf(tmp));
                    return;
                }
            }
            out.print("None");
        }

    }
}



Measured memory_bytes: 23636
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =200100 , mod = 1000000007 ;
int n , a[N] , q , c = 1 ;
int dp[N] , idx[N];
vector < int > col[N];
int main ( ){
  scanf("%d",&n);
  int last = -1;
  for ( int i = 1; i <= n ; i++ ){
    int x;
    scanf("%d",&x);
    if ( x == last )continue;
    last = x;
    a[c] = x ;
    col[x].push_back(c);
    idx[c++] = col[x].size() - 1;
  }
  dp[c]=1;
  //cerr << c <<endl;
  for ( int i = c-1 ; i >= 1 ; --i ){

     dp[i] += dp[i+1]%mod;
     dp[i] %= mod ;
     if ( idx[i]+1 != col[a[i]].size()  ){
     dp[i] += dp[col[a[i]][idx[i]+1]]%mod;
     dp[i] %= mod;
     }
  }
  printf("%d\n",dp[1]);
 return 0 ;
}


Measured memory_bytes: 13568
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
        }
    }

    private void solve(InputReader in, PrintWriter out) {
        // MM 01 ~ 12
        String s = in.next();
        int pre = Integer.parseInt(s.substring(0, 2));
        int suf = Integer.parseInt(s.substring(2, 4));
        if ((pre == 0 || 12 < pre) && (1 <= suf && suf <= 12)) {
            out.println("YYMM");
        } else if ((suf == 0 || 12 < suf) && (1 <= pre && pre <= 12)) {
            out.println("MMYY");
        } else if ((suf < 1 || 12 < suf) && (pre < 1 || 12 < pre)) {
            out.println("NA");
        } else {
            out.println("AMBIGUOUS");
        }
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

    int nextInt() {
        return Integer.parseInt(this.sc.next());
    }

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());

    }

    @Override
    public void close() {
        this.sc.close();
    }
}


Measured memory_bytes: 21844
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

map<string,int>cnt;

 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n)
    {
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        cnt[s]++;
    }
    int ses=0;
    for(auto x:cnt)
    {
        ses+=((x.si*(x.si-1))/2);
    }
    cout<<ses<<endl;


















    return 0;

}














Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
#define FASTINPUT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) 
#define ll long long 
#define mp make_pair
#define pb push_back
#define Ma 1000000007

int main(){
  FASTINPUT;
  //#ifndef ONLINE_JUDGE
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  //#endif
   ll t;
   t=1;
   while(t>0)
   {
    string s;
    cin>>s;
    ll i,j,maxi=0,ans=0;
    for(i=0;i<s.length();i++)
    {
      ans=0;
      if(s[i]=='C'||s[i]=='G'||s[i]=='A'||s[i]=='T')
          ans++;
        else
          continue;
        maxi=max(ans,maxi);
      for(j=i+1;j<s.length();j++)
      {
        if(s[j]=='C'||s[j]=='G'||s[j]=='A'||s[j]=='T')
          ans++;
        else
          break;
      }
      maxi=max(ans,maxi);
    }
    cout<<maxi;

    t--;
   }
  
 return 0; 
    
}

           

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k;
  string L;
  cin >> L;
  ll N=L.size();
  ll dp[22][2]={};
  
  memset(dp, -1, sizeof(dp));
  
  dp[0][1]=0;
  for(i=0; i<N; i++) {
    if(dp[i][0]!=-1)
      chmax(dp[i+1][0], dp[i][0]+9);
    
    if(L[i]=='0') {
      chmax(dp[i+1][1], dp[i][1]+L[i]-'0');
    }else {
      chmax(dp[i+1][1], dp[i][1]+L[i]-'0');
      chmax(dp[i+1][0], dp[i][1]+L[i]-'0'-1);
    }
    
  }
  
  pt(max(dp[N][0], dp[N][1]));
}



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

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

    vector<long long int> divisor_num(N + 1, 2);
    divisor_num[1]--;

    for (long long int i = 2; i < N / 2 + 1; ++i) {
        long long int multiple = i + i;
        while (multiple <= N) {
            divisor_num[multiple]++;
            multiple += i;
        }
    }

    long long int ans = 0;
    for (long long int i = 1; i <= N; ++i) {
        ans += i * divisor_num[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 81388
#include <iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#include <limits>
#include <numeric>
#include <type_traits>
#include<stack>
#include<queue>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
const int INF =100000000;
typedef pair<int,int> P;


int retl(int K,int L){
    int tmp=0;
    while(pow(2,tmp) * L < K){
        tmp++;
    }
    return tmp;
}
int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
struct A{
    string s;
    int p;
    int order;
};

bool compare_by_b(pair<long, long> a, pair<long, long> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
bool dfs(long long sum,long long a[],int K,int N,int i){
    cout<<"sum="<<sum<<", i="<<i<<",a[i]="<<a[i]<<endl;
    if(sum==K){
        return true;
    }
    if(N==i){
        return false;
    }else{

    
    bool ret= dfs(sum+a[i],a,K,N,i+1) || dfs(sum,a,K,N,i+1);
    return ret;
    }
}
int dfs(int N){
    if(N==1){
        return 0;
    }
    if(N==3){
        return 1;
    }
    if(N%2==1){
        dfs(N/2);
        dfs(N/2 +1);
    }else{
        dfs(N/2);
        dfs(N/2);
    }
}

int main(){
    int N;
    cin>>N;
    double A[N];
    FOR(i,N){
        cin>>A[i];
    }
    double inA[N];
    FOR(i,N){
        inA[i]=1/A[i];
    }
    double sumb=0.0;
    FOR(i,N){
        sumb+=inA[i];
    }
    double ans=1/sumb;

    cout<<setprecision(16)<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
// i_m_arin

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef map<ll,ll> mpll;
typedef set<ll> stll;

#define f(i, a, n) 	for(ll i=a; i<(ll)n; i++)
#define f2(i, a, b) for(ll i=a; i<=(ll)b; i++)
#define pb 			push_back
#define ff 			first
#define ss 			second
#define pf			push_front
#define mp			make_pair
#define all(a)		(a).begin(),(a).end()
#define decimal(x)	fixed<<setprecision(x)
#define fsort(a)	sort(all(a))
#define rsort(a)	sort(all(a),greater<>())
#define fast_io		ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem0(a)		memset(a,0,sizeof(a))
#define mem1(a)		memset(a,-1,sizeof(a))
#define lcm(a,b)	(a*b)/__gcd(a,b)
#define ub(v,x)		upper_bound(all(v),x)-v.begin()
#define lb(v,x)		lower_bound(all(v),x)-v.begin()

const ld PI  = acos(-1);
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;
const ll SIZE= 100000;


void solve(){

string s;
cin>>s;
if(s[s.size()-1]=='s'){
	cout<<s<<"es"<<endl;
}
else{
	cout<<s<<"s"<<endl;
}

}


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

Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	vector<int> ind(n);
	iota(ind.begin(), ind.end(), 0);
	sort(ind.begin(), ind.end(), [&](int i, int j) {
		return a[i] < a[j];
	});
	for (auto t : ind) {
		cout << t + 1 << ' ';
	}
	cout << endl;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vi vec(N);
    for (ll i = 0; i < N - 1; i++) {
        int a;
        cin >> a;
        --a;
        ++vec[a];
    }
    prints.print_vec(vec, "\n");
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}


int main() {
  int k, x;
  cin >> k >> x;

  for (int i = (x - k) + 1; i <= (k + x) -1; ++i) {
    cout << i;
    if (i != k + x - 1) cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<map>
#include<cmath>
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
int N;

int calc(vector<int>& vec,int p)
{
  if(vec.size() < 4)
    return 0;

  //cout << "--- --- "<< endl;
  //for(int i=0;i<vec.size();i++)
  //cout << vec[i] << endl;

  stack<int> A,B;
  for(int i=0;i<=p;i++)
    A.push(vec[i]);
  for(int i=vec.size()-1;i>p;i--)
    B.push(vec[i]);
 
  bool update;
  while(true)
    {
      update = false;
    
      if(A.empty() && B.empty())
	break;
      //cout << A.top() << " A-B " << B.top() << endl;  
      if(!A.empty() && ! B.empty()  && A.top() == B.top())
	{	 
	  int c = A.empty()?B.top():A.top();
	  int cnt = 0;
	  while(!A.empty() && A.top() == c)
	    cnt++,A.pop();
	  while(!B.empty() && B.top() == c)
	    cnt++,B.pop();
	  if(cnt < 4)
	    {
	      //cout << p << " <> " << vec[p] <<  " = return " << A.size()+B.size()+cnt << endl;
	      return A.size() + B.size() + cnt;
	    }	 
	  update = true;
	 
	}
      else 
	{
	  stack<int> C,D;
	  int cnt = 0;
	  int c; 
	  bool pre = false,pre2 = false;
	 
	  if(!A.empty())
	    { 
	      c = A.top();
	      while(!A.empty() && A.top() == c)
		cnt++,C.push(A.top()),A.pop();
	      
	      if(cnt < 4)
		while(!C.empty())
		  A.push(C.top()),C.pop();
	      else 
		pre = true;
	    }	 
	  if(!B.empty())
	    {
	      cnt = 0,c = B.top();
	      while(!B.empty() && B.top() == c)
		cnt++,D.push(B.top()),B.pop();

	      if(cnt < 4)
		while(!D.empty())
		  B.push(D.top()),D.pop();
	      else 
		pre2 = true;
	    }

	  if(pre || pre2)
	    update = true;

	}
      if(!update)
	break;
    }
  //cout << p << " -> " << vec[p] <<  " = return " << A.size()+B.size() << endl;
  return A.size()+B.size();

}

int main()
{
  while(cin >> N,N)
    {
      vector<int> vec; 
      vec.resize(N); 
      for(int i=0;i<N;i++)
	cin >> vec[i];

      int ans = (1<<29);
      for(int i=0;i<N;i++)
	{
	  int pre_color = vec[i];
	  for(int j=1;j<=3;j++)
	    {
	      vec[i] = j;
	      ans = min(ans,calc(vec,i));
	    }
	  vec[i] = pre_color;
	}
	

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

Measured memory_bytes: 1312
import sys
from bisect import bisect_right,bisect_left
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N = I()
A,B = LI(),LI()

# 各桁の xor を考える

ans = 0
mod = 1 << 29
for i in range(29,0,-1):  # 2**(i-1) の位
    X = [a & (mod-1) for a in A]
    Y = [b & (mod-1) for b in B]
    X.sort()
    Y.sort(reverse=True)
    mod >>= 1
    r = 0
    i1,i2,i3 = 0,0,0
    for j in range(N):
        x = X[j]
        # [2**(i-1)-x,2*2**(i-1)-x),[3*2**(i-1)-x,4*2**(i-1)-x) にある Y の要素の個数を数え上げる
        # 尺取り法
        while i1 < N and Y[i1] >= mod-x:
            i1 += 1
        while i2 < N and Y[i2] >= 2*mod-x:
            i2 += 1
        while i3 < N and Y[i3] >= 3*mod-x:
            i3 += 1
        r += i1-i2+i3
    if r % 2 == 1:
        ans += mod

print(ans)


Measured memory_bytes: 182360
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <set>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;

ll n;

ll mod_pow(ll x, ll e) {
  ll res = 1;
  while(e) {
    if(e&1) res = res * x % MOD;
    x = x * x % MOD;
    e >>= 1;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  if(n == 1) {
    cout << a[0] * 2 % MOD;
    return 0;
  }

  sort(a.rbegin(), a.rend());
  ll coef = mod_pow(2, n - 1);
  ll c = mod_pow(2, n - 2);

  ll ans = 0, sum = coef;
  REP(i, n) {
    ans = (ans + a[i] * sum % MOD) % MOD;
    sum = (sum + c) % MOD;
  }

  cout << ans * mod_pow(2, n) % MOD;
  return 0;
}


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


int main(){
  int N,M,X,tot=0,m=INT_MAX;
  cin >> N >> M>>X;
  bool torf=true;
  
  vector<int> C(N);
  vector<vector<int>> A(N,vector<int>(M));
  vector<int> B(M,0);
  
  rep(i,N){
    cin >> C.at(i);
    rep(j,M){
      cin >> A.at(i).at(j);
    }
  }
  
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    fill(B.begin(),B.end(),0);
    
    bitset<12> s(tmp);
    //cout << s << endl;
    rep(i,N){
      if(s.test(i)){
        rep(j,M)
       		B.at(j)+=A.at(i).at(j); 
        tot+=C.at(i);
      }
    }
    
    rep(i,M){
      //cout << B.at(i)<< ' ';
      if(B.at(i)<X)
        torf=false;
    }
    //cout << endl;
    
    if(torf==true){//&& tot!=INT_MAX){
      
   /*   rep(i,M)
        cout << B.at(i) << ' ';
      cout << endl;*/
           
      m=min(tot,m);
      /*if(m!=INT_MAX)
        cout << m << endl;*/
      tot=0;
    }
    else{
      torf=true;
      tot=0;
    }
  }
  
  if(m!=INT_MAX)
  	cout << m << endl;
  else	
    cout << "-1" << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long LL;
const int MAX = 330;

int visit[MAX][MAX]={0};
LL Map1[MAX][MAX];
LL Map[MAX][MAX];
int N;

int main()
{
    cin>>N;
    for(int i = 1;i<=N;i++)
    for(int j = 1;j<=N;j++)
    {
        cin>>Map[i][j];
        Map1[i][j] = Map[i][j];
    }
    for(int k = 1;k<=N;k++)
        for(int i = 1;i<=N;i++)
            for(int j = 1;j<=N;j++){
                if(Map[i][j]>=Map[i][k]+Map[k][j]&&(i!=k&&j!=k)){
                    //cout<<i<<" "<<j<<" "<<k<<endl;
                    Map1[i][j] = Map[i][k]+Map[k][j];
                    visit[i][j] = 1;
                }
            }

    LL sum = 0;
    for(int i = 1;i<N;i++){
        for(int j = i+1;j<=N;j++)
        {
            if(Map[i][j]!=Map1[i][j]){
                 cout<<"-1"<<endl;
                 return 0;
            }
            if(Map[i][j]==Map1[i][j]&&visit[i][j]!=1)
                sum+=Map[i][j];

        }
    }
    if(sum==0)
        cout<<-1<<endl;
    else
        cout<<sum<<endl;


    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
const int MOD=1e9+7;
int main() {
  long long n,a[100005]={},b[100005]={},ans=1;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    b[a[i]]++;
    if(b[a[i]]>2) {
      cout << 0 << endl;
      return 0;
    }
    if(n%2==0&&b[0]>0) {
      cout << 0 << endl;
      return 0;
    }
  }
  if(n%2==1&&b[0]!=1) {
    cout << 0 << endl;
    return 0;
  }
  for(int i=0; i<n; i++) {
    if(b[i]!=0) {
      ans*=b[i];
      ans%=MOD;
    }
  }
  cout << ans << endl;
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  int n,asum=0,bsum=0;
  cin>>n;
  vector<int> a(n);
  r(i,n)cin>>a.at(i);
  sort(a.rbegin(),a.rend());

  r(i,n){
    if(i%2==1)asum+=a.at(i);
    else bsum+=a.at(i);
  }
  cout<<abs(asum-bsum)<<endl;

return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    ll t,i,j,n,a,b;
    string p,q,r;
    cin>>p>>q>>r;
    cout<<p[0]<<q[0]<<r[0]<<endl;

    return 0;
}





Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<string> vs;
typedef vector<Def> vi;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int main(){
	int n;
	map<char,bool>q;
	q['a']=1;
	q['i']=1;
	q['u']=1;
	q['e']=1;
	q['o']=1;
	while(cin>>n,n){
		vs in(n);
		rep(i,n)cin>>in[i];
		rep(i,n){
			string s="";
			s=in[i][0];
			rep(j,in[i].size()-1)if(q[in[i][j]])s+=in[i][j+1];
			in[i]=s;
		}
		rep(i,60){
			set<string>se;
			rep(j,n)se.insert(in[j].substr(0,i));
			if(se.size()==n){
				cout<<i<<endl;
				goto end;
			}
		}
		cout<<-1<<endl;
		end:;
	}
	
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string s; cin >> s;
    int n = s.length();
    int n1 = (n - 1) / 2;
    int n2 = (n + 1) / 2;

    string ans = "Yes";

    string ss1 = s.substr(0, n1);
    string ss2 = ss1;
    reverse(ss2.begin(), ss2.end());

    if (ss1 != ss2) ans = "No";

    string ss3 = s.substr(n2, n);
    string ss4 = ss3;
    reverse(ss4.begin(), ss4.end());

    if (ss3 != ss4) ans = "No";
    if (ss1 != ss3) ans = "No";

    cout << ans << endl;

    return 0;
}


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

int main(){
  int A, B, SUM;
  cin >> A >> B;
  SUM = A + B;
  if(SUM % 2 == 0){
    cout << SUM / 2 << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
//#pragma GCC optimize(2)
//南京市第三区OI委提醒您：
//代码千万条，-O2第一条。
//-O2不规范，超时两行泪。
// Happy TLE and WA every day!
// by: zxb
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define pb              push_back
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
#define read            ZXBs_fast_input
#define write           ZXBs_fast_output
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool write(int x){
	if(x >= 10) write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

int n;
string s;

long long dfs(int now, long long prev){
//	cout << now << " " << prev << endl;
	if(now == n) return prev;
	long long ans = 0;
	ans += dfs(now + 1, s[now] - '0') + prev * (1 << (n - now - 1));
	ans += dfs(now + 1, prev*10 + s[now] - '0');
//	cout << now << " ha " << ans <<endl; 
	return ans;
}

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> s;
	n = s.size();
	cout << dfs(1, s[0] - '0') << endl;
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int n,a[N];
ll cnt[N];
ll ans;

int main() {
	qr(n);
	for(int i=1;i<=n;i++) qr(a[i]),ans+=cnt[a[i]]++;
//	ans*=2;
	for(int i=1;i<=n;i++) pr2(ans-(cnt[a[i]]-1));	
	return 0;
}


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

using namespace std;
typedef long long ll;

int N;
ll a[100001];
ll d[100001];
ll sum;
ll sum_a;

int main() {
  cin >> N;

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

  for(int i = 1; i <= N; i++) {
    sum += i;
    d[i%N] = a[i%N] - a[i-1];
  }

  if(sum_a % sum != 0) {
    cout <<"NO"<<endl;
    return 0;
  }

  ll k = sum_a / sum;

  bool is = true;
  for(int i = 0; i < N; i++) {
    if(d[i] > k || (k-d[i]) % N != 0) {
      is = false;
      break;
    }
  }

  if(is) cout << "YES" <<endl;
  else cout << "NO" <<endl;
}
    


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

int main()
{
    long long int a,b,c,d,ans;
    cin>>a>>b>>c>>d;

    ans=max( max(a*c,a*d),max(b*c,b*d) );

    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 3632
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<ll> wacount(N, 0);
    vector<bool> okay(N, false);
    ll pena = 0;
    rep(i, M)
    {
        ll p;
        string s;
        cin >> p >> s;
        --p;
        if (s == "WA")
        {
            if (!okay[p])
            {
                ++wacount[p];
            }
        }
        else
        {
            if (!okay[p])
            {
                pena += wacount[p];
            }
            okay[p] = true;
            
        }
    }
    ll acnum = 0;
    rep(i, N)
    {
        acnum += okay[i] ? 1 : 0;
    }
    cout << acnum << " "<<pena << endl;
    return 0;
}

Measured memory_bytes: 3544
#include <string>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
    int n;
    cin>>n;
    char a[n],b[n];
   for(int i=0;i<n;i++)
       cin>>a[i];
    for(int i=0;i<n;i++)
       cin>>b[i];
    
    for(int j=0;j<n;j++)
    {
        cout<<a[j]<<b[j];
    }

    
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k;
    cin >> n >> k;

    for (int i = 1; i <= n; i++) {
    	if (i >= (n + i - 1 + k - 1) / k) {
    		cout << i << "\n";
    		return 0;
    	}
    }

    return 0;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define gc getchar
#define rint register int
#define rep(i,u,z) for(rint i=u;i<=z;++i)
#define reb(i,u,z) for(rint i=u;i>=z;--i)
#define inf 0x7fffffff

using namespace std;
typedef long long ll;

const int N=1e5+10;
int n,k,h[N];

inline int readint(){
	int rt=0,sign=1;
	char ch=gc();
	while(ch<'0'||ch>'9'){
		if(ch=='-')sign=-1;
	    ch=gc();
	}
	while(ch>='0'&&ch<='9'){
		rt=(rt<<3)+(rt<<1)+(ch&15);
		ch=gc();
	}
	return rt*sign;
}
int main(){
	n=readint(),k=readint();
	rep(i,1,n)h[i]=readint();
	sort(h+1,h+1+n);
	int minn=inf;
	rep(i,1,n-k+1){
		minn=min(minn,h[i+k-1]-h[i]);
	}
	printf("%d",minn);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
	int x;
	cin >> x;
	vector<int> arr;
	arr.push_back(1);
	for (int i = 2; i <= 32; i++) {
		int j = i*i;
		while (j <= 1000) {
			arr.push_back(j);
			j *= i;
		}
	}
	sort(arr.begin(), arr.end());
	unique(arr.begin(), arr.end());
	int ans = *(upper_bound(arr.begin(), arr.end(), x)-1);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
ans = 0
while a%2==0 and b %2== 0 and c %2== 0:
  if a == b == c:
    ans = -1
    break
  aa = (a/2)
  bb = (b/2)
  cc = (c/2)
  a = bb+cc
  b = aa+cc
  c = aa+bb
  ans += 1
  
print(ans)
  

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

int main() {
  int A, B, sum, K;
  cin >> A >> B;
  sum = 0;
  K = A;

  // ここにプログラムを追記
  for (int i = 0; i < B - A + 1; i++){
    int a, b, c, d, e;
    a = K / 10000;
    b = K % 10000 / 1000;
    c = K % 1000 / 100;
    d = K % 100 / 10;
    e = K % 10;    
    
    if (a == e && b == d) {
      sum++;
    }
    
    K++;
  }  

  cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = a + b;
    
    if(10 <= c){
      System.out.println("error");
    }else{
      System.out.println(c);
    }
  }
}
    

Measured memory_bytes: 23636