akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 27 20:47:18 2019

@author: Owner
"""


import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*M
Y = [0]*M
for m in range(M):
    P[m], Y[m] = map(int, input().split())
    
all(nstr.count(c) for c in '753')
"""

N = int(input())
A = input()
B = input()
C = input()

result = 0

for n in range(N):
    if A[n] == B[n] and B[n] == C[n]:
        continue
    else:
        if A[n] == B[n] or B[n] == C[n] or C[n] == A[n]:
            result += 1
        else:
            result +=2
print(result)
                
            


Measured memory_bytes: 24784
#include <bits/stdc++.h>
using namespace std;
#include<algorithm>
int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int max = min(A, B);
	int min = A + B - N;
	cout << max << " ";
	if (min < 0)cout << 0<<endl;
	else cout << min << endl;
}


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

int main() {
	int n; int rank[6] = { 0,0,0,0,0,0 };
	double tmp;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		if (tmp < 165.)rank[0]++;
		else if (tmp >= 165.&&tmp < 170.)rank[1]++;
		else if (tmp >= 170.&&tmp < 175.)rank[2]++;
		else if (tmp >= 175.&&tmp < 180.)rank[3]++;
		else if (tmp >= 180.&&tmp < 185.)rank[4]++;
		else if (tmp >= 185.)rank[5]++;
	}

	for (int i = 0; i < 6; i++) {
		cout << i+1 << ":";
		for (int j = 0; j < rank[i]; j++) {
			cout << "*";
		}
		cout << endl;
	}
}


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

int main() {
  int n; cin >> n;
  vector<int> p(n);
  for (int& e: p) cin >> e;
  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
    if ((p.at(i - 1) < p.at(i) && p.at(i) < p.at(i + 1)) or (p.at(i - 1) > p.at(i) && p.at(i) > p.at(i + 1))) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;


int main(){
  
  int N;
  cin>>N;
  int d[300000];
  for(int i=0;i<N;i++){
    cin>>d[i];
  }
  int D[600000];
  for(int i=0;i<N*2-1;i++){
    if(i<N){
      D[i]=d[i];
    }
    if(i>=N){
      D[i]=d[N*2-i-2];
    }
  }
  int judge[600000];
  judge[0]=1;
  for(int i=1;i<N*2-1;i++){
    judge[i]=0;
  }
  int jump=0;
  for(int i=0;i<N;i++){
    if(i<=jump){
        judge[i]=1;
      }
    if(judge[i]==1){
      jump=max(jump,i+D[i]/10);
    }
  }
  if(judge[N-1]==1){
    for(int i=N-1;i<N*2-1;i++){
      if(i<=jump){
        judge[i]=1;
      }
      if(judge[i]==1){
        jump=max(jump,i+D[i]/10);
      }
    }
  }
  if(judge[N*2-2]==1){
    cout<<"yes"<<endl;
  }
  else{
    cout<<"no"<<endl;
  }
  
  /*int x,y;
  cin>>x>>y;
  int gcd=0;
  for(int i=1;i<=min(x,y);i++){
    if(x%i==0 && y%i==0){
      gcd=max(gcd,i);
    }
  }
  cout<<x+y+1-gcd<<endl;*/
  
  
  /*int a,b,N;
  cin>>a>>b;
  cin>>N;
  int s[100],f[100];
  for(int i=0;i<N;i++){
    cin>>s[i]>>f[i];
  }
  int judge=0;
  for(int i=0;i<N;i++){
      if(s[i]<=a && f[i]>a){
        judge=judge+1;
      }
      if(s[i]<b && f[i]>=b){
        judge=judge+1;
      }
      if(a<=s[i] && b>s[i]){
        judge=judge+1;
      }
      if(a<f[i] && b>=f[i]){
        judge=judge+1;
      }
  }
  if(judge==0){
    cout<<0<<endl;
  }
  else{
    cout<<1<<endl;
  }*/
  
 /* int X;
  cin>>X;
  if(X%7==0){
    cout<<"thu"<<endl;
  }
  if(X%7==1){
    cout<<"fri"<<endl;
  }
  if(X%7==2){
    cout<<"sat"<<endl;
  }
  if(X%7==3){
    cout<<"sun"<<endl;
  }
  if(X%7==4){
    cout<<"mon"<<endl;
  }
  if(X%7==5){
    cout<<"tue"<<endl;
  }
  if(X%7==6){
    cout<<"wed"<<endl;
  }
 */
	
	/*int m,f,b;
	cin>>m>>f>>b;
	if(b-m<=0){
		cout<<0<<endl;
	}
	if(b-m>0 && b-m<=f){
		cout<<b-m<<endl;
	}
	if(b-m>0 && b-m>f){
		cout<<"NA"<<endl;
	}*/
	/*int a,b;
	cin>>a>>b;
	cout<<(a+b)/2<<endl;*/
	
	/*random_device rnd;
	mt19937 mt(rnd());
	uniform_int_distribution<> rnd3(1, 3);
	
	string p1, p2, p3, p4;
	cin >> p1 >> p2 >> p3 >> p4;
	
	int t = rnd()%3;
	
	if(t == 0){
		cout << "1:" << p1 << ',' << p2 << endl;
		cout << "2:" << p3 << ',' << p4 << endl;
	}
	if(t == 1){
		cout << "1:" << p1 << ',' << p3 << endl;
		cout << "2:" << p2 << ',' << p4 << endl;
	}
	if(t == 2){
		cout << "1:" << p1 << ',' << p4 << endl;
		cout << "2:" << p2 << ',' << p3 << endl;
	}*/
	
	/*
	switch(type){
		case 0:
			cout << "1:" << p1 << ',' << p2 << endl;
			cout << "2:" << p3 << ',' << p4 << endl;
			break;
		case 1:
			cout << "1:" << p1 << ',' << p3 << endl;
			cout << "2:" << p2 << ',' << p4 << endl;
			break;
		case 2:
			cout << "1:" << p1 << ',' << p4 << endl;
			cout << "2:" << p2 << ',' << p3 << endl;
			break;
	}
	*/
	
	
	return 0;
}



Measured memory_bytes: 8968
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int x,ans;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> x;
	ans+=1000*(x/500);
	x%=500;
	ans+=5*(x/5);
	print1(ans);
	return 0;
}

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

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//template <typename T> using orderSet =
//tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000000000000018
#define mod 1000000007
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>

