akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

string S;

int main(){
    cin>>S;
    int A,B,C,D;
    A=S[0]-'0';
    B=S[1]-'0';
    C=S[2]-'0';
    D=S[3]-'0';
    if(A+B+C+D==7){printf("%d+%d+%d+%d=7\n",A,B,C,D);}
    else if(A+B+C-D==7){printf("%d+%d+%d-%d=7\n",A,B,C,D);}
    else if(A+B-C+D==7){printf("%d+%d-%d+%d=7\n",A,B,C,D);}
    else if(A+B-C-D==7){printf("%d+%d-%d-%d=7\n",A,B,C,D);}
    else if(A-B+C+D==7){printf("%d-%d+%d+%d=7\n",A,B,C,D);}
    else if(A-B+C-D==7){printf("%d-%d+%d-%d=7\n",A,B,C,D);}
    else if(A-B-C+D==7){printf("%d-%d-%d+%d=7\n",A,B,C,D);}
    else if(A-B-C-D==7){printf("%d-%d-%d-%d=7\n",A,B,C,D);}
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  vector<vector<char>> r(h, vector<char>(w));
  rep(i, h) cin >> v[i];
  rep(i, h){
    rep(j, w){
      if(v[i][j] == '#') r[i][j] = '#';
      else{
        int c = 0;
        for(int k = max(0, i-1); k < min(h, i+2); ++k){
          for(int l = max(0, j-1); l < min(w, j+2); ++l){
            if(v[k][l] == '#') ++c;
          }
        }
        r[i][j] = '0' + c;
      }
    }
  }
  rep(i, h){
    rep(j, w) cout << r[i][j];
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
price_list = []
t = raw_input()
for i in range(int(t)):
    price_list.append(int(input()))
maxv = float("-inf")
minv = price_list[0]
for i in range(1, int(t)):
    maxv = max([maxv, price_list[i] - minv])
    minv = min([minv, price_list[i]])
print maxv

Measured memory_bytes: 18992
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD 1000000007
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  long long n,a,b;cin>>n>>a>>b;
  long long c = b-a;
  if(c%2){
    long long ans = min(b-1,n-a);
    ans = min(ans,(b-(a-1)+1)/2 + (a-1));
    ans = min(ans,(n-(a+(n-b+1)))/2 + (n-b+1));
    cout << ans << endl;
  }else{
    cout << c/2 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
#define chmax(x,y) x = max(x,y)

int a[3005][3005];
ll dp[3005][3005][4];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int R,C,n;
    cin >> R >> C >> n;
    rep(i,n){
        int r,c,v;
        cin >> r >> c >> v;
        a[r-1][c-1]=v;
    }

    rep(i,R)rep(j,C){
        for(int k=2;k>=0;--k){
            chmax(dp[i][j][k+1],dp[i][j][k]+a[i][j]);
        }
        rep(k,4){
            chmax(dp[i+1][j][0],dp[i][j][k]);
            chmax(dp[i][j+1][k],dp[i][j][k]);
        }
    }
    ll ans=0;
    rep(k,4) chmax(ans,dp[R-1][C-1][k]);
    cout << ans << "\n";
    return 0;
}   

Measured memory_bytes: 320552
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int r, g, b;
  scanf("%d %d %d", &r, &g, &b);
  int n = 10 * g + b;
  if(n % 4 == 0) printf("YES\n");
  else printf("NO\n");

  return 0;
}


Measured memory_bytes: 128
def main():
    N = int(input())
    a = map(int, input().split())
    d = {i: 0 for i in range(-1, 100001)}

    for i in a:
        d[i-1] += 1
        d[i] += 1
        d[i+1] += 1

    print(max(d.values()))

if __name__ == '__main__':
    main()


Measured memory_bytes: 22252
a1=[int(x) for x in input().split()]
a2=[int(x) for x in input().split()]
a3=[int(x) for x in input().split()]
n=int(input())
b=set()
for c in range(n):
    b.add(int(input()))
t=list(range(8))
t[1]=set(a1)
t[2]=set(a2)
t[3]=set(a3)
t[4]={a1[0],a2[0],a3[0]}
t[5]={a1[1],a2[1],a3[1]}
t[6]={a1[2],a2[2],a3[2]}
t[7]={a1[0],a2[1],a3[2]}
t[0]={a1[2],a2[1],a3[0]}

k=0
for c in range(8):
    if t[c]<=b:
        k=1
if k==1:
    print('Yes')
else:
    print('No')

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

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define INF 1e+18L
#define pb push_back
#define ll long long

int main()
{
    FASTIO
    int n;
    cin >> n;
    int val = 0;
    rep(i,1,n+1)
    {
        rep(j,1,n+1)
        {
            rep(k,1,n+1)
            {
                val += __gcd(__gcd(i,j), k);
            }
        }
    }
    cout << val;
    return 0;
}

Measured memory_bytes: 3652
//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;

//int→string
//string→int
//------------------------------------------
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();
}

