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

int main(){
    string s; cin >> s;
    int sl=s.length();
    if(s[sl-1]=='s') s=s+"es";
    else s=s+"s";
    cout << s << endl;
    return 0;
}

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

vector<int> Z_Algorithm(string &s) {
    vector<int> ret(s.size());
    for (int i = 1, j = 0; i < s.size(); i++) {
        if (i + ret[i-j] < j + ret[j]) {
            ret[i] = ret[i-j];
        } else {
            int k = max(0, j + ret[j] - i);
            while (i+k < s.size() && s[k] == s[i+k]) k++;   
            ret[i] = k; j = i;
        }
    }
    ret[0] = s.size();
    return ret;
}

int main() {
    string s, t; cin >> s >> t;
    string r = t + s + s;
    while (r.size() < t.size() * 3) {
        r.append(s);
    }
    vector<int> z = Z_Algorithm(r);
    vector<int> next(s.size(), -1);
    vector<int> d(s.size(), -1);
    for (int i = 0; i < s.size(); i++) {
        if (z[t.size()+i] >= t.size()) {
            next[i] = (i + t.size()) % s.size();
        }
    }
    int ans = 0;
    for (int st = 0; st < s.size(); st++) {
        if (d[st] != -1) continue;
        stack<int> s({st});
        int plus = 0;
        while (next[s.top()] != -1) {
            if (next[s.top()] == st) {
                cout << -1 << endl;
                return 0;
            }
            if (d[s.top()] != -1) {
                plus = d[s.top()];
                break;
            }
            s.push(next[s.top()]);
        }
        while (!s.empty()) {
            d[s.top()] = plus++; 
            s.pop();
        }
    }
    for (auto x: d) {
        ans = max(ans, x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16948
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int N = 0;
    int result = 0;
    int x = 0;
    int y = 0;
    int z = 0;
    scanf("%d",&N);
    
    int A[N];

    for (int i = 0; i < N; i++) {
        scanf("%d",&A[i]);
    }
    
    //1 4 6 3
    
    for (int i = 0; i < N - 1; i++) {
        x = A[i];//1
        for (int j = i + 1; j < N; j++) {
            y = A[j];//4
            z = x - y;//マイナスが入る可能性　マイナスなら+に変換
            if (z < 0) {
                z = z * -1;
            }
            if (result < z) {
                result = z;
            }
        }
    }
    
    printf("%d",result);
    
    
    return 0;
}


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

#define DEBUG if(0)
#define SIZE 100001

int main(){
    int ret;

    int N;
    ret = scanf("%d", &N);

    int Q;
    ret = scanf("%d", &Q);
    
    char S[SIZE];
    ret = scanf("%s", S);

    int *l;
    int *r;
    l = (int*)malloc(sizeof(int)*SIZE);
    r = (int*)malloc(sizeof(int)*SIZE);

    for(int i=0; i<Q; i++){
        ret = scanf("%d", &l[i]);
        ret = scanf("%d", &r[i]);
    }

    DEBUG{
        printf("--------Original input--------\nN = %d, Q = %d\n", N, Q);
        printf("S:%s\n", S);
        printf("    i -> (    l,     r)\n_______________________\n");
        for(int i=0; i<Q; i++){
            printf("%5d -> (%5d, %5d)\n", i, l[i], r[i]);
        }
        printf("\n\n");
    }

    int *AC;
    int nAC = 0;

    AC = (int*)malloc(sizeof(int)*SIZE);
    AC[0] = 0;

    for(int i=1; i<N; i++){
        if(S[i-1]=='A' && S[i]=='C'){
            nAC++;
            AC[i] = nAC;
        }
        else{
            AC[i] = AC[i-1];
        }
        DEBUG{
            if(i==1) 
                printf("AC[%d] = %d\n", 0, AC[0]);
            printf("AC[%d] = %d\n", i, AC[i]);
        }
    }

    for(int i=0; i<Q; i++){
        int l_ = AC[ (l[i]-1) ];
        int r_ = AC[ (r[i]-1) ];
        int answer = r_ - l_;
        printf("%d\n", answer);
    }

 

    return 0;
}

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

using namespace std;

int main() {
    int N;

    cin >> N;

    int A[N];

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

    sort(A, A + N);

    for(int i = 0; i < N - 1; i++) {
        if(A[i] == A[i + 1]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 1024
n,m = map(int,input().split())
H = list(map(int,input().split()))
D=[]
for i in range(m):
    A,B = map(int,input().split())
    if H[A-1]<H[B-1]:
        D.append(A)
    elif H[A-1]==H[B-1]:
        D.append(A)
        D.append(B)
    else:
        D.append(B)
ans = list(set(list(range(1,n+1)))-set(D))
print(len(ans))

Measured memory_bytes: 112084
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>

using namespace std;

int main (void)
{
	for (int i = 1; i < 10; i++)
	{
		for (int j = 1; j < 10; j++)
		{
			cout << i << 'x' << j << '=' << i * j
 << endl;		}
	}
}

Measured memory_bytes: 2992
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N];

void solve() {
    ll n, w;
    cin >> n >> w;
    if (n > w) cout << "safe\n";
    else cout << "unsafe\n";
}

int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}// smf

Measured memory_bytes: 3608
N, K = map(int, input().split())
S = input()

left = 0
right = 0
op = 0
prev = '1'
ans = 0
while right < N:
    while right < N:
        if prev == '1' and S[right] == '0':
            op += 1
            if op > K:
                break
        prev = S[right]
        right += 1
    ans = max(ans, right - left)
    prev = S[left]
    while left < right:
        if prev == '0' and S[left] == '1':
            break
        prev = S[left]
        left += 1
    op -= 1
print(ans)

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

using namespace std;

#define MAX 101
#define INF LLONG_MAX/4
typedef long long ll;


int main(){
  int V,E,a,b;
  ll d[MAX][MAX],c;

  for(int i = 0 ; i < MAX ; i++){
    for(int j = 0 ; j < MAX ; j++){
      d[i][j] = INF;
    }
    d[i][i] = 0;
  }

  cin >> V >> E;
  for(int i = 0 ; i < E ; i++){
    cin >> a >> b >> c;
    d[a][b] = c;
  }


  for(int k = 0 ; k < V ; k++){
    for(int i = 0 ; i < V ; i++){
      for(int j = 0 ; j < V ; j++){
	if(d[i][k] != INF && d[k][j] != INF){
	  d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}
      }
    }
  }

  bool check = false;
  for(int i = 0 ; i < V ; i++){
    if(d[i][i] < 0){
      check = true;
      break;
    }
  }

  if(check){
    cout << "NEGATIVE CYCLE" << endl;
  }else{
    for(int i = 0 ; i < V ; i++){
      for(int j = 0 ; j < V ; j++){
	if(d[i][j] == INF){
	  cout << "INF";
	}else{
	  cout << d[i][j];
	} 

	if(j != V-1){
	  cout << " ";
	}
      }
      cout << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1244
#include <stdio.h>

int main(){
  int n,i;
  char s[105],t[105],m[205];
  scanf("%d",&n);
  scanf("%s",&s);
  scanf("%s",&t);
  for(i=0;i<n;i++){
    m[i*2]=s[i];
    m[i*2+1]=t[i];
  }
  m[i*2]=0;
  printf("%s",&m);
  return(0);
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
using namespace std;

int main() {
    float fraction = 0;
    int input;
    
    cin >> input;
    
    int numList[input];
    
    for(int i = 0; i < input; i++){
        cin >> numList[i];
    }
    
    for(int i = 0; i < input; i++){
        fraction += 1.0 / numList[i];
    }
    fraction = 1 / fraction;
    
    cout << fraction;
    
	return 0;
}


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

int main()
{

    int a, b;
    cin >> a >> b;
    if (a < b)
        for (int i = 0; i < b; i++)
            cout << a;
    else
        for (int i = 0; i < a; i++)
            cout << b;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define pb push_back
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define ld double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 998244353
#define bit(x) (1 << x)
#define par pair<int,int>
#define maxn 200005

using namespace std;
///All indexing is 0-based
using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

ll N,K,dist,A[maxn];

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> K >> N;

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

    for(int i=0;i<N;i++)
        dist = max(dist,(A[(i+1)%N]-A[i] + K) % K );

    cout << K-dist;




}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=55;
const int mod=1e9+7;
void add(int &a, int b)
{ a+=b;if(a>=mod) a-=mod;}
void sub(int &a, int b)
{ a-=b;if(a<0) a+=mod;}
void mul(int &a, int b)
{ a=(ll)a*b%mod;}
struct matrix
{
int a[N][N];
matrix()
{
for(int i=0;i<N;i++)
for(int j=0;j<N;j++)
a[i][j]=0;
}
};
matrix operator * (matrix a, matrix b)
{
matrix c;
for(int i=0;i<N;i++)
for(int j=0;j<N;j++)
for(int k=0;k<N;k++)
add(c.a[i][j],(ll)a.a[i][k]*b.a[k][j]%mod);
return c;
}
int main()
{
int n,u,v;ll k;
scanf("%i %lld",&n,&k);
matrix f=matrix();
for(int i=0;i<n;i++)
for(int j=0;j<n;j++) 
scanf("%i",&f.a[i][j]);
matrix ans=matrix();
for(int i=0;i<N;i++) ans.a[i][i]=1;
for(;k;k>>=1,f=f*f) if(k&1) ans=ans*f;
int sol=0;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
add(sol,ans.a[i][j]);
printf("%i",sol);
return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
//#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sort stable_sort
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for (register int (i)=(1);(i)<=(x);(i)++)
#define rep2(i,x) for (register int (i)=(x);(i)>=(1);(i)--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
using namespace std;
int n,i,j;
string ans;
vector<int> fr,fb,tmp;
string query(vector<int> q)
{
	cout<<'?';
	foreach(it,q) cout<<' '<<*it;
	cout<<endl<<flush;
	string st;cin>>st;
	return st;
}
int main()
{
	cin>>n;
	if(n==1){
		tmp.pb(1);
		if(query(tmp)=="Red") ans="RB"; else ans="BR";
		cout<<"! "<<ans<<endl<<flush;
		return 0;
	}
	ans="";
	rep(i,n){
		ans.push_back('?');
		ans.push_back('?');
		fr.pb(i);
		fb.pb(i+n);
	}
	if(query(fr)=="Blue") swap(fr,fb);
	int l=0,r=n+1,mid,ss=0;
	while(l<r){
		mid=(l+r)/2;
		tmp.clear();
		for(j=0;j<n-mid;j++) tmp.pb(fr[j]);
		for(j=0;j<mid;j++) tmp.pb(fb[j]);
		if(query(tmp)=="Blue"){
			r=mid;
		}
		else{
			l=ss=mid+1;
		}
	}
	tmp.clear();
	for(j=0;j<n-ss;j++) tmp.pb(fr[j]);
	for(j=0;j<ss;j++) tmp.pb(fb[j]);
	fb=tmp;ans[fb.back()-1]='B';
	rep(i,n+n)if(ans[i-1]=='?'){
		bool f=0;
		foreach(it,fb) if(*it==i){
			f=1;break;
		}
		if(!f){
			tmp=fb;
			tmp.pop_back();
			tmp.push_back(i);
			if(query(tmp)=="Blue") ans[i-1]='B'; else ans[i-1]='R';
		}
	}
	fr.clear();
	rep(i,n+n){
		if(fr.size()<n/2&&ans[i-1]=='B') fr.push_back(i);
	}
	rep(i,n+n){
		if(fr.size()<n&&ans[i-1]=='R') fr.push_back(i);
	}
	rep(i,n+n)if(ans[i-1]=='?'){
		bool f=0;
		foreach(it,fr) if(*it==i){
			f=1;break;
		}
		if(!f){
			tmp=fr;
			tmp.pop_back();
			tmp.push_back(i);
			if(query(tmp)=="Blue") ans[i-1]='B'; else ans[i-1]='R';
		}
	}
	cout<<"! "<<ans<<endl<<flush;
	return 0;
}

Measured memory_bytes: 724
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 200005

int N;
int A[SIZE];

int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){

		scanf("%d",&A[i]);
	}

	int num_destroy = 0,next = 1;

	for(int i = 0; i < N; i++){
		if(A[i] != next){
			num_destroy++;
			continue;
		}

		next++;
	}

	if(num_destroy == N){

		printf("-1\n");

	}else{

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

	return 0;
}


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

int main(){
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  int sum, ans_1=a*100, ans_2=0;
  double con, maxCon;
  for ( int i = 0; i <= 30; i++){
    sum = a*i*100;
    if ( sum > f)continue;
    for ( int j = 0; j <= 30; j++){
      sum = a*i*100 + b*j*100;
      if ( sum > f)continue;
      for ( int k = 0; k <= f/c + 1; k++){
        sum = a*i*100 + b*j*100 + c*k;
        if ( sum > f)continue;
        for ( int l = 0; l <= f/d + 1; l++){
          sum = a*i*100 + b*j*100 + c*k + d*l;
          con = (double)(c*k + d*l) * 100 /(a*i*100 + b*j*100);
          if ( sum > f || con > e)continue;
          if ( con > maxCon){
            maxCon = con;
            ans_1 = sum;
            ans_2 = c*k + d*l;
          }
        }
      }
    }
  }

  cout << ans_1 << " " << ans_2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;

int32_t main()
{
	IOS;
	string s;
	cin>>s;
	int p=0;
	int q1;
	cin>>q1;
	deque<char>q;
	for(int i=0;i<s.size();i++)
	{
		q.push_back(s[i]);
	}
	for(int i=1;i<=q1;i++)
	{
		int t;
		cin>>t;
		if(t==1)
		{
			p^=1;
		}
		else if(t==2)
		{
			int f;
			cin>>f;
			char c;
			cin>>c;
			if(f==1)
			{	
				if(p==0)
				{
					q.push_front(c);
				}
				else
				{
					q.push_back(c);
				}
			}
			else
			{
				if(p==1)
				{
					q.push_front(c);
				}
				else
				{
					q.push_back(c);
				}
			}
		}
	}
	if(p==0)
	{
		while(!q.empty())
		{
			cout<<q.front();
			q.pop_front();
		}
		cout<<endl;
	}
	else
	{
		while(!q.empty())
		{
			cout<<q.back();
			q.pop_back();
		}
		cout<<endl;
	}







}


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

int N;
char S[200000][12];
int n[200000];

int cmpfunc( const void *a, const void *b )
{
    return( strcmp( (char *)a, (char *)b ) );
}

int main( int argc, char *argv[] )
{
    int i;
    int max = 0;

    if( scanf( "%d", &N ) != 1 ) {
        printf( "N read error!\n" );
        exit( -1 );
    }

    for( i=0; i<N; i++ ) {
        n[i] = 0;
        if( scanf( "%10s", (char *) &S[i] ) != 1 ) {
            printf( "N read error!\n" );
            exit( -1 );
        }
    }

    qsort( S, N, sizeof(S[0]), strcmp );

    int start = 0;
    int end = start +1;

    while( end < N ) {

        while( !strcmp( S[start], S[end] ) ) end++;

        n[start] = end - start;

        if( n[start] > max ) max = n[start];

        start = end;
    }

//    for( i=0; i<N; i++ )
//        printf( "[%s] %d\n", S[i], n[i] );

    for( i=0; i<N; i++ )
        if( n[i] == max )
            puts( S[i] );
//            printf( "%s\n", S[i] );
}


Measured memory_bytes: 5628
#include <iostream>

using namespace std;

int w,h;
int dx[8] = { -1 , -1 , -1 ,  0 , 0 ,  1 , 1 , 1};
int dy[8] = { -1 ,  0 ,  1 , -1 , 1 , -1 , 0 , 1};
int map[51][51];

void check(int x , int y){
	int mx,my;

	for(int i=0 ; i<8 ; i++){//üÍWûüð²×é
		mx = x + dx[i];
		my = y + dy[i];

		//tB[hOÉoÄ¢È¯êÎ²×é(0ÈãE³Èà)
		if(mx>=0 && mx<w && my>=0 && my<h){
			if(map[my][mx]==1){//¾Á½ç
				map[my][mx] = 2;//ñdÉ²×È¢½ßÉÊÌlðüêé
				check( mx , my );
			}
		}
	}
}

int main(){
	int count;//ÌðJEg·éÏ

	while(1){
		//ÏÌú»
		count = 0;
		
		//E³ÌüÍ
		cin >> w >> h;
		if(w==0 && h==0) break;//0 0ªüÍ³ê½çI¹

		//tB[hª©C©ÌîñðüÍ
		for(int y=0 ; y<h ; y++){
			for(int x=0 ; x<w ; x++){
				cin >> map[y][x];
			}
		}

		for(int y=0 ; y<h ; y++){
			for(int x=0 ; x<w ; x++){
				if(map[y][x]==1){//¾Á½çÄAÖðÄÑo·
					map[y][x] = 2;
					count++;
					check( x , y );
				}
			}
		}

		//¦ÌoÍ
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 0
N, M = map(int, input().split())
guess = [-1] * N

for i in range(M):
  s, c = map(int, input().split())
  s = s - 1
  if s == 0 and c == 0 and N>1:
    print(-1)
    exit()
  if guess[s] == -1:
    guess[s] = c
  elif guess[s] == c:
    continue
  else:
    print(-1)
    exit()

if len(guess) > 1 and guess[0] == -1:
  guess[0] = 1
for i in range(len(guess)):
  if guess[i] == -1:
    guess[i] = 0
    
res = map(str, guess)
print(''.join(res))

Measured memory_bytes: 3064
#include <iostream>

namespace ABC179
{

  class C
  {
  public:
    C() = default;
    ~C() = default;


    void Run()
    {
      int N = {};
      std::cin >> N;

      int sum = 0;
      for (int AB = 1; AB < N; ++AB)
      {
        int yakusu_count = 0;
        int j2 = 1;
        for (int j = 1; j2<=AB;)
        {
          if (AB%j == 0) {
            yakusu_count++;
            if(j2!=AB) yakusu_count++;
          }          
          ++j;
          j2 = j*j;
        }

        sum += yakusu_count;
      }

      std::cout << sum << std::endl;
    }
  };

}


int main()
{

  ABC179::C prob;
  prob.Run();

  return 0;
}



Measured memory_bytes: 3188
#include<cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include<cmath>
#include<string.h>

using namespace std;

int main(){
	int n,r;
	scanf("%d %d",&n,&r);
	if(n>10)printf("%d\n",r);
	else printf("%d\n",r+100*(10-n));
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define REP(i, s, n) for (int i = s; i< (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
ll inf = ll(1e18);
using ll1d = vector<ll>;
using ll2d = vector<ll1d>;
using ll3d = vector<ll2d>;

ll f(ll b, ll n) {
  if (n < b) return n;
  else return f(b, static_cast<ll>(floor(double(n) / b))) + n % b;
}

void solve(istream &ccin = cin, ostream &ccout = cout) {
  ll n, s;
  ccin >> n;
  ccin >> s;

  double nn = sqrt(n);
  ll b = -1;
  if (n == s) {
    b = n + 1;
  } else if (s < n) {
    ll nnn = ceil(nn) + 1;
    REP(ib, 2, nnn) {
      if (f(ib, n) == s) {
        b = ib;
        break;
      }
    }
    if (b == -1) {
      b = inf;
      REP(a, 1, nnn) {
        if ((n - s) % a == 0 and f((n - s) / a + 1, n) == s) b = min(b, (n - s) / a + 1);
      }

      if (b == inf) b = -1;

    }

  }

  ccout << b << endl;

}

int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 256
def min(a,b); a < b ? a : b; end
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
B << 0

total = 0
(0 .. N).inject(0) do |rest,i|
  a = A[i]
  b = B[i]
  
  x = min(a, rest)
  y = min(b, a - x)
  total += (x + y)
  b - y
end

puts total


Measured memory_bytes: 15500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = Input.NextInt();
            long taka = Input.NextLong();
            long aoki = Input.NextLong();
            double rate = (double)taka / aoki;

            for (int i = 1; i < N; i++) {
                long ttmp = Input.NextLong();
                long atmp = Input.NextLong();
                double ratetmp = (double)ttmp / atmp;

                // takahashiを中心に上昇
                if(rate < ratetmp) {
                    // aokiの設定
                    aoki = ((aoki - 1) / atmp + 1) * atmp;
                    // takahashiの設定
                    taka = (aoki / atmp) * ttmp;
                }

                // aokiを中心に上昇
                if(rate > ratetmp) {
                    taka = ((taka - 1) / ttmp + 1) * ttmp;
                    aoki = (taka / ttmp) * atmp;
                }

                rate = ratetmp;
            }

            Console.WriteLine(taka + aoki);
        }
    }

    class Input {
        static IEnumerator<string> enumerator;

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
n = int(input())
a = list(map(int,input().split()))
left = 0
num = 1
start = 0
while True:
    Flag = True
    for i in range(start,n):
        if a[i] == num:
            left += 1
            start = i
            Flag = False
            num += 1
            break
    if Flag:
        break
if left == 0:
    ans = -1
else:
    ans = n - left
print(ans)

Measured memory_bytes: 25716
n = int(input())
Ss = []
for i in range(n):
    s = input()
    Ss.append(s)

ssdict = {}
for i in range(n):
    if Ss[i] in ssdict:
        ssdict[Ss[i]] += 1
    else:
        ssdict[Ss[i]] = 0

cnt = 0
ans = []
for key in ssdict:
    if ssdict[key] > cnt:
        ans = []
        ans.append(key)
        cnt = ssdict[key]
    elif ssdict[key] == cnt:
        ans.append(key)
    else:
        continue

srt = sorted(ans)
for value in srt:
    print(value)

Measured memory_bytes: 35220
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define Mod 1000000007
#define limit 1000008
using namespace std;

void solve(int t)
{
    int i,j,n,m,d,tt,s;
    cin >> d >> tt >> s;
    if(d>s*tt)
    {
        cout <<"No\n";
    }
    else
        cout <<"Yes\n";
    return ;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int t,tt=1;
   // cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
  return 0;
}




Measured memory_bytes: 3552
require 'prime'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end



n,a = gi
num = gi
dp = darray(n+1,2501,0)
dp[0][0] = 1
max = 0
rep n do |k|
	ct = num[k]
	repl max,0,-1 do |j|
		rep n do |i|
			if dp[i][j] != 0
				dp[i+1][j+ct] += dp[i][j]
				if max < j+ct
					max = j+ct
				end
			end
		end
	end
end
sum = 0
repl 1, n do |i|
	sum += dp[i][i*a]
end

puts sum



Measured memory_bytes: 2940
N = int(input())
S = list(input())

left = S[:0].count('#')
right = S[0:].count('.')
cou = left+right

for i in range(1,N+1):
    if S[i-1]=='#':
        left+=1
    else:
        right-=1
    cou = min(cou,left+right)
print(cou)

Measured memory_bytes: 6308
N,L =map(int,input().split())
inoazi=0
azi=0
min=100000
bag=[]
for i in range(1,N+1):
    azi+=L+i-1

for j in range(1,N+1):
    tab=azi-(L+j-1)
    if (min>abs(azi-tab)):
        min=abs(azi-tab)
        bag.append(j)
        
m=max(bag)
kotae=azi-(L+m-1)
print(kotae)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int a,b;
  int num=0;
  for(int i=0;i<N;i++){
    cin>>a>>b;
    num=num+b-a+1;
  }  
  cout<<num<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
void prin(const int time){
	int hour=time/3600; int min=(time-3600*hour)/60; int sec=time%60;
	char h[2],m[2],s[2];
	h[0]='0'+hour/10; h[1]='0'+hour%10;
	m[0]='0'+min/10; m[1]='0'+min%10;
	s[0]='0'+sec/10; s[1]='0'+sec%10;
	cout<<h[0]<<h[1]<<':'<<m[0]<<m[1]<<':'<<s[0]<<s[1]<<'\n';
}
int main(){
	while(1){
	int hour,min,sec,time;
	cin >> hour >> min >> sec ;
	if(hour==-1 && min==-1 && sec==-1) break;
	time=3600*hour+60*min+sec;
	time=7200-time;
	prin(time);
	prin(time*3);
	};
}

Measured memory_bytes: 1120
N = int(input())
s = input()
s += s[0]

# S: 1, W: 0
for a0, a1 in ((0, 0), (0, 1), (1, 0), (1, 1)):
  l = [a0, a1]

  for i in range(1, N + 1):
    if s[i] == 'o': l.append(not (l[i] ^ l[i - 1]))
    else: l.append(l[i] ^ l[i - 1])

  if (l[0] == l[-2]) and (l[1] == l[-1]):
    s = ''.join(['S' if i == 1 else 'W' for i in l[:-2]])
    print(s)
    exit()

print(-1)

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

int INF = 100000000;
int N,A,B,C;
vector<int> l;

int dfs(int pos,int a,int b,int c) {
    // 停止条件
    if (pos == N){
      if(min({a,b,c})==0) return INF;
      return abs(a-A)+abs(b-B)+abs(c-C)-30;
    }

    // pos を進めながら（末端に進みながら）分岐処理
    // 末端まで到達した時それぞれの分岐から値が返される
    // for 文で書ける場合は for 文で実装
    int ret1 = dfs(pos + 1, a,b,c);
    int ret2 = dfs(pos + 1, a+l[pos],b,c)+10;
    int ret3 = dfs(pos + 1, a,b+l[pos],c)+10;
    int ret4 = dfs(pos + 1, a,b,c+l[pos])+10;

    // それぞれの分岐からの戻り値の処理を行う関数
    return min({ret1, ret2, ret3, ret4});
}


int main() {
  cin >> N >> A >> B >> C;
  l.resize(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &l[i]);
  }

  cout << dfs(0,0,0,0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string s, t;
  std::cin >> s;
  std::cin >> t;
  bool f = true;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]) f = false;
  }
  std::cout << (f?"Yes":"No") << '\n';
  return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    ll n = 1, ma = (ll)2e18;
    for (int i = 0; i < N; ++i) {
        ll A;
        cin >> A;
        if (A == 0)
            n = 0;
        if (n != 0) {
            if (ma / n >= A)
                n *= A;
            else
                n = ma;
        }
    }

    cout << (n <= (ll)1e18 ? n : -1) << endl;
    return 0;
}


Measured memory_bytes: 3696
from collections import defaultdict

n, wmax = map(int, input().split())
dp = [defaultdict(int) for _ in range(2)]
dp[0][0] = 0
for i in range(n):
    w, v = map(int, input().split())
    if i == 0:
        w0 = w
    dp[(i+1)%2] = defaultdict(int)
    for j in range(n+1):
        for k in range(300):
            weight = j*w0+k
            if weight <= wmax:
                if weight - w >= 0:
                    dp[(i+1)%2][weight] = max(dp[(i+1)%2][weight], dp[i%2][weight - w] + v)
                dp[(i+1)%2][weight] = max(dp[(i+1)%2][weight], dp[i%2][weight])

print(max(list(dp[n%2].values())))


Measured memory_bytes: 128340
#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>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, m;
  cin >> n >> m;
  vl w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];
  vector<vl> dp(n + 1, vl(m + 1, 0));
  rep(i, n) rep(j, m + 1) {
    if(j >= w[i])
      dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
    else
      dp[i + 1][j] = dp[i][j];
  }
  ll ans = 0;
  rep(j, m + 1) ans = max(ans, dp[n][j]);
  cout << ans << endl;
}

Measured memory_bytes: 80256
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);

        int r = scan.nextInt();
        int col = scan.nextInt();

        int[][] a = new int[r][col];
        int[][] b = new int[col][1];
        int[][] c = new int[r][1];
        scan.nextLine();

        for (int i = 0; i < a.length;i++) {
            for(int j = 0;j < a[0].length;j++) {
                a[i][j] = scan.nextInt();
            }
            scan.nextLine();
        }
        for (int i = 0; i < b.length;i++) {
            b[i][0] = scan.nextInt();
            scan.nextLine();
        }
        for (int i = 0; i < a.length;i++) {
            int t = 0;
            for (int j = 0; j < a[0].length;j++) {
                t += a[i][j] * b[j][0];
                c[i][0] = t;
            }
        }
        for (int i = 0; i < c.length; i++) {
         System.out.println(c[i][0]);
        }
    }
}

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


int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = 0;
  rep(i, n){
    if(i % 2 == 0 && a[i] % 2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
//
// Created by kuribohkute on 20/04/2019.
//
#include <unordered_map>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
#define mp make_pair
#define X first
#define Y second
unsigned long long gcd (unsigned long long a, unsigned long long b) {
    return b == 0 ? a : gcd(b, a % b);
}
unsigned long long lcm (unsigned long long a, unsigned long long b) {
    return a * b / gcd(a, b);
}
unsigned long long divide (unsigned long long a, unsigned long long b, unsigned long long c) {
    return max ((unsigned long long) 0, b / c - (a - 1) / c);
}
int main () {
    unsigned long long a, b, c, d;
    cin >> a >> b >> c >> d;
//    cout << divide(a, b, c) << " " << divide(a, b, d) << " " << divide(a, b, lcm(c, d)) << "\n";
    cout << b - a + 1 - (divide(a, b, c) + divide(a, b, d) - divide(a, b, lcm(c, d)));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int h,w;
string s[100];
const Int MOD = 1e8+7;
Int dp[11][100000];
Int po[20];
Int dfs(Int y,Int b);
Int dfs2(Int y,Int x,vector<Int> &v);

const Int DBG = 0;
Int dfs(Int y,Int b){
  if(DBG) cout<<y<<":"<<b<<endl;
  if(y==h) return b==0;
  Int &res=dp[y][b];
  if(~res) return res;
  res=0;
  vector<Int> v(w,0);
  for(Int i=0;i<w;i++){
    v[i]=-((b/po[i])%3);
    if(s[y][i]=='.') continue;
    v[i]+=s[y][i]-'0';
    if(v[i]<0) return res;
  }
  if(DBG){
    for(Int i=0;i<w;i++) cout<<v[i]<<":";
    cout<<endl;
  }
  res+=dfs2(y,0,v);
  res%=MOD;
  if(DBG) cout<<y<<":"<<b<<":"<<res<<endl;
  return res;
}
Int calc(vector<Int> &v){
  Int b=0;
  for(Int i=w-1;i>=0;i--){
    if(v[i]>0||-v[i]>2) return -1;
    b=b*3+(-v[i]);
  }
  return b;
}
Int dfs2(Int y,Int x,vector<Int> &v){
  //cout<<y<<"*"<<x<<endl;
  while(x<w&&!isdigit(s[y][x])) x++;
  if(x==w){
    Int b=calc(v);
    if(~b) return dfs(y+1,b);
    return 0;
  }
  Int px=x++,flg=0;
  while(x<w&&!isdigit(s[y][x])){
    flg|=(v[x]<0); 
    x++;
  }
  if(x==w){
    v[px]*=-1;
    Int res=dfs2(y,x,v);
    v[px]*=-1;
    return res;
  }
  Int res=0;
  Int pv=v[px];
  for(Int i=0;i<=pv;i++){
    if(i>=3||pv-i>=3) continue;
    if(flg && i!=pv) continue;
    v[x]-=pv-i;
    v[px]=-i;
    res+=dfs2(y,x,v);
    res%=MOD;
    v[x]+=pv-i;
    v[px]=pv;
  }
  return res;
}


signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  cin>>h>>w;
  for(Int i=0;i<h;i++) cin>>s[i];
  po[0]=1;
  for(Int i=1;i<20;i++) po[i]=po[i-1]*3;
  memset(dp,-1,sizeof(dp));
  cout<<dfs(0,0)<<endl;
  return 0;
}



Measured memory_bytes: 11784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define M(x) ((x+MOD)%MOD)
#define MAX 2010

ll fac[MAX];

ll qpow(ll n, ll k)
{
	ll res = 1;
	while (k) {
		if (k & 1) res = M(res * n);
		n = M(n * n);
		k >>= 1;
	}
	return res;
}

ll inv(ll a)
{
	return qpow(a, MOD - 2);
}

ll C(ll a, ll b)
{
	if (a < b)
		return 0;
	return M(M(fac[a] * inv(fac[a - b])) * inv(fac[b]));
}

int main()
{
	int n, k;
	fac[0] = fac[1] = 1;
	scanf("%d%d", &n, &k);
	for (int i = 2;i <= n;++i)
		fac[i] = M(fac[i - 1] * i);
	for (int i = 1;i <= k;++i)
		printf("%lld\n", M(C(n - k + 1, i)*C(k - 1, i - 1)));
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	int[] x;
	public boolean dfs(int idx, int left, int right){
		if( idx >= 10 ){
			return true;
		}
		boolean flag = left < x[idx] ? dfs(idx+1, x[idx], right) : false;
		flag = flag || (right < x[idx] && dfs(idx+1, left, x[idx]));
		return flag;
	}
	public void solve() throws IOException {
		int n = nextInt();
		for(int i = 0; i < n; i++){
			x = new int[10];
			for(int j = 0; j < 10; j++){
				x[j] = nextInt();
			}
			if( dfs(0, 0, 0) ){
				writer.println("YES");
			} else {
				writer.println("NO");
			}
		}
		writer.flush();
	}
	public static void main(String[] args){
		new Main().run();
	}
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	public void run() {
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch(Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}
	public String nextToken() throws IOException {
		if( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
}

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

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12


int main(void)
{
	//変数の宣言
	int t;
	llong int a,b,c,d;
	llong int gcd;
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	llong int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;
	//データの読み込み
	scanf("%d",&t);
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=0;i<t;i++){
		scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
		
		if(b>d){
			printf("No\n");
		}else{
			temp1=b;
			temp2=d;
		while(temp1!=0&&temp2!=0){
				if(temp1>temp2){
					temp1=temp1%temp2;
				}else{
					temp2=temp2%temp1;
				}
			}
			
			gcd=max(temp1,temp2);
			
			if(a-c>gcd){
//				printf("a=%lld,a-c=%lld,gcd=%lld,(a-c)/gcd=%lld\n",a,a-c,gcd,(a-c)/gcd);
				a=a-((a-c-1)/gcd)*gcd;
			}
//			printf("gcd=%lld,a=%lld\n",gcd,a);
			
			if(a>=b){
				printf("Yes\n");
			}else{
				printf("No\n");
			}
		}
	}
	
	
	
//	printf("計算部分終了\n");
	//出力
	
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 128
#include <iostream>
#define AMAX 50
#define MMAX 200
#define TRUE 1
#define FALSE 0
using namespace std;

int solve(int,int);
int A[AMAX],n;
  
int main(){
  int q,M[MMAX];
  int i;
  
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> A[i];
  }
  cin >> q;
  for(i = 0; i < q; i++){
    cin >> M[i];
    if(solve(0,M[i]) > 0){  /**/
      cout << "yes" << endl;
    }
    else{
      cout << "no" << endl;
    }
  }
  return 0;
}
int solve(int i,int m){
  int res;
  if(m == 0){
    return TRUE;
  }
  if(n <= i){
    return FALSE;
  }
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

Measured memory_bytes: 3072
import java.io.*
import java.util.*
import java.lang.Math.*


fun main() {
    val S = rd.readString()
    val T = rd.readString()
    val N = S.length

    var ans = 0
    for (i in 0 until N) {
        if (S[i] != T[i]) ans++
    }

    println(ans)
}


//val rd = debug.Reader("abc", "171", "b", "sample-1")
val rd = Reader()
fun main(args: Array<String>) {
    Thread(null, MainThread(), "mainThread", 128 * 1024 * 1024).start()
}


const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
class MainThread : Runnable {
    override fun run() { main() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 38664
def Xok():
    s=set([xp])
    for i in X:
        tmp=set()
        for c in s:
            tmp.add(c+i)
            tmp.add(c-i)
        s=tmp
    return True if x in s else False
def Yok():
    s=set([0])
    for i in Y:
        tmp=set()
        for c in s:
            tmp.add(c+i)
            tmp.add(c-i)
        s=tmp
    return True if y in s else False

s=input()
N=len(s)
x,y=map(int,input().split())

xp,X,Y=0,[],[]

i=0
while(i<N and s[i]!='T'):
    xp+=1
    i+=1
i+=1
flag=True
while(i<N):
    j=i
    cnt=0
    while(j<N and s[j]!='T'):
        cnt+=1
        j+=1
    if flag:
        Y.append(cnt)
    else:
        X.append(cnt)
    i=j+1
    flag=not flag

print('Yes' if Xok() and Yok() else 'No')

Measured memory_bytes: 81188
#include<bits/stdc++.h>
#define ll long long
#define ld long double 
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace :: std;

const ll  maxn=1e6+500;
const ll inf=1e9+9;

ll dp[maxn];// dp[i] = dfa roye i base minimom badesh 
ll dfa[maxn][29];



int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	s='#'+s;
	ll n=s.size();
	for(ll i=0;i<n;i++){
		s[i]-='a';
	}


	for(ll j=0;j<26;j++){
		dfa[n-1][j]=n;
	}
	for(ll i=n-2;i>=0;i--){
		for(ll j=0;j<26;j++){
			dfa[i][j]=dfa[i+1][j];
		}
		dfa[i][s[i+1]]=i+1;
	}

	for(ll i=n-1;i>=0;i--){
		dp[i]=inf;
		for(ll j=0;j<26;j++){
			dp[i]=min(dp[i],dp[dfa[i][j]]+1);		
		}
	}
	string ans;
	ll p=0;
	while(p<n){
		for(ll i=0;i<26;i++){
			if(dp[p]==dp[dfa[p][i]]+1){
				ans+=(i+'a');
				p=dfa[p][i];
				break;
			}
		}
	}
	cout<<ans;
}


Measured memory_bytes: 51792
#pragma GCC optimize ("O3")
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <vector>
using namespace std;

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;

  vector<int> p, q, r;
  for(int i = 0; i < A; ++i) {
    int x; cin >> x;
    p.push_back(x);
  }
  for(int i = 0; i < B; ++i) {
    int x; cin >> x;
    q.push_back(x);
  }
  for(int i = 0; i < C; ++i) {
    int x; cin >> x;
    r.push_back(x);
  }

  sort(p.begin(), p.end(), greater<int>());
  sort(q.begin(), q.end(), greater<int>());
  sort(r.begin(), r.end(), greater<int>());
  p.resize(X);
  q.resize(Y);

  copy(p.begin(), p.end(), back_inserter(r));
  copy(q.begin(), q.end(), back_inserter(r));

  sort(r.begin(), r.end(), greater<int>());
  r.resize(X+Y);

  cout << accumulate(r.begin(), r.end(), 0ll) << endl;

  return 0;
}


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

#define MAX_N 100000

int order[MAX_N];

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

  for(int i=0; i<N; i++) {
    int idx;
    cin >> idx;
    order[idx - 1] = i + 1;
  }

  for(int i=0; i<N; i++) {
    cout << order[i];
    if(i == N - 1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
  
  return 0;
}
	

Measured memory_bytes: 1280
#include<iostream>
#include <string>
#include <algorithm>
#include <deque>
#include <vector>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;
deque<int> fri[100005];//隣接リスト、フレンド
deque<int> blo[100005];//隣接リスト、ブロック
int N,M,K;
 
struct UnionFind{
    vector<int>par;
    vector<int>sizes;//親がsizeを持つ
    UnionFind(int n):par(n),sizes(n,1){//初期化(すべての要素を独立にする)
        rep(i,0,n)par[i]=i;
    }
    int root(int x){//xの根を求める
        if(par[x]==x)return x;
        return (par[x]=root(par[x]));//
    }
    bool same(int x,int y){//xとyが同じ気に属するか判定する
        return root(x)==root(y);
    }
    void unite(int x,int y){//xとyが属する気をマージする
        x=root(x);
        y=root(y);
        if(x==y)return;//すでに同じ気ならマージしない
        if(sizes[x]<sizes[y])swap(x,y);//xの木が大きいようにする
        par[y]=x;
        sizes[x]+=sizes[y];
    }
    int size(int x){
        return sizes[root(x)];
    }
};
 
int main(){
    cin>>N>>M>>K;
    UnionFind tree(N);
    //リストに格納する
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        fri[a].push_back(b);
        fri[b].push_back(a);
        tree.unite(a,b);
    }
    for(int i=0;i<K;i++){
        int c,d;
        cin>>c>>d;
        c--;d--;
        blo[c].push_back(d);
        blo[d].push_back(c);
    }
    
    rep(i,0,N){
        int c=0;
        c=tree.size(i);
        fore(j,blo[i]){
            if(tree.same(i,j)){
                c--;
            }
        }
        puts(c-1-fri[i].size());
    }
    
    

 
}

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

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
#define MOD 1000000007;

/*
    Ball and Boxes 1
    人間、教室、制限なし
*/

int main() {
    ll n, k;
    cin >> n >> k;

    ll ans = 1;

    rep(i,n){
        ans *= k;
        ans %= MOD;
    }

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



Measured memory_bytes: 3124
n, m = map(int, input().split())
AB = []
for i in range(n):
    a, b = map(int, input().split())
    AB.append((a, b))
AB.sort()

ans = 0
for i in range(n):
    a, b = AB[i]
    if b >= m:
        ans += a*m
        break
    else:
        ans += a*b
    m -= b
print(ans)


Measured memory_bytes: 53208
n = int(input())
l = list(map(int, input().split(' ')))

def gcd(a, b):
    return b if a % b == 0 else gcd(b, a % b)
def lcm(a, b):
    return a * b // gcd(a, b)
hoge = 1
for p in l:
    hoge = lcm(hoge, p)
ans = 0
for p in l:
    ans += hoge // p
print(ans % int(1e9 + 7))  # TLE ????


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    ll A = N / K;
    ll B = (N*2 + K) / (K*2);
    if(K % 2 == 0) PR(A*A*A+B*B*B);
    else PR(A*A*A);

    return 0;
}

/*



*/

Measured memory_bytes: 3628