#define MX 200005

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

	string str;
	set <string> s;

	for(int i = 0; i < n; i++) {
		cin>>str;
		s.insert(str);
	}

	cout<<s.size()<<endl;
}


Measured memory_bytes: 19220
#include<stdio.h>

int selectionsort(int a[],int n){
	int i,j,minj,s,c=0;
	for(i=0;i<=n-1;i++){
		minj=i;
		for(j=i;j<=n-1;j++){
			if(a[j]<a[minj]){
				minj=j;
			}
		}
		s=a[i];
		a[i]=a[minj];
		a[minj]=s;
		if(i!=minj) c++;
	}
	return c;
}

int main()
{
	int i,n,a[100],c;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	c=selectionsort(a,n);
	
	for(i=0;i<n;i++){
		if(i>0) printf(" ");
		printf("%d",a[i]);
	}
	printf("\n%d\n",c);
	return 0;
}

Measured memory_bytes: 2716
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<" : "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}
template<class Type> void dline(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cerr<<' ';cerr<<elem;}cerr<<endl;}

int main(){
	int a,b;
	cin>>a>>b;
	
	//debug(a);
	//debug(b);
	
	if(a==b) cout<<"a == b"<<endl;
	else if(a>b) cout<<"a > b"<<endl;
	else cout<<"a < b"<<endl;
}



Measured memory_bytes: 3096
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;






int main(void) {
    int X;
    cin >> X;
    
    if( X <= 3 ) {
        cout << 1 << endl;
        return 0;
    }

    int m = 0;
    for( int i=2; i< 32; i++ ) {
        int t = i * i;
        while(t <= X){
            if( m < t ) {
                m = t;
            }
            t *= i;
        }
    }
    
    cout << m << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 25
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int n,D[MAX],H[MAX];

int setHeight(int u){
  int h1 = 0,h2 = 0;
  if(T[u].l != NIL){
    h1 = setHeight(T[u].l) + 1;
  }
  if(T[u].r != NIL){
    h2 = setHeight(T[u].r) + 1;
  }
  if(h1 > h2){
    H[u] = h1;
  }
  else H[u] = h2; 
  return H[u];
}

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

  return NIL;
}

