akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
#include <unordered_map>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <sstream>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll pow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = pow(N, P/2);
        return t*t;
    }
    return N * pow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}

int main() {
    string s[2];cin>>s[0]>>s[1];
    set<int>memo;
    bool flag=0;
    rep(i,s[0].size()){
        if(memo.find(i)!=memo.end())continue;
        memo.insert(i);
        char tg[2];
        tg[0]=s[0][i];
        tg[1]=s[1][i];

        for(int j=i+1;j<s[0].size();j++){
            if(s[0][j]!=tg[0]&&s[1][j]!=tg[1])continue;

            if(s[0][j]==tg[0]&&s[1][j]==tg[1])memo.insert(j);

            else{flag=1;break;}
        }
        if(flag)break;
    }
    if(flag)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  int N;
  cin >> N;
  cout << N / 3 << endl;
  return 0;
}

Measured memory_bytes: 256
int main()
{
  int a, b;
  scanf("%d %d", &a, &b);
  int plus, minus, multi;
  plus = a + b;
  minus = a - b;
  multi = a * b;
  if (plus >= minus && plus >= multi)
    printf("%d", plus);
  else if (minus >= plus && minus >= multi)
    printf("%d", minus);
  else
    printf("%d", multi);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#define INF 1e5
using namespace std;

int n,m;
int x[101],y[101],v[101];
int xd[101],yd[101];
double cost[101][101];
struct edge{
	int to,cap,rev;
	edge(){}
	edge(int tt,int cc,int rr){
		to=tt;
		cap=cc;
		rev=rr;
	}
};
vector<edge> G[205];

void add_edge(int from,int to,int cap){
	G[from].push_back(edge(to,cap,G[to].size()));
	G[to].push_back(edge(from,0,G[from].size()-1));
}

bool used[205];

int dfs(int v,int t,int f){
	if(v==t)return f;
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		edge &e=G[v][i];
		if(!used[e.to] && e.cap>0){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow=0;
	while(1){
		memset(used,0,sizeof(used));
		int f=dfs(s,t,1);
		if(f==0)return flow;
		flow+=f;
	}
}

bool C(double x){
	for(int i=0;i<=n+m+1;i++){
		G[i].clear();
	}
	for(int i=0;i<n;i++){
		add_edge(0,i+1,1);
		for(int j=0;j<m;j++){
			if(cost[i][j]<=x)add_edge(i+1,n+j+1,1);
		}
	}
	for(int i=0;i<m;i++){
		add_edge(n+i+1,n+m+1,1);
	}
	return max_flow(0,n+m+1)==m;
}

int main(void){
	while(1){
		scanf("%d %d",&n,&m);
		if(n+m==0)break;
		for(int i=0;i<n;i++){
			scanf("%d %d %d",&x[i],&y[i],&v[i]);
		}
		for(int i=0;i<m;i++){
			scanf("%d %d",&xd[i],&yd[i]);
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				cost[i][j]=sqrt(pow(x[i]-xd[j],2)+pow(y[i]-yd[j],2))/(double)v[i];
			}
		}
		double l=0.0,r=INF;
		for(int i=0;i<100;i++){
			double mid=(l+r)/2.0;
			if(C(mid))r=mid;
			else l=mid;
		}
		printf("%.8f\n",r);
	}
	return 0;
}

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

int main() {
  int a, b, n, s, f, ans = 0;
  cin >> a >> b >> n;
  for (int i = 0; i < n; i++) {
    cin >> s >> f;
    if (!(f <= a || b <= s)) ans = 1;
  }
  cout << ans << "\n";
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 3e5 + 9, M = 4e5 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();

    int n, p;   cin >> n >> p;
    string s;   cin >> s;

    reverse(s.begin(), s.end());

    ll ans = 0;
    if(p == 5){
        for(int i = 0;i < n;i++){
            if(s[i] == '0' || s[i] == '5')  ans += (n - i);
        }
    }

    if(p == 2){
        for(int i = 0;i < n;i++){
            if((s[i] - '0') % 2 == 0) ans += (n - i);
        }
    }

    if(p != 2 && p != 5){
        int mod[p] = {0};   mod[0]++;
        int x = 0;
        for(int i = 0, pw = 1;i < n;i++){
            x += (s[i] - '0') * pw;
            x %= p;
            pw *= 10;    pw %= p;
            ans += mod[x]++;
        }
    }

    cout << ans;
}

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

struct node{
	unsigned int key;
	struct node *next;
	struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch( int key )
{
	NodePointer cur = nil->next;
	while( 1 ) {
		if( cur == nil ) { break; }
		if( cur->key == key ) { break; }
		cur = cur->next;
	}
	return cur;
}

void init( )
{
	nil = malloc( sizeof(struct node) );
	nil->next = nil;
	nil->prev = nil;
}

void printList( )
{
	NodePointer cur = nil->next;
	int isf = 1;
	while(1) {
		if( cur == nil ) { break; }
		if( isf == 0) { printf(" "); }
		printf( "%d", cur->key );
		cur = cur->next;
		isf = 0;
	}
	printf("\n");
}

void deleteNode( NodePointer t )
{
	NodePointer pt = t->prev;
	NodePointer nt = t->next;
	pt->next = nt;
	nt->prev = pt;
	free( t );
}

void deleteFirst( )
{
	NodePointer t = nil->next;
	if( t == nil ) return;
	deleteNode( t );
}

void deleteLast( )
{
	NodePointer t = nil->prev;
	if( t == nil ) return;
	deleteNode( t );
}

void delete( int key )
{
	NodePointer t = listSearch( key );
	if( t == nil ) return;
	deleteNode( t );
}

void insert( int key )
{
	NodePointer x;
	x = malloc( sizeof(struct node) );
	x->key = key;
	x->next = nil->next;
	x->next->prev = x;
	x->prev = nil;
	nil->next = x;
}


int main( int argc, char *argv[] ) 
{
	int key, n, i;
	char com[20];
	
	scanf( "%d", &n );
	init( );
	for( i = 0; i < n; i++ ) {
		scanf( "%s", com );
		if( com[0] == 'i' ) {
			scanf( "%d", &key );
			insert( key ); 
		} else if( com[0] == 'd' ) {
			if( 6 < strlen( com )  ) {
				if( com[6] == 'F' ) { 
					deleteFirst( );
				} else if( com[6] == 'L' ) {
					deleteLast( );
				}
			} else {
				scanf( "%d", &key );
				delete( key );
			}
		}
	}
	printList( );
	
    return 0;
}

Measured memory_bytes: 31784
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 4*1001001001001001001;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int A,B,C,D,E,F; cin >>A>>B>>C>>D>>E>>F;

    double res = -1;
    int wat = 0;
    int sug = 0;
    for (int a = 0; a < 31; a++) {
        for (int b = 0; b < 31; b++) {
            for (int c = 0; c < 101; c++) {
                for (int d = 0; d < 101; d++) {
                    if (100*(A*a + B*b) + C*c + D*d > 0 && 100*(A*a + B*b) + C*c + D*d <= F && (C*c + D*d) <= E*(A*a + B*b)) {
                        int den = 100*(A*a + B*b) + C*c + D*d;
                        int num = 100*(C*c + D*d);
                        double ratio = ((double)num)/((double)den);
                        if (ratio > res) {
                            res = ratio;
                            wat = den;
                            sug = num/100;
                        } 
                    } 
                }
            }
        }
    }

    cout << wat << " " << sug << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
struct node{
	ll x,y;
	 
}r[1100];
bool cmp(node a,node b){
	return atan2(a.y,a.x) < atan2(b.y,b.x);
	
}
int main(){
	ll n,x,y;
	cin >> n;
	for(ll i = 0; i < n; i++){
		cin >> r[i].x >> r[i].y;
	}
	ll ans = 0;
	sort(r,r+n,cmp);
	for(ll i = 0; i < n; i++){
		x = r[i].x ; y = r[i].y;
		ans = max(ans,x*x+y*y);
		for(ll j = (i+1)%n; j != i; j = (j+1)%n){
			x += r[j].x ; y += r[j].y;
			ans = max(ans,x*x+y*y);
		}

	}
	double ans1 = sqrt(ans);
	printf("%.13lf\n",ans1);
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = 998244353;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

struct num { ll i; ll v; };

int main() {
  int N; cin >> N; 
  string X; cin >> X; rep(i,N) X += X[i]=='0' ? '1' : '0';
  N *= 2;
  int tn = 1; while(N%(tn*2)==0) tn*= 2;


  vector<num> ya;
  for (int i=1; i*i<=N; i++) {
    if (N%i==0) {
      if (i%tn==0) ya.push_back({i,0});
      if ((N/i)%tn==0) ya.push_back({N/i,0});
    }
  }
  sort(all(ya),[](const num &x, const num &y){return x.i<y.i;});
  // for(auto x: ya) cout << x.i << " "; cout << endl;
  // cout << X << endl;

  for (auto &x: ya) {
    string ts = X.substr(0,x.i/2); rep(i,x.i/2) ts += ts[i]=='0' ? '1' : '0';
    string s; rep(i,N/x.i) s += ts;
    rep(i,x.i/2) {
      x.v *= 2;
      x.v += X[i] - '0';
      x.v %= MOD;
    }
    x.v += s<=X; x.v %= MOD;
    for (auto y: ya) {
      if (x.i<=y.i) break;
      if (x.i%y.i==0) {
        x.v -= y.v; x.v %= MOD;
      }
    }
    x.v = (x.v%MOD+MOD)%MOD;
  }
  // for(auto x: ya) cout << x.i << "->" << x.v << " "; cout << endl;
  ll result = 0;
  for (auto x: ya) { result += x.i*x.v; result %= MOD; }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;
	int n;
	cin>>n;
	int a[n],i;
	long double s=0;
	for(i = 0 ; i < n ; i++ )
	{
		cin >> a[i];
	}
	for(i=0;i<n;i++)
	{
		if(a[i]==0)
		{
			cout<<0<<endl;
			return 0;
		}
	}
	s=0;
	for(i=0;i<n;i++)
	{
		s+=log10(a[i]);
	}
	if(s>18)
	{
		cout<<-1<<endl;
		return 0;
	}
	int ans=1;
	for(i=0;i<n;i++)
	{
		ans*=a[i];
	}
	if(ans>1000000000000000000)
	{
		cout<<-1<<endl;
		return 0;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4672
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
    long long minu(long long a, long long b){
        return mod(mod(a)-mod(b));
    }
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
    
    vector<int>dirX={-1,0,1};
    vector<int>dirY={-1,0,1};
 
 
    void solve(){
        ll n;
        cin>>n;
        if(n==1){
            cout<<0;
            return;
        }
        if(n==2){
            cout<<2;
            return;
        }
        ll ans=minu(add(modPow(10LL,n),modPow(8LL,n)),mul(2LL,modPow(9LL,n)));
        cout<<ans;
    }
    int main(){
 
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
        //    cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3560
let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let arr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let _ = Array.fast_sort compare arr in
  let ans = ref 0 in
  for i = 0 to Array.length arr - 1 do
    for j = i + 1 to Array.length arr - 1 do
      for k = j + 1 to Array.length arr - 1 do
        if arr.(i) <> arr.(j) && arr.(j) <> arr.(k) && arr.(i) + arr.(j) > arr.(k) 
        then ans := !ans + 1
      done;
    done;
  done; Printf.printf "%d\n" !ans

Measured memory_bytes: 3888
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

const double eps = 5e-3;

struct point {
  double x,y,z;
  point(){}
  point(double x, double y, double z):x(x),y(y),z(z){}
  point operator-(const point &t){
    return point(x-t.x,y-t.y,z-t.z);
  }
};

double abs(const point &a){
  return sqrt(a.x*a.x + a.y*a.y + a.z*a.z);
}

bool eq( double a, double b){
  return abs(a/b-b/a)<0.0001;
}

//                       a b c
//                       Q R P
const int possible[3][3] = { {1,1,0},
                             {0,1,1},
                             {1,0,1} };

bool determine(int p[3], int q[3], int depth, pair<int,int> out[3] ){
  if( depth == 3 ){
    for(int i = 0; i < depth; ++i){
      for(int j = i+1; j < depth; ++j){
        if( (out[i].first == out[j].first || out[i].second == out[j].second) ){
          return false;
        }
      }
    }
    return true;
  }
  for(int j = 0; j < 3; ++j){
    for(int k = 0; k < 3; ++k){
      if( possible[p[depth]][j] && possible[q[depth]][k] ){
        out[depth] = make_pair(j,k);
        if( determine(p,q,depth+1,out) ) return true;
      }
    }
  }
  return false;
}

int main()
{
  int T;
  cin >> T;
  for(int tc=0;tc<T;++tc){
    int n;
    pair<double,int> l[3];
    vector<point> vp;

    for(int i = 0; i < 3; ++i){
      //  QR , RP , PQ
      cin >> l[i].first;
      l[i].second = i;
    }
    // sort(l,l+3);

    cin >> n;
    for(int i = 0; i < n; ++i){
      point p; cin >> p.x >> p.y >> p.z;
      vp.push_back( p );
    }

    for(int a = 0; a < n; ++a){
      
      for(int b = 0; b < n; ++b){
        if( a == b ) continue;
        
        for(int c = 0; c < n; ++c){
          if( b == c || a == c ) continue;
          
          pair<double,int> tl[3];
          
          tl[0] = make_pair(abs(vp[a]-vp[b]),0);
          tl[1] = make_pair(abs(vp[b]-vp[c]),1);
          tl[2] = make_pair(abs(vp[c]-vp[a]),2);
          // sort(tl,tl+3);
          
          if( eq( tl[2].first / l[2].first, tl[1].first / l[1].first ) &&
              eq( tl[2].first / l[2].first, tl[0].first / l[0].first) ) {

            cout << c+1 << ' ' << a+1 << ' ' << b+1 << endl;
            /*
            int pp[3] = { l[2].second, l[1].second, l[0].second};
            int qq[3] = {tl[2].second,tl[1].second,tl[0].second};
            pair<int,int> res[3];
            determine(pp,qq,0,res);

            sort(res,res+3);

            cout << a << ' ' << b << ' ' << c << endl;
            for(int i = 0; i < 3; ++i){
              cout << res[i].first << ' ' << res[i].second << endl;
            }
            swap(res[0],res[2]);
            swap(res[1],res[2]);

            int id[3] = {a,b,c};
            for(int i = 0; i < 3; ++i){
              if( i ) cout << ' ';
              cout << 1+id[res[i].second];
            }
            cout << endl;
            */
          }
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1240
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int x = scn.nextInt();
		int[] a = new int[n];
		for(int i=0; i<a.length; ++i){
			a[i] = scn.nextInt();
		}
      	int sum = 0;
      	for(int i=0; i<a.length; ++i){
			sum = sum + a[i];
		}
      	int xx = x - sum;
      	int mini = 1000;
      	for(int i=0; i<a.length; ++i){
			if(mini>a[i]){
              mini = a[i];
            }
		}
      	int num = xx/mini;
      	int ans = n + num;
      	System.out.println(ans);
	}
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n;
    cin >> n;
    set<long long> S;
    for (long long i = 1; i * i <= n - 1; ++i) {
        if ((n - 1) % i == 0) {
            if (i != 1) S.insert(i);
            if ((n - 1) / i != 1) S.insert((n - 1) / i);
        }
    }
    S.insert(n);
    for (long long k = 2; k * k <= n; ++k) {
        long long tmp = n;
        while (tmp % k == 0) {
            tmp /= k;
            if ((tmp - 1) % k == 0) {
                S.insert(k);
                break;
            }
        }
    }
    cout << S.size() << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int n;
string s;

// index が条件を満たすかどうか
int solve() {
    int s0 = n/2;
    int s1 = n/2;
    if (n%2==0) s0--;

    int t0 = n; int t1 = -1;

    for (int i = s0; i < n-1; ++i) {
        if (s[i]!=s[i+1]) {
            t0=i+1;
            break;
        }
    }

    for (int i = s1; i > 0; --i) {
        if (s[i]!=s[i-1]) {
            t1=i-1;
            break;
        }
    }

    int ret = min(n-1-t1, t0);
    return ret;
}

int main(int argc, char const *argv[]) {
    cin >> s;
    n = s.length();
    int ans = solve();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s,t;
    R(s,t);
    map<char,char>c1,c2;
    REP(i,SZ(s)){
        c1[s[i]]=t[i];
        c2[t[i]]=s[i];
    }
    REP(i,SZ(s)){
        if(c1[s[i]]!=t[i] || c2[t[i]] != s[i]){
            W("No");
            return 0;
        }
    }
    W("Yes");
    return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 100005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<lint,lint> pii;
map<lint,lint>M;
vector<lint> V[MAX];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    lint n,a,mx,sum=0;
    cin>>n>>mx;
    for(lint i=2;i<=n;i++){
        cin>>a;
        if(a<mx){
            sum+=(mx-a);
        }
        else
            mx=a;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 5972
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
#define ch() getchar()
#define pc(x) putchar(x)
template<typename T>inline void read(T&x){
	int f;char c;
	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;
	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;
}
template<typename T>inline void write(T x){
	static char q[64];int cnt=0;
	if(!x)pc('0');if(x<0)pc('-'),x=-x;
	while(x)q[cnt++]=x%10+'0',x/=10;
	while(cnt--)pc(q[cnt]);
}
const int maxn=200005;
int vis[maxn],pos[maxn],nt[maxn];
int main(){
	int n;long long k;
	read(n),read(k);
	for(int i=1;i<=n;++i)
		read(nt[i]);
	int no=1,cnt=0,an;
	while(true){
		if(vis[no]){
			an=vis[no];break;
		}
		pos[vis[no]=++cnt]=no;
		no=nt[no];
	}
	if(k+1<=1ll*cnt){
		write(pos[k+1]),putchar('\n');
	}
	else{
		k-=an-1;k%=(cnt-an+1);
		write(pos[an+k]),putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 5860
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include<iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;
const ll mod=1000000007;
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,tmp=n;while(tmp!=0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll q,h,s,d,n;
 cin>>q>>h>>s>>d>>n;
 q*=4;
 h*=2;
 ll t=min(q,h);
 t=min(t,s);
 ll ans=min((n/2)*d+(n%2)*t,n*t);
 pr(ans);
return 0;}

Measured memory_bytes: 3628
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	ll n,a,b;
	cin>>n>>a>>b;
	if(a){
	    ll q = (n/(a+b))*a;
	    ll r = ((n%(a+b))>a)?a:n%(a+b);
	    cout<<q+r<<endl;
	}
	else cout<<"0"<<endl;
	return 0;
}


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

ll modpower(ll a, ll r, ll mod){ //a^r
    ll x = 1;
    a %= mod;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a, ll mod){
    return modpower(a, mod-2, mod);
}

vector<ll> fact;
vector<ll> invfact;

void set_fact(ll n, ll mod){
    fact.resize(n+1, 1);
    invfact.resize(n+1, 1);
    for (ll i = 2; i <= n; i++) {
        fact[i] = fact[i-1] * i % mod;
    }
    invfact[n] = modinv(fact[n], mod);
    for (ll i = n-1; i >= 2; i--) {
        invfact[i] = invfact[i+1] * (i+1) % mod;
    }
    return;
}

ll comb(ll n, ll k, ll mod) {
    if (k > n || k < 0) return 0;
    if (k == n || k == 0) return 1;
    return fact[n] * invfact[n-k] % mod * invfact[k] % mod;
}

int main(){
    ll N, M;
    cin >> N >> M;
    ll mod = 1e9+7;
    set_fact(N+M+10, mod);
    
    ll ans = 0;
    for (ll i = 0; i <= N; i++) {
        ll a = fact[M] * invfact[M-i] % mod;
        ll b = fact[M-i] * invfact[M-N] % mod;
        ll t = comb(N, i, mod) * a % mod * b % mod * b % mod;
        if (i%2 == 0) ans += t;
        else ans -= t;
    }
    cout << (ans%mod+mod)%mod << endl;
    
    return 0;
}

Measured memory_bytes: 18788
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int f[100001],g[100001],ans;
int main()
{
	int n,m;
	cin>>n>>m;
	if(n>=m)
	{
		cout<<0;
		return 0;
	}
	for(int i=1;i<=m;i++)
	{
		cin>>f[i];
	}
	sort(f+1,f+m+1);
	for(int i=2;i<=m;i++)
	{
		g[i-1]=abs(f[i]-f[i-1]);
	}
	sort(g+1,g+m);
	for(int i=m-n;i>0;i--)
	{
		ans+=g[i];
	}
	cout<<ans;
}

Measured memory_bytes: 1024
def factorization(n):
    arr = [[1,1]]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
A,B =list(map(int, input().split(" ")))

val = min(A,B)
lim = int(val ** 0.5)


ms = factorization(min(A,B)) 
res = []
maxi = max(A,B)

for v, _ in ms:
    if maxi % v == 0:
        res.append(v)
print(len(res))

Measured memory_bytes: 3064
n = input()
ans = {}
for i in range(n):
  (a, b) = raw_input().split()
  if not (len(a), a) in ans:
    ans[(len(a), a)] = 0
  ans[(len(a), a)] += int(b)

for (l, k) in sorted(ans):
  print k, ans[(l, k)]

Measured memory_bytes: 4472
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

long long calc(int n, long long* a, bool isPositive){
    long long nCount = 0, sum = 0;

    for(int i = 0; i < n; i++){
        if(isPositive){
            if((a[i] + sum) < 0){
                sum += a[i];
            }else{
                nCount += abs(a[i] + sum) + 1;
                sum = -1;
            }
            isPositive = !isPositive;
        }else{
            if((a[i] + sum) > 0){
                sum += a[i];
            }else{
                nCount += abs(a[i] + sum) + 1;
                sum = 1;
            }
            isPositive = !isPositive;
        }
    }

    return nCount;
}

int main(){
    int n;
    long long a[100005];

    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];

    bool isPositive;
    long long nCount[2];

    /* pattern 1 */
    isPositive = true;
    nCount[0] = calc(n, a, isPositive);

    /* pattern 2 */
    isPositive = false;
    nCount[1] = calc(n, a, isPositive);

    cout << min(nCount[0], nCount[1]) << endl;

    return 0;
}



Measured memory_bytes: 1024
import java.util.*;
import java.io.PrintWriter;

public class Main{
	static int[] c=new int[26];
	static int[] lastD=new int[26];
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long startTime = System.currentTimeMillis();
		Random rd=new Random();
		Random rc=new Random();
		int d=sc.nextInt();
		for(int i=0; i<26; i++){
			c[i]=sc.nextInt();
		}
		int[][] s=new int[d][26];
		for(int i=0; i<d; i++){
			for(int j=0; j<26; j++){
				s[i][j]=sc.nextInt();
			}
		}
		int maxSati=-1000000;
		int maxInd=-1;
		int[] ans=new int[d];
		TreeSet<Integer>[] memo=new TreeSet[26];
		for(int i=0; i<26; i++){
			memo[i]=new TreeSet<>();
			memo[i].add(0);
			memo[i].add(d+1);
		}
		//j:何日目
		int endSati=0;
		for(int j=0; j<d; j++){
			//i:どの大会をやるか
			for(int i=1; i<=26; i++){
				int sati=0;
				sati+=s[j][i-1];
				sati-=subSati(j+1,i-1);
				if(maxSati<sati){
					maxSati=sati;
					maxInd=i;
				}
			}
			ans[j]=maxInd;
			memo[maxInd-1].add(j+1);
			lastD[maxInd-1]=j+1;
			endSati+=maxSati;
			maxSati=-1000000;
			maxInd=-1;
		}
		long endTime=0;
		while(endTime-startTime<1500){
			int tmpd=rd.nextInt(d)+1;
			int tmpc=rc.nextInt(26)+1;
			int oldSati=endSati;
			endSati-=s[tmpd-1][ans[tmpd-1]-1];
			endSati+=s[tmpd-1][tmpc-1];
			endSati-=c[ans[tmpd-1]-1]*(tmpd-memo[ans[tmpd-1]-1].lower(tmpd))*(memo[ans[tmpd-1]-1].higher(tmpd)-tmpd);
			endSati+=c[tmpc-1]*(tmpd-memo[tmpc-1].lower(tmpd))*(memo[tmpc-1].higher(tmpd)-tmpd);
			if(oldSati<endSati){
				ans[tmpd-1]=tmpc;
				memo[ans[tmpd-1]-1].remove(tmpd);
				memo[tmpc-1].add(tmpd);
			}else{
				endSati=oldSati;
			}
			endTime = System.currentTimeMillis();
		}
		PrintWriter pw=new PrintWriter(System.out);
		for(int i:ans){
			pw.println(i);
		}
		pw.flush();
	}
	static int subSati(int d,int ii){
		int ret=0;
		for(int i=0; i<26; i++){
			if(i==ii) continue;
			ret+=c[i]*(d-lastD[i]);
		}
		return ret;
	}
}


Measured memory_bytes: 60364
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    const int MOD = 1e9 + 7;
    int n; cin >> n;
    vector<int> a(n); repeat(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    
    bool first = true;
    int ans = 1;
    if (n % 2 == 0) {
        int t = 1;
        repeat(i, n) {
            if (first) {
                if (a[i] == t) {
                    first = false;
                }
                else {
                    cout << 0 << endl;
                    return 0;
                }
            }
            else {
                if (a[i] == t) {
                    ans *= 2;
                    ans %= MOD;
                    first = true;
                    t += 2;
                }
                else {
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
        cout << ans << endl;
        return 0;
    }
    else {
        if (a[0] != 0) {
            cout << 0 << endl;
            return 0;
        }
        int t = 2;
        repeat_from(i, 1, n) {
            if (first) {
                if (a[i] == t) {
                    first = false;
                }
                else {
                    cout << 0 << endl;
                    return 0;
                }
            }
            else {
                if (a[i] == t) {
                    ans *= 2;
                    ans %= MOD;
                    first = true;
                    t += 2;
                }
                else {
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
        cout << ans << endl;
        return 0;
    }      
    return 0;
}
    

Measured memory_bytes: 640
import sys

n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
ans = 1
for i in a:
    if i == 0:
        print(0)
        sys.exit()
    ans *= i
    if ans > 10**18:
        print("-1")
        sys.exit()
print(ans)

Measured memory_bytes: 21600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  
///////

long long modinverse(long long a, long long b)
{
    long long b0 = b, t, q;
    long long x0 = 0, x1 = 1;
    if (b == 1) return 1;
    while (a > 1) {
        q = a / b;
        t = b, b = a % b, a = t;
        t = x0, x0 = x1 - q * x0, x1 = t;
    }
    if (x1 < 0) x1 += b0;
    return x1;
}
long long powerm(long long x, unsigned long long y, long long p) 
{ 
    long long res = 1;
    x = x % p;
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
} 

int fac[1000000];
int ifac[1000000];
signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,a,b,c;
	cin>>n>>a>>b>>c;
	int mo=1000000007;
	fac[0]=1;
	for(int i=1;i<1000000;++i)
		fac[i]=(i*fac[i-1])%mo;
	for(int i=0;i<1000000;++i)
	{
		ifac[i]=modinverse(fac[i],mo);
	}
	a*=modinverse(100,mo);
	a%=mo;
	b*=modinverse(100,mo);
	b%=mo;
	c*=modinverse(100,mo);
	c%=mo;
	int ans=0;
	int AB=1;
	int ia=modinverse(a,mo);
	int ib=modinverse(b,mo);
	int an=powerm(a,n,mo);
	int bn=powerm(b,n,mo);
	int apb=powerm(a+b,n,mo);
	apb=modinverse(apb,mo);
	int iapb=modinverse(a+b,mo);
	int pr=0;
	int tn;
	int ci=modinverse((1-c+mo)%mo,mo);
	for(int i=1;i<=n;++i)
	{
		tn=(((1+(a+b)*pr)%mo)*ci)%mo;
		pr=tn;
	}
	for(int i=0;i<=n-1;++i)
	{
		int r=1;
		r*=AB;
		r%=mo;
		r*=(an+bn)%mo;
		r%=mo;
		r*=apb;
		r%=mo;
		r*=fac[n+i-1];
		r%=mo;
		r*=ifac[n-1];
		r%=mo;
		r*=ifac[i];
		r%=mo;
		r*=tn;
		r%=mo;
ans+=r;
ans%=mo;
		tn=(((1+(a+b)*pr)%mo)*ci)%mo;
		pr=tn;
		apb*=iapb;
		apb%=mo;
		an*=ia;
		an%=mo;
		bn*=ib;
		bn%=mo;
		AB*=(a*b)%mo;
		AB%=mo;
	}
	cout<<ans;
}

Measured memory_bytes: 15872
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

ans = ["First", "Second"]

def main():
    s = input()
    if s[0] == s[-1]:
        print(ans[len(s)%2])
    else:
        print(ans[1-len(s)%2])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.awt.*;
import java.awt.geom.*;
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String args[]) {
    int ans[] = new int[125];
    int i;
    Scanner in = new Scanner(System.in);
    int num = in.nextInt();
    for(i = 0; i < num; i++){
      ans[i] = in.nextInt();
    }
    for(int k = i-1; k>=0; k--){
      if(k ==0) {
        System.out.print(ans[k]);
      } else {
        System.out.print(ans[k] + " ");
      }
    }
    System.out.println();
  }
}



Measured memory_bytes: 26392
n = int(input())
A = [int(input()) for i in range(n)]

M = max(A)
ind = A.index(M)
A[ind] = 0
M2 = max(A)


if M in A:
    for i in range(n):
        print(M)
else:
    for i in range(n):
        if A[i] == 0:
            print(M2)
        else:
            print(M)



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

const int N = 2e5;

int li[N+5];
int n;
int cari = 1;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&li[i]);
		if(li[i] == cari) cari++;
	}
	if(cari == 1){
		printf("-1\n");
		return 0;
	}
	printf("%d\n",n-cari+1);
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include<string.h>
 
int main()
{
    int n,i,T=0,H=0,f;
    char t[101],h[101];
    scanf("%d\n",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s%s",t,h);
        f=strcmp(t,h);
        if(f==0){T+=1;H+=1;}
        else if(f>0)T+=3;
        else H+=3;
    }
    printf("%d %d\n",T,H);
    return 0;
}


Measured memory_bytes: 2056
#include <stdio.h>

int main(){
    int A, B, C, ans;
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
    
    ans = C - (A - B);
    printf("%d", ((0 < ans)? ans : 0 ));
    
    return 0;
}

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

int main() {
  string s;
  cin>>s;
  set<char> cs;
  for (char c: s) {
    cs.insert(c);
  }
  if (cs.size() == 26) {
    cout<<"None"<<endl;
    return 0;
  }
  for (int i='a'; i<='z'; i++) {
    if (cs.find(i) == cs.end()) {
      cout<<(char)i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 512
import java.util.*;

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

        Queue<Long> que = new ArrayDeque<>();
        for (long i = 1; i <= 9; i++) {
            que.offer(i);
        }

        int count = 0;
        while(!que.isEmpty()) {

            long target = que.poll();
            count++;
            if (count == K) {
                System.out.println(target);
                break;
            }

            long shimohito = target % 10;
            if (shimohito == 0) {
                que.offer(target * 10);
                que.offer(target * 10 + 1);
            } else if (shimohito == 9) {
                que.offer(target * 10 + 8);
                que.offer(target * 10 + 9);
            } else {
                que.offer(target * 10 + shimohito - 1);
                que.offer(target * 10 + shimohito);
                que.offer(target * 10 + shimohito + 1);
            }
        }

    }
}


Measured memory_bytes: 45772
#include<stdio.h>

struct Node {int p,l,r; };
struct Node T[1000000];
int n;

void preParse(int u){
  if(u == -1) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==-1) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==-1) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}
  
int main(void)
{
    int i, v, l, r, root;
  
    scanf("%d", &n);
    for(i=0;i<n;i++) {
        T[i].p=-1;
    }
    for (i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].l=l;
        T[v].r=r;
        if(l!=-1) T[l].p=v;
        if(r!=-1) T[r].p=v;
    }
      
    for(i=0;i<n;i++){
      if(T[i].p==-1)root = i;
  }
  
    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
  
    return 0;
}


Measured memory_bytes: 2052
using System;
using System.Linq;

namespace AtCoderBeginnerContest177
{
	class Program
	{
		static void Main(string[] args)
		{
			var inputs = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();

			if (inputs[1] * inputs[2] >= inputs[0])
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}
		}
	}
}


Measured memory_bytes: 28128
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    if(s == "SUN"){
        cout << 7 << endl;
    }
    if(s == "MON"){
        cout << 6 << endl;
    }
    if(s == "TUE"){
        cout << 5 << endl;
    }
    if(s == "WED"){
        cout << 4 << endl;
    }
    if(s == "THU"){
        cout << 3 << endl;
    }
    if(s == "FRI"){
        cout << 2 << endl;
    }
    if(s == "SAT"){
        cout << 1 << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

s = sum(a)
m1 = s // n
m2 = -(-s // n)
ans1 = 0
ans2 = 0

for x in a:
    ans1 += (x - m1)**2
    ans2 += (x - m2)**2

print(min(ans1, ans2))

Measured memory_bytes: 38256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll N,X=0,Y=0;
  cin >> N;
  rep(i,N){
    ll A,B;
    cin >> A >> B;
    if(i==0){
      X=A;Y=B;
    }
    else{
      ll K=max((X-1)/A+1,(Y-1)/B+1);
      X=A*K;Y=B*K;
    }
  }
  cout << X+Y << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  vector<vector<int>> ans(h, vector<int>(w));
  int count = 1;
  rep(i, h) {
    rep(j, w) {
      if(s[i][j] == '#') {
        ans[i][j] = count;
        ++count;
      }
    }
  }
  rep(i, h) {
    int pre = 0;
    rep(j, w) {
      if(ans[i][j] == 0) {
        ans[i][j] = pre;
      } else {
        pre = ans[i][j];
      }
    }
  }

  rep(i, h) {
    int pre = 0;
    for (int j = w - 1; j >= 0; --j) {
      if(ans[i][j] == 0) {
        ans[i][j] = pre;
      } else {
        pre = ans[i][j];
      }
    }
  }

  vector<int> pre = ans[0];
  rep(i, h) {
    if(ans[i][0] == 0) ans[i] = pre;
    else pre = ans[i];
  }
  pre = ans[h - 1];
  for (int i = h - 1; i >= 0; --i) {
    if(ans[i][0] == 0) ans[i] = pre;
    else pre = ans[i];
  }
  rep(i, h) {
    rep(j, w) printf("%d%c", ans[i][j], (j == w - 1) ? '\n' : ' ');
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define xrep(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define vl vector<long long>
#define vs vector<string>

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

    bool ans = true;
    rep(i,N){
        if(A[i] % 2 == 0){
            if(A[i] % 3 != 0 && A[i] % 5 != 0){
                ans = false;
                break;
            }
        }
    }

    if(ans) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 3628
import collections
import bisect

n, m = map(int, input().split())#入力
s = [[int(_) for _ in input().split() ] for _ in range(m)]
a = collections.defaultdict(list)#「県」と「市の誕生順」を分けて管理

for x,y in sorted(s):#ソート⇒県の順番に並ぶ
    a[x]+=[y]
for x,y in s:
    z = bisect.bisect(a[x],y)#二分検索⇒市の誕生順に並ぶ
    print("%06d%06d"%(x,z))#形式を整えて出力

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

int main(){
    long long a,b,i=1;
    long long c;
    cin>>a>>b;

    while(true){
        c=a*i;
        if(c%b==0){
            cout<<c<<endl;
            return 0;
        }
        i++;
    }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    int n,m; cin>>n>>m;
    if(n>m) for(int i=0; i<n; i++) cout<<m;
    else for(int i=0; i<m; i++) cout<<n;
    cout<<endl;


    return 0;
}

Measured memory_bytes: 3596
#! python3

N = int(input())
a = [int(x) for x in input().split(' ')]
S = sum(a)
diff = abs(S - 2*a[0])
acc = a[0]
for x in a[1:-1]:
    acc += x
    if abs(S - 2*acc) < diff:
        diff = abs(S-2*acc)
print(diff)

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

string gen(int c, int len) {
	string r;
	rep(i, len) {
		r += c + '0';
	}
	return r;
}

int main(int argc, char const *argv[])
{
	int a, b; cin >> a >> b;
	string s1 = gen(a, b), s2 = gen(b, a);
	cout << (s1 < s2 ? s1 : s2) << endl;
	return 0;
}


Measured memory_bytes: 256
il = lambda: list(map(int, input().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
a = il()
dic = dict()
for i in a:
    for j in [-1, 0, 1]:
        if i+j in dic:
            dic[i+j] += 1
        else:
            dic[i+j] = 1
print(max(dic.values()))

Measured memory_bytes: 20684