//sqrt
//-------------------------------------------
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())
#define RSORT(c) sort((c).rbegin(),(c).rend())

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

//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() {

    int N; cin>>N;

    map<string, int> dict1;
    map<string, int> dict2;

    REP(i, N){
        string str; cin >> str;
        dict1[str]++;
    }

    int M; cin>>M;
    REP(i, M){
        string str; cin>>str;
        dict2[str]++;
    }

    int maxD = 0;

    for(auto itr = dict1.begin();itr!=dict1.end();itr++){
        string str = (*itr).first;
        int blue = (*itr).second;
        int red = dict2[str];

        if(maxD < blue- red){
            maxD = blue- red;
        }

    }

    cout<<maxD;

    return 0;
}















































Measured memory_bytes: 256
import bisect
a,b,c = map(int,input().split())

aa = []
bb = []
for i in range(a):
	aa.append(int(input()))
for i in range(b):
	bb.append(int(input()))
for i in range(c):
	cc = int(input())
	aaa = bisect.bisect_left(aa,cc)
	bbb = bisect.bisect_left(bb,cc)
	if aaa == 0 and bbb == 0:
		print(max(aa[0],bb[0]) - cc)
	elif aaa == a and bbb == b:
		print(cc - min(aa[a-1],bb[b-1]))
	elif aaa == 0:
		if bbb == b:
			print(min(abs(cc - aa[0]),abs(cc - bb[bbb-1])) + aa[0] - bb[bbb-1])
		else:
			aaaa = min(abs(bb[bbb] - aa[0])+min(abs(cc-aa[0]),abs(cc-bb[bbb])),abs(bb[bbb-1] - aa[0])+min(abs(cc-aa[aaa]),abs(cc-bb[bbb-1])))
			print(aaaa)
	elif bbb == 0:
		if aaa == a:
			print(min(abs(cc - aa[a-1]),abs(cc - bb[0])) + bb[0] - aa[aaa-1])
		else:
			bbbb = min(abs(bb[0] - aa[aaa-1])+min(abs(cc-aa[aaa-1]),abs(cc-bb[0])),abs(bb[0] - aa[aaa])+min(abs(cc-aa[aaa]),abs(cc-bb[0])))
			print(bbbb)
	elif aaa == a:
		aaaa = min(abs(bb[bbb] - aa[a-1])+min(abs(cc-aa[a-1]),abs(cc-bb[bbb])),abs(bb[bbb-1] - aa[a-1])+min(abs(cc-aa[a-1]),abs(cc-bb[bbb-1])))
		print(aaaa)
	elif bbb == b:
		bbbb = min(abs(bb[b-1] - aa[aaa-1])+min(abs(cc-aa[aaa-1]),abs(cc-bb[b-1])),abs(bb[b-1] - aa[aaa])+min(abs(cc-aa[aaa]),abs(cc-bb[b-1])))
		print(bbbb)
	else:
		aaaa = min(max(aa[aaa],bb[bbb])-cc,cc-min(aa[aaa-1],bb[bbb-1]),2*aa[aaa] - cc - bb[bbb-1],aa[aaa] + cc - 2 * bb[bbb-1],2*bb[bbb] - cc - aa[aaa-1],bb[bbb] + cc - 2 * aa[aaa-1])
		print(aaaa)


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

int a[7];

void move(char i){
int b[7];
for(int n=1;n<7;n++){b[n]=a[n];}

if(i=='W'){
a[6]=b[4];
a[4]=b[1];
a[1]=b[3];
a[3]=b[6];
}

if(i=='N'){
a[6]=b[5];
a[5]=b[1];
a[1]=b[2];
a[2]=b[6];
}

if(i=='E'){
a[6]=b[3];
a[3]=b[1];
a[1]=b[4];
a[4]=b[6];
}

if(i=='S'){
a[6]=b[2];
a[2]=b[1];
a[1]=b[5];
a[5]=b[6];
}

if(i=='R'){
a[3]=b[2];
a[2]=b[4];
a[4]=b[5];
a[5]=b[3];
}}



void move2(int m){
if(a[2]==m){move('N');}
if(a[3]==m){move('W');}
if(a[4]==m){move('E');}
if(a[5]==m){move('S');}
if(a[6]==m){move('N'); move('N');}
}

void move3(int l){
if(a[3]==l){move('R'); move('R'); move('R');}
if(a[4]==l){move('R');}
if(a[5]==l){move('R'); move('R');}
}


void move4(int l){
while(1){
if(a[2]!=l){move('R');}
else{break;}
}}




int main(){
int c[1000];
for(int n=1;n<7;n++){cin>>a[n]; c[n]=a[n];}
int x;
cin>>x;

for(int g=0;g<x;g++){
int y,z;
cin>>y>>z;
move2(y);
move4(z);
cout<<a[3]<<endl;
for(int n=1;n<7;n++){a[n]=c[n];}
}


return 0;
}