void print(int u){
  int c = 0;
  printf("node %d: parent = %d, sibling = %d, ", u, T[u].p, getSibling(u));

  if(T[u].l != NIL) c++;
  if(T[u].r != NIL) c++;
  printf("degree = %d, ",c);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].p == NIL){
    printf("root\n");
  }
  else if(T[u].l == NIL && T[u].r == NIL){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}

void calcDepth(int u, int p){
  if(u == NIL) return ;
  D[u] = p;
  if(T[u].r != NIL) calcDepth(T[u].r,p+1);
  if(T[u].l != NIL) calcDepth(T[u].l,p+1);
}

int main(){
  int i, j, k, l;
  int root = 0;
  scanf("%d", &n);
  
  for(i=0; i < n;i++)T[i].p = NIL;

  for(i=0; i < n;i++){
    scanf("%d %d %d", &j, &k, &l);
    T[j].l = k;
    T[j].r = l;
    if(k != NIL)T[k].p = j;
    if(l != NIL)T[l].p = j;
  }

  //根を求める (find the root)
  for(i=0; i < n;i++){
    if(T[i].p == NIL) root = i;
  }

  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);
  setHeight(root);
//出力 (output)
  for(i=0; i < n;i++){
    print(i);
  }

  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll d; cin >> d;
    vector<P> p(26);
    rep(i,26){
        ll c; cin >> c;
        p[i].first = c;
        p[i].second = i;
    }

    sort(all(p)); reverse(all(p));
    vector<vector<ll>> g(d, vector<ll> (26));

    rep(i,d){
        rep(j,26){
            cin >> g[i][j];
        }
    }

    rep(i,39){
        cout << p[0].second + 1 << endl;
        cout << p[1].second + 1 << endl;
        cout << p[2].second + 1 << endl;
        cout << p[3].second + 1 << endl;        
    }
    rep(i,26){
        cout << p[i].second + 1 << endl;
    }
    rep(i,45){
        cout << p[0].second + 1 << endl;
        cout << p[1].second + 1 << endl;
        cout << p[0].second + 1 << endl;
        cout << p[1].second + 1 << endl;        
    }
    cout << p[0].second + 1 << endl;
    cout << p[1].second + 1 << endl;
    cout << p[2].second + 1 << endl;        

}

Measured memory_bytes: 3724
n=int(input())
a=[int(input()) for i in range(n)]
index=1
b=a[0]
cnt=0
if a[0]==2:
    print(1)
    exit()
for i in range(n):
    cnt+=1
    index=a[b-1]
    b=a[b-1]
    if index==2:
        cnt+=1
        print(cnt)
        exit()
print(-1)

Measured memory_bytes: 7084
#include<bits/stdc++.h>
using namespace std;
 
int main(){
long long int A,B,C,K;
cin>>A;
cin>>B;
cin>>C;
cin>>K;
if(K==0){
    cout<<0;
}
if(K<=A+B+C&&K>=1&&A>=0&&B>=0&&C>=0&&K>=0&&K<=2000000000&&A<=2000000000&&B<=2000000000&&C<=2000000000){
if(A!=0){
    if(B!=0){
        if(C!=0){
            if(K<=A){
                cout<<K;
            }
            else{
              if(B<(K-A)) {
                  cout<<A-(K-(A+B));
              } 
              else{
                  cout<<A;
              }
            }
        }
        else{
            cout<<A;
        }
    }
    else{
        if(C==0){
            cout<<K;
        }
        else{
            if(K>A){
                cout<<A-(K-A);
            }
            else{
                cout<<A;
            }
        }
    }
}
else{
    if(B!=0){
        if(C!=0){
            if(K>B){
                cout<<B-K;
            }
            else{
                cout<<0;
            }
        }
        else{
            cout<<0;
        }
    }
    else{
        if(C!=0){
            cout<< -(K);
        }
       
    }
}
}
return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(){
   int i,j,n,m,k[10],kk,l,s[10][10],ok[2048],nmax,b[11]={1,2,4,8,16,32,64,128,256,512,1024},p[10];
    
   scanf("%d %d",&n,&m);
   nmax=1;
   for (i=0;i<n;i++) nmax*=2;
   for (i=0;i<nmax;i++) ok[i]=1;
   for (i=0;i<m;i++) {
       scanf("%d",&k[i]);
       for (j=0;j<k[i];j++) {
          scanf("%d",&kk);
          s[j][i]=kk-1;
       }
   }
   for (i=0;i<m;i++) scanf("%d",&p[i]);
   for (i=0;i<m;i++)
       for (l=0;l<nmax;l++) 
          if (ok[l]) {
             kk=0;
             for (j=0;j<k[i];j++)
                 if ((l & b[s[j][i]])!=0) kk++;
             if (kk%2!=p[i]) ok[l]=0;
          }
   for (i=kk=0;i<nmax;i++)
      if (ok[i]) kk++;
   printf("%d\n",kk);
   return 0;
}


Measured memory_bytes: 128
#ABC105 B
#
#Nから7を順番に引いていき,4の倍数になったときに4以上になっているかどうかを判定すればよい
N = int(input())
if N%7 == 0:
	print('Yes')

else:
	while N%4 != 0:
		N = N - 7
	if N >= 4:
		print('Yes')
	else:
		print('No')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,wmax;
    cin >> n >> wmax;
    vi w(n), v(n);
    rep(i,n) cin >> w.at(i) >> v.at(i);
    // 個数制限がないので、計算量的には問題なさそう
    vvi vmax(n,vector<int64_t>(wmax+1, INF));
    rep(j,wmax+1){
        if(w.at(0)<=j){
            vmax.at(0).at(j) = v.at(0);
        }else{
            vmax.at(0).at(j) = 0;
        }
    }
    for(int64_t i=1; i<n; i++){
        rep(j,wmax+1){
            int64_t noaddValue = vmax.at(i-1).at(j);
            if(j-w.at(i) < 0){
                vmax.at(i).at(j) = noaddValue;
                continue;
            }
            int64_t addValue = vmax.at(i-1).at(j-w.at(i)) + v.at(i);
            vmax.at(i).at(j) = max(noaddValue, addValue);
        }
    }
    // rep(i,n){
    //     rep(j,wmax+1){
    //         cout << "j:" << j << "  vmax:" << vmax.at(i).at(j) << endl;
    //     }
    //     cout << endl;
    // }
    cout << vmax.at(n-1).at(wmax) << endl;
}

Measured memory_bytes: 79488
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,a,b;
    string s;
    ll yos = 0;
    ll kai=0;
    cin >> n >> a >> b >> s;
    for(int i=0;i<n;i++){
        if(s.at(i)=='b')kai++;

        if(s.at(i)=='a'&&yos<a+b){
            yos++;
            cout << "Yes" << endl;
        }
        else if(s.at(i)=='b'&&yos<a+b&&kai<=b){
            yos++;
            cout <<  "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<vector<int>> edge(N+1, vector<int>());
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> dist_a(N+1, -1), dist_b(N+1, -1);
    dist_a[1] = 0;
    dist_b[N] = 0;
    queue<pair<int, int>> q;
    q.push({1, 0});
    while(!q.empty()) {
        int now = q.front().first;
        int pre = q.front().second;
        q.pop();
        for (int nxt : edge[now]) {
            if (nxt == pre) continue;
            q.push({nxt, now});
            dist_a[nxt] = dist_a[now] + 1;
        }
    }
    
    q.push({N, 0});
    while(!q.empty()) {
        int now = q.front().first;
        int pre = q.front().second;
        q.pop();
        for (int nxt : edge[now]) {
            if (nxt == pre) continue;
            q.push({nxt, now});
            dist_b[nxt] = dist_b[now] + 1;
        }
    }
    
    int fe = 0, sn = 0;
    for (int i = 2; i <= N-1; i++) {
        if (dist_a[i] <= dist_b[i]) fe++;
        else sn++;
    }
    if (fe > sn) cout << "Fennec\n";
    else cout << "Snuke";
}

Measured memory_bytes: 6656
import math

a, b, h, m = map(int, input().split())
ht = (h*60+m)/360*math.pi
mt = m/30*math.pi
hx = a * math.sin(ht)
hy = a * math.cos(ht)
mx = b * math.sin(mt)
my = b * math.cos(mt)
print(math.sqrt((hx-mx)**2+(hy-my)**2))

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 212345;
vector<int> g[MAX_N];

int main2() {
  REP(i, MAX_N) g[i].clear();

  int N = nextInt();
  int M = nextInt();
  string s; cin >> s;

  set< pair<int,int> > vis;

  vector<int> degA(N), degB(N);
  REP(i, M) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    if (a > b) swap(a, b);
    if (vis.count({a, b})) continue;
    g[a].push_back(b);
    g[b].push_back(a);
    if (s[b] == 'A') degA[a]++; else degB[a]++;
    if (a != b) {
      if (s[a] == 'A') degA[b]++; else degB[b]++;
    }
  }

  vector<int> dead(N);
  queue<int> q;
  REP(i, N) {
    if (degA[i] == 0 || degB[i] == 0) {
      q.push(i);
      dead[i] = true;
    }
  }
  for (;!q.empty();) {
    int v = q.front(); q.pop();
    for (int u : g[v]) if (!dead[u]) {
      if (s[v] == 'A') {
        if (--degA[u] == 0) {
          dead[u] = true;
          q.push(u);
        }
      } else {
        if (--degB[u] == 0) {
          dead[u] = true;
          q.push(u);
        }
      }
    }
  }

  bool yes = false;
  REP(i, N) if (!dead[i]) yes = true;
  cout << (yes ? "Yes" : "No") << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 13444
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    ll ans = n / 2 + n % 2;

    cout << ans << endl;

    return 0;
}

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