Measured memory_bytes: 3088
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
    cin>>b[i];
  int h=0;
  rep(i,a){
  rep(j,a){
  rep(k,a){
  if(i<j&&j<k){
  if(b[i]+b[j]>b[k]&&b[i]+b[k]>b[j]&&b[k]+b[j]>b[i]&&b[i]!=b[j]&&b[k]!=b[j]&&b[i]!=b[k]){
  h++;
  }
  }
  }
  }
  }
  out(h);
}

Measured memory_bytes: 3804
N=int(input())
res=N
for i in range(N+1):
    cc=0
    tmp=i
    while tmp>0:
        cc+=tmp%6
        tmp=tmp//6
    tmp=N-i
    while tmp>0:
        cc+=tmp%9
        tmp=tmp//9
    res=min(res,cc)
print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n;
char s[200010];

int nxt[200010][26];
int most[200010];
int dp[200010];

int main()
{
	scanf("%s", s);
	n=strlen(s);
	for(int i=0; i<26; ++i) nxt[n][i]=n;
	dp[n]=1;
	for(int i=n-1; 0<=i; --i){
		for(int j=0; j<26; ++j) nxt[i][j]=nxt[i+1][j];
		nxt[i][s[i]-'a']=i;
		most[i]=*max_element(nxt[i], nxt[i]+26);
		dp[i]=dp[most[i]+1]+1;
	}
	int ans=dp[0];
	int p=0;
	for(int i=0; i<ans; ++i){
		for(int j=0; j<26; ++j){
			if(i+dp[nxt[p][j]+1] != ans){
				putchar('a'+j);
				p=nxt[p][j]+1;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 22272
n=input()
s=raw_input().split()
a=[0 for i in range(n+3)]
b=[0 for i in range(n+3)]
sum=0
for i in range(1,n+1):
    a[i]=int(s[i-1])
b[1]=a[1]
for i in range(2,n+1):
    b[i]=b[i-1]+a[i]
ans=abs(b[n]-b[1]*2)
for i in range(2,n):
    ans=min(ans,abs(b[n]-2*b[i]))
print ans

Measured memory_bytes: 31212
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
	string s;
	cin >> s;
	for(char c:s)
		if(c == '7'){
			cout << "Yes" << endl;
			return 0;
		}

	cout << "No" << endl;
}


Measured memory_bytes: 3616
n=input()
def garden(a,h):
    if len(a)==0:
        return 0
    if len(a)==1:
        return a[0]-h
    m=min(a)
    i=a.index(m)
    return m-h+garden(a[:i],m)+garden(a[i+1:],m)
print(garden(list(map(int,input().split())),0))

Measured memory_bytes: 9140
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>=b)swap(a,b);
    if(b>=c)swap(b,c);
    if(a>=b)swap(a,b);
    cout<<a<<" "<<b<<" "<<c<<endl;
}



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

int main()
{
	int d, g; cin >> d >> g;
	
	vector<int> p(d), c(d); for (int i = 0; i < d; i++) cin >> p[i] >> c[i];

	int ans = 2147483647;
	for (int bit = 0; bit < (1<<d); bit++) {

		int tmp_score = 0;
		int tmp_ans = 0;
		int maxIndex;
		for (int i = 0; i < d; i++) {			

			if (bit & (1 << i)) {
				tmp_score += c[i] + 100 * (i + 1) * p[i];
				tmp_ans += p[i];
			}
			else {
				maxIndex = i;
			}

		}
		if (g <= tmp_score) {
			ans = min(ans, tmp_ans);
		}
		else {
			for (int i = 0; i < p[maxIndex] - 1; i++) {
				tmp_score += 100 * (maxIndex + 1);
				tmp_ans++;
				if (g <= tmp_score) {
					ans = min(ans, tmp_ans);
					break;
				}					
			}
		}
			
	}	

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

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

using namespace std;

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

	int n, x, t; cin >> n >> x >> t;
	cout << (n + x - 1)/x * t;    

  return 0;
}


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

struct Node {
    int key;
    Node* parent;
    Node* left;
    Node* right;
    Node(int key_in){
        key    = key_in;
        parent = NULL;
        left   = NULL;
        right  = NULL;
    }
};

class Tree {
    Node* root;
    void inorder(Node* n){
        if (n == NULL) return;
        inorder(n->left);
        cout << " " << n->key;
        inorder(n->right);
    }
    void preorder(Node* n){
        if (n == NULL) return;
        cout << " " << n->key;
        preorder(n->left);
        preorder(n->right);
    }
    void delete_node(Node* x){
        Node* child;
        if (x->left == NULL && x->right == NULL) {
            child = NULL;
        } else if (x->left != NULL) {
            child = x->left;
        } else {
            child = x->right;
        }
        if (x == root) {
            root = child;
            delete x;
            return;
        }
        Node* p = x->parent;
        if (x == p->left) {
            p->left = child;
        } else {
            p->right = child;
        }
        if (child != NULL) {
            child->parent = x->parent;
        }
        delete x;
    }
public:
    Tree(){
        root = NULL;
    }
    void insert(int key){
        Node* z = new Node(key);
        if (root == NULL) {
            root = z;
            return;
        }
        Node* x = root;
        while (1) {
            Node** child_p;
            if (key < x->key) {
                child_p = &(x->left);
            } else {
                child_p = &(x->right);
            }
            if (*child_p == NULL) {
                *child_p = z;
                z->parent = x;
                return;
            }
            x = *child_p;
        }
    }
    void print(){
        inorder(root);
        cout << endl;
        preorder(root);
        cout << endl;
    }
    Node* find(int key){
        for (Node* x = root; x != NULL;) {
            if (key == x->key) return x;
            if (key < x->key) {
                x = x->left;
            } else {
                x = x->right;
            }
        }
        return NULL;
    }


    Node* next_node(Node* x){
        if (x->left == NULL) return x;
        return next_node(x->left);
    }

    void delete_(int key){
        Node* x = find(key);
        if (x == NULL) return;
        if (x->left != NULL && x->right != NULL) {
            Node* y = next_node(x->right);
            x->key = y->key;
            x = y;
        }
        delete_node(x);
    }
};

int main(){
    int m;
    cin >> m;
    Tree T;
    for (int i = 0; i < m; i++) {
        string str;
        cin >> str;
        if (str == "print") {
            T.print();
            continue;
        }
        int num;
        cin >> num;
        if (str == "insert") {
            T.insert(num);
            continue;
        }
        if (str == "find") {
            if (T.find(num) == NULL) {
                cout << "no" << endl;
            } else {
                cout << "yes" << endl;
            }
            continue;
        }
        if (str == "delete") {
            T.delete_(num);
        }
    }
    return 0;
}

Measured memory_bytes: 21756
N=input()
L=list(map(int,input().split()))

items=0

while(L):

	if L[0]<L[1] :
		s_lg=L[0]
		lg=L[1]
	else:
		s_lg=L[1]
		lg=L[0]

	if len(L)>2:
		for i in range(2,len(L)) :
			if L[i]>=lg:
				s_lg=lg
				lg=L[i]
			elif L[i]>=s_lg :
				s_lg=L[i]

	items=items+s_lg

	L.remove(s_lg)
	L.remove(lg)	

print(items)	

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int high[100];
  int width[100];
  int i;
  int j;
  int count=0;
  int z;

  
  while(1){
  scanf("%d %d",&high[count],&width[count]);
  if(high[count] == 0 && width[count]==0) break;
  count++;
  }

  for(z=0;z<count;z++){
    for(i=0;i<high[z];i++){
      for(j=0;j<width[z];j++){
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2076
/*
      author : nishi5451
      created: 11.08.2020 21:44:09
*/

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


int main(){
    int a,b,t;
    cin >> a >> b >> t;
    cout << (t/a)*b << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#define DEBT 100000

int main(void) {
    int n, d = DEBT;
    for(scanf("%d", &n); n--;) {
        d = d * 105 / 100;
        d % 1000 && (d += 1000 - d % 1000);
    }
    printf("%d\n", d);
    return 0;
}

Measured memory_bytes: 588
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}

void m_sort(int a[], int tmp[], int left, int right);
void m_sort(int a[], int tmp[], int left, int right);
void sort(int a[], int total) {
	int tmp;
	for (int i = 0; i < total; i++) {
		for (int j = i + 1; j < total; j++) {
			if (a[i] < a[j]) {
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}

}

void mergeSort(int a[], int tmp[], int size)
{
	m_sort(a, tmp, 0, size - 1);
}
void merge(int a[], int tmp[], int left, int mid, int right)
{
	int i, left_end, num_elements, tmp_pos;

	left_end = mid - 1;
	tmp_pos = left;
	num_elements = right - left + 1; // 要素 

	while ((left <= left_end) && (mid <= right))
	{
		if (a[left] <= a[mid])
		{
			tmp[tmp_pos] = a[left];
			tmp_pos = tmp_pos + 1;
			left = left + 1;
		}
		else
		{
			tmp[tmp_pos] = a[mid];
			tmp_pos = tmp_pos + 1;
			mid = mid + 1;
		}
	}


	while (left <= left_end)
	{
		tmp[tmp_pos] = a[left];
		left = left + 1;
		tmp_pos = tmp_pos + 1;
	}

	while (mid <= right)
	{
		tmp[tmp_pos] = a[mid];
		mid = mid + 1;
		tmp_pos = tmp_pos + 1;
	}


	for (i = 0; i <= num_elements; i++)
	{
		a[right] = tmp[right];
		right = right - 1;
	}
}
void m_sort(int a[], int tmp[], int left, int right)
{
	int mid;

	if (right > left)
	{
		mid = (right + left) / 2;
		m_sort(a, tmp, left, mid);
		m_sort(a, tmp, mid + 1, right);

		merge(a, tmp, left, mid + 1, right);
	}
}


int H, W, ans, N,x,y,z, A,X[8002],Y,xnum,ynum, num,sum,B,now,chain[100000];
string s,t,tt,ss;
int a[100000], b[100000],amax,c[100000];

int main() {
	cin >> N>>H;
	amax = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
		amax = max(a[i], amax);
	}

	mergeSort(b, c, N);

	for (int i = N-1; i >=0; i--) {
		if (b[i] > amax) {
			ans++;
			H -= b[i];
		}
		else {
			break;
		}
		if (H <= 0) {
			cout << ans << endl;
			return 0;
		}
	}
	if (H%amax == 0) {
		ans += H / amax;
	}
	else {
		ans += (H / amax) + 1;
	}
	

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




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

#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, ss, ee) for (int i = (ss); i < (ee); ++i)

void solve() {
  int N, M;
  cin >> N >> M;
  dsu ds(N);

  rep(i, 0, M) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    ds.merge(u, v);
  }
  cout << ds.groups().size() - 1 << endl;
}

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

Measured memory_bytes: 8996
/**
		Rishabh Arora
*/
#include "bits/stdc++.h"
using namespace std;
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	if(a%2==0 || b%2==0 || c%2==0)
		cout<<0<<endl;
	else
	{
		long long arr[3];
		arr[0]=a;
		arr[1]=b;
		arr[2]=c;
		sort(arr,arr+3);
		cout<<arr[0]*arr[1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] nums = new int[N + 1];
        for (int i = 0; i < N; i++) {
        	nums[i] = sc.nextInt();
        }
        
        int count = 0;
        while (isAllOdd(nums)) {
        	for (int i = 0; i < N; i++) {
            	nums[i] = nums[i] / 2;
            }
            ++count;
        }
        System.out.println(count);
    }
  
    private static boolean isAllOdd(int[] nums) {
    	for (int i = 0; i < nums.length; i++) {
        	if (nums[i] % 2 != 0) {
            	return false;
            } 
        }
        return true;
    }
}

Measured memory_bytes: 23508
using System;
using System.Collections.Generic;

namespace ABC143C
{
    public class EmptyClass
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            char[] s = Console.ReadLine().ToCharArray();
            List<char> res = new List<char>();
            res.Add(s[0]);
            for (int i = 1; i < n; i++)
            {
                if (s[i]==res[res.Count-1])
                {
                    continue;
                }
                res.Add(s[i]);
            }
            Console.WriteLine(res.Count);
        }
    }
}


Measured memory_bytes: 13280
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    readInt()
    val a = readLongList()

    val counter = a.groupingBy { it }.eachCount().toMap()

    var ans = 0L
    counter.forEach {
        ans += it.value.toLong() * (it.value.toLong() - 1) / 2
    }

    a.forEach {
        println(ans - (counter[it]!! - 1))
    }
}


Measured memory_bytes: 89044
def solve(n):
    k = 1
    while k * (k + 1) < 2 * n:
        k += 1
    if k * (k + 1) != 2 * n:
        return False, [], -1
    ans = [[] for _ in range(1000)]
    add_num = 1
    ans[1].append(add_num)
    ans[0].append(add_num)
    for i in range(2, k + 1):
        for j in range(i):
            add_num += 1
            ans[i].append(add_num)
            ans[i - j - 1].append(add_num)
    return True, ans, k


def main():
    n = int(input())
    res, ans, k = solve(n)
    if res:
        print("Yes")
        print(k + 1)
        for a in ans:
            if a:
                print(len(a), " ".join(map(str, a)))
            else:
                break
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 13936
#include <stdio.h>

int main(void)
{
    char c[3];

    scanf("%c%c%c", &c[0], &c[1], &c[2]);
    for (int i = 0; i < 3; i++)
    {
        switch (c[i])
        {
        case '1':
            printf("9");
            break;
        case '9':
            printf("1");
            break;
        default:
            printf("%c", c[i]);
        }
    }
    printf("\n");

    return 0;
}


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

int main()
{
 std::string str;
 std::cin >> str;
 std::sort(str.begin(), str.end());
 for(int i = 0; i < str.size() - 1; i++){
  if(str[i] == str[i + 1]){
   std::cout << "no" << std::endl;
   return 0;
  }
 }
 std::cout << "yes" << std::endl;
 return 0;
}

Measured memory_bytes: 256
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    N = int(input())
    import collections
    p = collections.Counter(prime_factorize(N))
    l = list(p.values())
    ans = 0
    for i in range(len(l)):
        c = l[i]
        if(c == 1 or c == 2):
            ans += 1
            continue
        for j in range(c):
            if ((j * (j + 1)) // 2 == c):
                ans += j
                break
            elif ((j * (j + 1)) // 2 > c):
                ans += j - 1
                break
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
    string a;
    cin >> a;
    if (a == "SUN") {
        cout << 7 << endl;
    } else if (a == "MON") {
        cout << 6 << endl;
    } else if (a == "TUE") {
        cout << 5 << endl;
    } else if (a == "WED") {
        cout << 4 << endl;
    } else if (a == "THU") {
        cout << 3 << endl;
    } else if (a == "FRI") {
        cout << 2 << endl;
    } else if (a == "SAT") {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
int abs(int n){
	if(n<0)n=-n;
	return n;
}
int main(){
	int n;
	scanf("%d",&n);
	int a[n]={};
	int m=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(abs(a[m])<abs(a[i]))m=i;
	}
	printf("%d\n",2*n-1);
	if(a[m]>0){
		for(int i=0;i<n;i++){
			printf("%d %d\n",m+1,i+1);
		}
		for(int i=0;i<n-1;i++){
			printf("%d %d\n",i+1,i+2);
		}
	}else{
		for(int i=0;i<n;i++){
			printf("%d %d\n",m+1,i+1);
		}
		for(int i=n-1;i>0;i--){
			printf("%d %d\n",i+1,i);
		}
	}
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TOPSIC
{
    partial class Program
    {
        static void Main(string[] args)
        {
          string S = Console.ReadLine();
            string ans = "Yes";

            if (S[0] == S[1] && S[1] == S[2])
            {
                ans = "No";
            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 0
using namespace std;

vector<int> adj[200007];
int d1[200007];
int d2[200007];

void DFS1( int x, int p, int d)
{
    d1[x] = d;

    for( auto y:adj[x])
    {
        if( y==p)
            continue;
        DFS1( y, x, d+1);
    }
}

int maxi = 0;
int pp = 0;
void DFS2( int x, int p, int d)
{
    if( d >= d1[x])
    {
        return;
    }

    if( (d-d1[x])%2==1)
    {
        maxi = max( d1[x]-1, maxi);
    }
    else
    {
        maxi = max( d1[x]-1, maxi);
    }

    for( auto y:adj[x])
    {
        if( y==p)
            continue;
        DFS2( y, x, d+1);
    }
}

int main()
{
    int i,j;
    int N;
    int u,v;

    scanf("%d", &N);
    scanf("%d %d", &u, &v);
    for( i=0; i<N-1; i++)
    {
        int a,b;
        scanf("%d %d", &a, &b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    DFS1( v, v, 0);
    de(1)
    {
        for( i=1; i<=N; i++)
        {
            printf("%d>>> %d\n", i, d1[i]);
        }
    }
    DFS2( u, u, 0);
    printf("%d\n", maxi);

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/   \/_________/\/__/   \/__/
//


Measured memory_bytes: 12288
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 305;
int a[MAXN][MAXN];
bool avoid[MAXN][MAXN];

void solve(){
    int n; cin>>n;

    FOR(i,1,n) FOR(j,1,n) cin>>a[i][j];

    bool flag = true;
    FOR(i,1,n){
        FOR(j,1,n){
            FOR(k,1,n){
                if(a[i][k] + a[k][j] < a[i][j]){
                    flag = false;
                }
                if(k!=i && k != j) if(a[i][k] + a[k][j] == a[i][j]) avoid[i][j] = true;
            }
        }
    }

    if(!flag) cout<<-1<<endl;
    else {
        int ans = 0;
        FOR(i,1,n) FOR(j,1,n) if(!avoid[i][j]) ans += a[i][j];
        ans /= 2;
        cout<<ans<<endl;
    }
}

signed main(){

   FastRead;    

    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 1152
a, b, c, x, y = map(int, input().split())
z = min(x, y)
if a + b >= c * 2:
    print(min(c * z * 2 + a * (x - z) + b * (y - z), c * max(x, y) * 2))
else:
    print(a * x + b * y)

Measured memory_bytes: 3060
function main(input) {
  const fline: string = input.split('\n')[0];
  const sline: string[] = input.split('\n')[1].split(' ');
  const n: number = parseInt(fline.split(' ')[0], 10);
  const k: number = parseInt(fline.split(' ')[1], 10);
  const h: number[] = sline.map(x => parseInt(x, 10));
  
  let ans: number = 0;
  h.forEach(function(el) {
    if (el >= k) ans += 1;
  });
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 16704
import java.util.*;

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

    double ans = 0.0;
    for(int i=0; i<N; i++){
    x[i] = sc.nextDouble();
    u[i] = sc.next();

    if(u[i].equals ("BTC")){
        x[i]*=380000.0;
}
    ans += x[i];
}    
	System.out.println(ans);
      }
}


Measured memory_bytes: 37236
import java.util.Scanner;                                                               
 
class Main {
    public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            String str = new String();
            StringBuilder sb = new StringBuilder();
            int i =0 ;
            while(in.hasNext()) {
                        String buf = in.nextLine();
                    i++;
                    int j = Integer.parseInt(buf);
                    if (j == 0){
                    break;
                    }else{
                    sb.append("Case" + " " + i  + ":" + " " +  buf + "\n");
                    }

                    }
            System.out.print(sb);
        }
}

Measured memory_bytes: 66592
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;

void solve(){
    vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> n;
    cout << a[n-1] << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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


int main()
{
    int n,a,b;
    cin>>n;
    if(n==1)
    {
        cout<<"Hello World"<<endl;
    }
    else
    {
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);

const int m = 10e6;
using namespace std;


int main() {

   ll int tst,a,b,c,d;
   string s;
   cin>>s;
    if(s.back() == '3'){
            cout<<"bon"<<endl;
            return 0;
    }
    else if(s.back() == '0' ||  s.back()  == '1' || s.back()  == '6' || s.back()  == '8'){
        cout<<"pon"<<endl;
            return 0;
    }
cout<<"hon"<<endl;

       return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define GCD(a, b)       __gcd(a, b)
#define pi              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
using namespace std;

long long powerMod(long long number,long long power,long long mod)
{
    LL ret=0;

    if(power==0) return 1LL%mod;
    if(power==1) return number%mod;
    if(power%2==0)
    {
        ret=powerMod(number,power/2,mod);
        ret=(ret%mod*ret%mod)%mod;
        return ret%mod;
    }
    else
    {
        ret=powerMod(number,power/2,mod);
        ret=(ret%mod*ret%mod*number%mod)%mod;
        return ret%mod;
    }
}


int main()
{

    LL n;
    cin>>n;

    if(n%2==0)
    {
        cout<<n/2;
    }

    else
        cout<<((n/2)+1);



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include<cstdio>
#define ll long long int
#define mod 1000000007
#define pi 3.141592653589793
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define vfind(a, e) find(a.begin(), a.end(), e)
#define forr(i, n) for (ll i = 0; i < n; i++)
#define rfor(i, n) for (ll i = n - 1; i >= 0; i--)
#define fors(i, b, e, steps) for(ll i = b; i < e; i += steps)
#define rfors(i, e, b, steps) for(ll i = e; i > b; i -= steps)
#define mp make_pair
using namespace std;


bool isVowel(char c){
    return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}

bool isLower(char c){
    return 97 <= c && c <= 122;
}

void mul(ll a[2][2], ll b[2][2]) {
    ll p = a[0][0] * b[0][0] + a[0][1] * b[1][0];
    ll q = a[0][0] * b[0][1] + a[0][1] * b[1][1];
    ll r = a[1][0] * b[0][0] + a[1][1] * b[1][0];
    ll s = a[1][0] * b[0][1] + a[1][1] * b[1][1];

    a[0][0] = p % mod;
    a[0][1] = q % mod;
    a[1][0] = r % mod;
    a[1][1] = s % mod;
}



int main() {
    // cout << setprecision(30);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    ll n;
    cin >> n;
    string s;
    cin >> s;
    unordered_map<char, ll> d;
    for (char c : s) {
        d[c]++;
    }
    ll ans = 1;
    for (auto e : d) {
        ans *= (e.second + 1);
        ans %= mod;
    }

    cout << (ans - 1 + mod) % mod;
}





Measured memory_bytes: 512
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val w = readLine()!!.split(" ").map(String::toInt).toIntArray()

    var min = Integer.MAX_VALUE
    for (t in 0 .. n - 2) {
        val s1 = w.filterIndexed { index, i -> index <= t }.sum()
        val s2 = w.filterIndexed { index, i -> index > t }.sum()
        min = Math.min(min, Math.abs(s1 - s2))
    }
    println(min)
}


Measured memory_bytes: 36108
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
    int n,d,a;
    cin>>n>>d>>a;
    vector<pair<int,int>> p(n);
    for(auto& e:p)cin>>e.first>>e.second;
    sort(p.begin(),p.end());
    vector<int> s(n+1);
	int r=0;
    long long ans=0;
    rep(i,n){
        p[i].second-=s[i];
        while(r<n&&p[r].first<=p[i].first+2*d)++r;
        if(p[i].second>0){
            int num=(p[i].second+a-1)/a;
            ans+=num;
            s[i]+=num*a;
            s[r]-=num*a;
        }
        s[i+1]+=s[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
typedef long long ll;
#define abs(x) ((x) > 0 ? (x) : -(x))

int
main(int argc, char *argv[])
{
  int n; char s[100000] = {};
  scanf("%d", &n);
  int i = 0;
  if(n == 0) printf("0\n");
  else{
    while(n != 0){
      s[i++] = '0' + abs(n % 2);
      n = (n - abs(n % 2)) / (-2);
    }
    for(int j = 0; j < i; j++){
      printf("%c", s[i - 1 - j]);
    }
    printf("\n");
  }
  return 0;
}
     

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

import static java.lang.Integer.parseInt;

/**
 * Perfect Number
 */
public class Main {

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

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int N = parseInt(line);
			if (N == 0) break;

			int sum = 0;

			for (int i = 1; i * i <= N; i++) {
				if (N % i == 0) {
					if (i * i == N) sum += i;
					else sum += i + N / i;
				}
			}

			sum -= N;

			if (N == sum) System.out.println("perfect number");
			else if (N > sum) System.out.println("deficient number");
			else if (N < sum) System.out.println("abundant number");

		}
	}
}

Measured memory_bytes: 24900
import sys
input = sys.stdin.readline

H,W = list(map(int,input().split()))
t = '.'*(W+2)
camp = [t]
for h in range(H):
    camp.append('.' + input().rstrip() + '.')
camp.append(t)

for h in range(1,H+1):
    for w in range(1,W+1):
        if camp[h][w] == '#':
            if camp[h][w-1] != '#' and camp[h][w+1] != '#' and camp[h-1][w] != '#' and camp[h+1][w] != '#':
                print('No')
                exit()
print('Yes')


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

const int N = (int) 5e3 + 5;

int n;
char s[N];
long long h[N], power[N];
set <long long> myset;
set <long long> :: iterator it;
map <long long, vector <int> > f;

long long get(int i, int j) {
	return h[j] - h[i - 1] * power[j - i + 1];
}

bool check(int len) {
	for (int i = 1; i + len - 1 <= n; i++) {
		long long has = get(i, i + len - 1);
		f[has].push_back(i);
		myset.insert(has);
	}
	for (it = myset.begin(); it != myset.end(); it++) {
		long long v = *it;
		sort(f[v].begin(), f[v].end());
		if (f[v].size() <= 1) continue;
		int x1 = f[v][0];
		int x2 = f[v][f[v].size() - 1];
		if (x1 + len <= x2) {
			for (it = myset.begin(); it != myset.end(); it++) { 
				f[*it].clear();
			}
			myset.clear();
			f.clear();
			// cout << v << " " << x1 << " " << x2 << " " << len << endl;;
			return true;
		}
	}
	for (it = myset.begin(); it != myset.end(); it++) { 
		f[*it].clear();
	}
	myset.clear();
	f.clear();
	return false;
}

int main() {
	scanf("%d", &n);
	scanf("%s", s + 1);
	// cout << s + 1 << endl;
	for (int i = power[0] = 1; i <= n; i++) power[i] = power[i - 1] * 31;
	for (int i = 1; i <= n; i++) h[i] = h[i - 1] * 31 + s[i] - 'a';
	int left = 1, right = n, mid, ans = 0;
	while (left <= right) {
		mid = (left + right) >> 1;
		if (check(mid)) {
			left = mid + 1;
			ans = mid;
		} else {
			right = mid - 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
using namespace std;
char s[3412];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            scanf("%s",s);
            if(s[0]=='s'&&s[1]=='n'&&s[2]=='u'&&s[3]=='k'&&s[4]=='e')
                return printf("%c%d\n",'A'+j-1,i),0;

        }
}

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

using namespace std;

#define ll long long
#define INF 1000000001
#define MAX_VALUE 100001

int main(){
  int n;
  ll w;
  cin >> n >> w;
  
  ll con[n + 1][MAX_VALUE];
  for(int i = 0; i < n + 1; i++){
    for(int j = 0; j < MAX_VALUE; j++){
      con[i][j] = INF;
    }
  }
  
  con[0][0] = 0;
  
  for(int i = 0; i < n; i++){
    ll u;
    int v;
    cin >> u >> v;
    for(int j = 0; j < MAX_VALUE; j++){
      if(j >= v){
        con[i + 1][j] = min(con[i + 1][j], con[i][j - v] + u);
      }
      con[i + 1][j] = min(con[i + 1][j], con[i][j]);
    }
  }
  
  for(int j = MAX_VALUE - 1; j >= 0; j--){
    if(con[n][j] <= w){
      cout << j << endl;
      break;
    }
  }
  
  return 0;
}


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

int main(){
int N, D, X;  cin >> N >> D >> X;
vector<int> A(N);
for (int i = 0; i < N; i++) {
    cin >> A[i];
}
int eat = 0;
for (int i = 0; i < N; i++) {
    int count = 0;
    for (int j = 1; j <= D; j++) {
        if (j == count*A[i] + 1) {
            eat++;
            count++;
        }
    }
}
cout << eat + X << endl;
}


Measured memory_bytes: 256
def main():
  import sys
  b=sys.stdin.buffer
  h,w=map(int,b.readline().split())
  x=w+1
  s=[c>>3for c in b.read()]
  dp=[10000]*h*x
  a=p=s[0]
  dp[0]=b=q=5-a
  for i in range(w):
    t=s[i]
    b+=a^t
    dp[i]=b
    a=t
  for i in range(x,h*x,x):
    t=s[i]
    q+=p^t
    dp[i]=b=q
    a=p=t
    for j in range(i+1,i+w):
      sj=s[j]
      b+=a^sj
      k=j-x
      t=dp[k]+(s[k]^sj)
      if b>t:b=t
      dp[j]=b
      a=sj
  print(b+1>>1)
main()

Measured memory_bytes: 3188