std::string solve(int n, const std::string& s)
{
  if (s.size() % 2) return "No";

  for (std::size_t i = 0; i < s.size() / 2; ++i) {
    if (s[i] != s[i + s.size() / 2]) return "No";
  }

  return "Yes";
}

int main()
{
  int n;
  std::string s;
  std::cin >> n >> s;

  std::cout << solve(n, s) << std::endl;
}


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

int main() {
    int n; cin >> n;
    int d[n]; for (int i = 0; i < n; ++i) cin >> d[i];
    
    sort(d, d + n);

    int res = 0;
    res = max(res, d[n / 2] - d[n / 2 - 1]);

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
N, M = map(int, input().split())

if N >= M:
    print(0)
    quit()

x = list(map(int, input().split()))

x.sort()
interval = [0] * (M - 1)
for i in range(M - 1):
    interval[i] = x[i + 1] - x[i]

interval.sort(reverse=True)
ans = 0
if N != 1:
    for i in range(N - 1):
        ans += interval[i]
    print(sum(interval) - ans)
else:
    print(sum(interval))

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

#define MAX 2020
#define P 101

int table[MAX];
int idxs[P];

void move(int pid) {
    if (table[idxs[pid]+1] == 0 && idxs[pid]+1 <= 2019) {
        table[idxs[pid]] = 0; table[idxs[pid]+1] = 1;
        idxs[pid]++;
    }
}


int main()
{
    int N, M, tmp;
    for (int i = 0; i < 2020; i++) {
        table[i] = 0;
    }

    std::scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        std::scanf("%d", &tmp);
        idxs[i] = tmp;
        table[tmp] = 1;
    }

    std::scanf("%d", &M);
    for (int i = 0; i < M; i++) {
        std::scanf("%d", &tmp);
        move(tmp);
    }

    for (int i = 1; i <= N; i++) {
        std::printf("%d\n", idxs[i]);
    }



    return 0;
}



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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int w, h;

void dfs(vii &a, int ii, int jj, int d) {
  a[ii][jj] = d;
  rep (k, 8) {
    if (in(ii + dx2[k], 0, h) && in(jj + dy2[k], 0, w) && a[ii + dx2[k]][jj + dy2[k]] == -1) {
      dfs(a, ii + dx2[k], jj + dy2[k], d);
    }
  }
}

int main() {
  while (true) {
    cin >> w >> h;
    if (h == 0) return 0;
    vii a(h, vi(w));
    rep (i, h) {
      rep (j, w) {
        cin >> a[i][j];
        a[i][j] *= -1;
      }
    }

    int ans = 0;
    rep (i, h) {
      rep (j, w) {
        if (a[i][j] == -1) {
          ans++;
          dfs(a, i, j, ans);
        }
      }
    }

    cout << ans << endl;
    
  }
}



Measured memory_bytes: 3232
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:07/03/2020
*/
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
#define ld long double
#define ff first
#define ss string 
#define se second
#define alt(v) v.begin(),v.end()
#define pb emplace_back
#define mp make_pair
#define tc(t) cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fab(i,a,b) for(ll i=(a);i<(b);i++)
#define fba(i,a,b) for(ll i=(b);i>=(a);i--)
#define arr(i,n) fab(i,0,n)
ll max(ll a,ll b){if(a>b)return a;else return b;} 
ll min(ll a,ll b){if(a<b)return a;else return b;}
const ll inf=0x3f3f3f3f;




ll test=0;
void solve()
{

    ll n,c,x,ans=0,i,j,y;
    cin>>x>>y;
    for(i=1;i<=10000;i++)
    {
        if(i*8/100==x && i/10==y)
        {
            cout<<i<<endl;
            return;
        }
    }
    cout<<"-1"<<endl;

}








int main()
{
    fio;
    ll t=1,s;
    if(test)
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop,heapify
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
x = []
s = 0
s += a[0]
heappush(x,-a[1])
heappush(x,-a[1])
for i in range(2,n):
  y = heappop(x)
  s -= y
  heappush(x,-a[i])
  heappush(x,-a[i])
print(s)

Measured memory_bytes: 98864
#include <bits/stdc++.h>
#define i64 long long
#define N (int)(1e5)
#define pii pair<int,int>
#define L first 
#define R second
#define all(x) x.begin(),x.end()
using namespace std;
bool cmp(int val1,int val2){
	return val1>val2;
}
int main(){
	int n; cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(all(a),cmp);
	int sumA = 0, sumB =0;
	for(int i=0;i<n;i++){
		if(i&1) sumB+=a[i];
		else sumA+=a[i];
	}
	printf("%d\n", sumA-sumB);
	return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    var raw = input[0].split(" ");
    var N = parseInt(raw[0],10);
    var Y = parseInt(raw[1],10);
    var W = Y/1000;
    var flag = false;
    for(var z=0; z<=N; z++){
      var A = W-z
      if(A%5!==0) continue;
      var M = N-z;
      if(10*M >= A && A >= 5*M) {
        flag = true;
        var y = (10*M-A)/5;
        var x = M-y;
        console.log('%d %d %d',x,y,z);
        break;
      }
    }
    if(!flag) {
       console.log('%d %d %d',-1,-1,-1);
    }
    
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
/*
 *
 *	Author: r3gz3n
 *	Description: 
 *	Difficulty: 
 *
 */

#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define REP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define REPI(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define REPITER(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define pi 3.141592653589793

using namespace std;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y); }
template<class T> inline T mod(T x) { if(x < 0) return -x; else return x; }

typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;

const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(int argc, char* argv[])
{
	if(argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
	if(argc == 3) freopen(argv[2], "w", stdout);
	ios::sync_with_stdio(false);
	int x1, x2, y1, y2, x, y;
	string s = "";
	cin >> x1 >> y1 >> x2 >> y2;
	x = x1;
	y = y1;
	while(x < x2)
		x++, s += 'R';
	while(y < y2)
		y++, s += 'U';
	while(x > x1)
		x--, s += 'L';
	while(y > y1)
		y--, s += 'D';
	x = x1 - 1;
	y = y1;
	s += 'L';
	while(y <= y2)
		y++, s += 'U';
	while(x < x2)
		x++, s += 'R';
	y--;
	s += 'D';
	x++;
	s += 'R';
	while(y >= y1)
		y--, s += 'D';
	while(x > x1)
		x--, s += 'L';
	y++;
	s += 'U';
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int h, n; cin >> h >> n;
	int sum = 0;
	while(n--) {
		int a; cin >> a;
		sum += a;
	}
	if(sum >= h) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}
	return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;

const int dy[] = {0,0,1,-1};
const int dx[] = {1,-1,0,0};
int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;

	int red = 0;
	rep(i,n){
		red += (s[i] == 'R');
	}
	// 赤を数えました！！
	int ans = 0;
	for(int i = red; i < n; i++){
		if(s[i] == 'R') ans++;
	}
	cout << ans << endl;
}


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

#define ll long long
#define ld long double
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,a,b;
    cin >>  n >> a >> b;
    if (abs(a-n) > abs(b-n)){
        cout << "B" << endl;
    } else{
        cout << "A" << endl;
    }
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

int main() {
	ios_base::sync_with_stdio(false);
	ll N, P; cin >> N >> P;
	if (N == 1) {
		cout << P << endl;
		return 0;
	}
	ll ub = (ll)(pow(P, 1.0 / N) + 1);
	ll ans = 1;
	repr(i, 2, ub) {
		if (i > P) break;
		int n = 0;
		while (P % i == 0) {
			P /= i;
			n++;
		}
		if (n >= N) {
			int t = n / N;
			rep(k,t)ans *= i;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
n = int(input())
ans = ""
i = 0
if (n == 0):
    print(0)
    exit()
while (n != 0):
    tmp = 1 if (n % (2 ** (i+1)) != 0) else 0
    n -= (-2) ** i * tmp
    ans = str(tmp)+ans
    i+= 1
print(ans)

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

int main(){
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for (int i=0 ; i<m ; i++)
    cin >> b.at(i);
  vector<vector<int>> a(n, vector<int>(m));
  for (int i=0 ; i<n ; i++){
    for (int j=0 ; j<m ; j++)
      cin >> a.at(i).at(j);
  }
  
  int ans = 0;
  for (int i=0 ; i<n ; i++){
    int calc = c;
    for (int j=0 ; j<m ; j++)
      calc += a.at(i).at(j) * b.at(j);
    if (calc > 0)
      ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3612
n, k =map(int,input().split())
s = input()
x = s[k-1]
if x == "A":
  t = s[:k-1] + "a" + s[k:]
elif x == "B":
  t = s[:k-1] + "b" + s[k:]
else:
  t = s[:k-1] + "c" + s[k:]
print(t)

Measured memory_bytes: 3060
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <limits>
#include <math.h>
#include <string>
#include <map>

using namespace std;

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < n; ++i) {
    bool is_valid = true;
    for (int j = 0; j + i < n; ++j) {
      if (t[j] != s[j + i]) is_valid = false;
    }
    if (is_valid) {
      cout << n + i << endl;
      return 0;
    }
  }
  cout << 2 * n << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,a,b;
	cin>>n>>a>>b;
	string s;
	cin>>s;
	ll ja=0,ov=0;
	ll count=0;
	ll count1=0;
	for(ll i=0;i<n;i++)
	{
		if(s[i]=='a')
		{
			if(count<a+b)
			{
				count++;
				cout<<"Yes"<<endl;
			}
			else
			{
				cout<<"No"<<endl;
			}
		}
		else if(s[i]=='b')
		{
			if(count<a+b && count1<b)
			{
				count++;
				cout<<"Yes"<<endl;
				count1++;
			}
			else
			cout<<"No"<<endl;
		}
		else
		cout<<"No"<<endl;
	}
	return 0;
}

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

char a[205], b[205];

int main(){
	int k, ans;
	char *p, *q, *wp, *wq;
	char *s[3] = { "IDENTICAL", "CLOSE", "DIFFERENT" };

	while (scanf("%s", a) && a[0] != '.') {
		scanf("%s", b); p = a, q = b; ans = -1, k = 0;
		while (*p && *q) {
			if (*p != *q) { ans = 2; break; }
			if (*p == '"') { wp = ++p, wq = ++q;
				while (*p != '"') p++;
				while (*q != '"') q++;
				*p = *q = 0;
				k += 1 - (strcmp(wp, wq) == 0);
				if (k > 1) { ans = 2; break; }
			}
			p++, q++;
		}
		if (ans < 0) if (*p == *q) ans = k; else ans = 2;
		puts(s[ans]);
	}
	return 0;
}


Measured memory_bytes: 2104
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int x,a;
  cin >> x >> a;

  if ( x < a) cout << 0;
  else cout << 10;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
intt gcd(intt a, intt b) {return b ? gcd(b, a % b) : a;}
intt lcm(intt a, intt b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = ((res) * (a))%mod;
      a = ((a) * (a))%mod;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("ino.txt","r",stdin);
  freopen("onc.txt","w",stdout);
  #endif
}


int main(){

    //go();
    fast_io
    string s;cin>>s;
    intt ans=0;
    while(s.size()){
      ans+=(s[s.size()-1]-'0');
      s.pop_back();
    }
   // cout << s.size() <<'\n';
    if(ans%9)
      cout << "No" <<"\n";
    else
      cout << "Yes" <<"\n";
 
}



/*
3
17
4
*/






















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

#define hell 1000000007
#define PI acos(-1.0)
#define S second
#define F first
#define lli long long int
#define li long int
#define ld long double
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define run(j, n) for(auto ii=j;ii!=n;ii++)
#define out(j, n) for(auto ii=j;ii!=n;ii++) cout<<(*ii)<<" ";
#define L_MAX 1e16


int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << showpoint;
cout << setprecision(11);

/*
#ifndef ONLINE_JUDGE
freopen("inpute.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
*/

int t=1, x = 0;
//cin>>t;
while(t--)
{ 
  int n;cin>>n;
  lli ar[n];for(lli &x:ar) cin>>x;
  lli dp[n];for(lli &x:dp) x=1000;
  lli mx = 1000;
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<i;j++)
    {
      dp[i]=max(dp[i], mx);
       dp[i]=max(dp[i], (dp[j]-(dp[j]/ar[j])*ar[j])+(dp[j]/ar[j])*ar[i]);
       mx = max(dp[i], mx);
    }
  }
  cout<<dp[n-1];
} 


return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll S,W; cin >> S >> W;
  cout << (W >= S ? "unsafe" : "safe") << endl;
  return 0;
}


Measured memory_bytes: 3612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class HGrid1 {
        long mod = (long) 1e9 + 7;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int h = in.ni(), w = in.ni();
            char[][] grid = new char[h + 1][w + 1];
            long[][] pr = new long[h + 1][w + 1];
            for (int i = 1; i <= h; ++i) {
                String x = in.next();
                for (int j = 1; j <= w; ++j) {
                    grid[i][j] = x.charAt(j - 1);
                }
            }
            pr[1][1] = 1;
            for (int i = 1; i <= h; ++i) {
                for (int j = 1; j <= w; ++j) {
                    if (grid[i][j] == '.') {
                        pr[i][j] += (pr[i - 1][j] + pr[i][j - 1]) % mod;
                    }
                }
            }
            out.println(pr[h][w] % mod);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ni() {
            return Integer.parseInt(next());
        }

    }
}



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

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

	long long int t1, t2;
	long long int a1, a2, b1, b2;

	cin >> t1 >> t2;
	cin >> a1 >> a2;
	cin >> b1 >> b2;

	long long int d1 = (a1 - b1)*t1;
	long long int d2 = (a2 - b2)*t2;
	if(d1>0)
	{
 		d1 = -1*d1;
 		d2 = -1*d2;
	}

	if(d1+d2<0)
	{
		cout << 0 << '\n';
		return 0;
	}
	else if(d1+d2==0)
	{
		cout << "infinity" << '\n';
		return 0;
	}

	long long int res = -d1/(d1+d2);
	if((-d1)%(d1+d2)==0)
	{
		cout << 2*res << '\n';
	}
	else
	{
		cout << 2*res+1 << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int o=n%10;
  if(o==2 || o==4 || o==5 || o==7 || o==9){
  	cout << "hon";
  } 
  else if(o==0 || o==1 || o==6 || o==8){
  	cout << "pon";
  }
  else{
  	cout << "bon";
  }
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define mp make_pair
#define np next_permutation
#define pb push_back
#define all(x) (x.begin(),x.end())
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
 
#define fi first
#define se second 
using namespace std;
const int maxn=1e4+5;
const int maxl=26;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
int main()
{
	ios::sync_with_stdio(false); 
	string s;
	ull k;
	while(cin>>s>>k){
		int index=0;
		for(int i=0;i<s.length();i++){
			if(s[i]!='1'){
				index=i;
				break;
			}
		}
		if(k-1<index) cout<<1<<endl;
		else cout<<s[index]<<endl;
	}
}

Measured memory_bytes: 256