akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;

  int A[60][60];
  for (int i = 0; i < H; ++i) {
    string S;
    cin >> S;
    for (int j = 0; j < W; ++j) {
      A[i][j] = S[j];
    }
  }

  for (int h = 0; h < H; ++h) {
    for (int w = 0; w < W; ++w) {
      if (A[h][w] == '#') {
        cout << '#';
        continue;
      }

      int count = 0;
      for (int y = max(0, h-1); y <= min(H-1, h+1); ++y) {
        for (int x = max(0, w-1); x <= min(W-1, w+1); ++x) {
          if (A[y][x] == '#') ++count;
        }
      }
      cout << count;
    }
    cout << endl;
  }


  return 0;
}


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

int main() {
vector<int> x(5);
rep(i,5) cin >> x.at(i);
int k;
cin >> k;
bool ans = false;
rep(i,5){
  rep(j,i){
 
    if(abs(x.at(i)-x.at(j)) > k) ans = true;
  }
}
puts(!ans?"Yay!":":(");
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int w;
  cin >> w;
  cout << w * 32 << endl;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef long long ll;

int main() {
	int n; cin>>n;
	vector<ii> points;
	set<ii> s;
	for (int i=0; i<n; i++) {
		int a, b; cin>>a>>b;
		points.emplace_back(a, b);
		s.emplace(a, b);
	}
	int maxSaved=0;
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			if (i==j) continue;
			int dx=points[i].first-points[j].first;
			int dy=points[i].second-points[j].second;
			int saved=0;
			for (int k=0; k<n; k++) {
				ii p=points[k], target={p.first+dx, p.second+dy};
				if (s.find(target)!=s.end())
					saved++;
			}
			maxSaved=max(saved, maxSaved);
		} 
	}
	cout<<n-maxSaved<<'\n';
	return 0;
}


Measured memory_bytes: 256
// 解説を読んだ
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];
    vector<ll> sum(n+1);
    sum[0] = 0;
    for(int i = 0; i < n; i++)  sum[i+1] = sum[i] + v[i];
    auto f = [&](int l, int r)->ll{
        return sum[r] - sum[l-1];
    };
    ll ans = 1ll<<60;
    int le = 1, ri = 3;
    for(int center = 2; center <= n-2; center++){
        ll diff = abs(f(1, le)-f(le+1, center));
        while(true){
            ll tmp = abs(f(1,le+1)-f(le+2, center));
            if(diff > tmp){
                diff = tmp;
                le++;
            }else{
                break;
            }
        }
        diff = abs(f(center+1, ri)-f(ri+1, n));
        while(true){
            ll tmp = abs(f(center+1, ri+1)-f(ri+2, n));
            if(diff > tmp){
                diff = tmp;
                ri++;
            }else{
                break;
            }
        }
        ll a = f(1, le), b = f(le+1, center), c = f(center+1, ri), d = f(ri+1, n);
        ans = min(ans, max({a,b,c,d})-min({a,b,c,d}));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main(void) {
	
	int A,B;
	char op;
	long int res;
	
	scanf("%d %c %d",&A,&op,&B);
	if(op=='+'){
		res = A + B;
	}else if(op == '-'){
		res = A - B;
	}else{
		printf("op is error\n");
	}
	printf("%ld\n",res);
	
	return 0;
}


Measured memory_bytes: 128
/*
// Sample code to perform I/O:

cin >> name;                            // Reading input from STDIN
cout << "Hi, " << name << ".\n";        // Writing output to STDOUT

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/

// Write your code here


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define  mod 1000000007 

int main(){
  ll n;
  cin>>n;
  ll ans=(n*(n+1))/2;
  for(int i=3;i<=n;i+=3)
  ans-=i;
  for(int i=5;i<=n;i+=5)
  ans-=i;
 for(int i=15;i<=n;i+=15)
  ans+=i;
  cout<<ans;
  
  
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;


int main(){

	int yoko[10][10];
	int tate[10][10];
	for(int i = 0; i < 5; i++){
		for(int j = 0; j < 4; j++){
				char c;
				cin>>c;
				yoko[i][j]=c-'0';
		}
		if(i!=4){
			for(int j = 0; j < 5; j++){
				char c;
				cin>>c;
				tate[i][j]=c-'0';
			}
		}
	}
	cout<<'R';
	int cx=1;
	int cy=0;

	// 0:E,1:º,2:¶,3:ã
	int angle=0;
	while(1){
		int nx=cx;
		int ny=cy;
		if(angle==0){

			nx=cx+1;
			ny=cy;
			if(cy!=0&&tate[cy-1][cx]){
				angle=3;
				cy--;
				cout<<"U";
			}
			// Çª éÈç
			else if(nx>=0&&ny>=0&&ny<5&&nx<5&&yoko[cy][cx]){
				cy=ny;
				cx=nx;
				cout<<'R';
			}
			// È¢ÈçAü«ðÏX
			else if(tate[cy][cx]){
				angle=1;
				cout<<"D";
				cy++;
			}
			else{
				angle=2;
				cout<<"L";
				cx--;
			}
		}
		else if(angle==1){
			nx=cx;
			ny=cy+1;
			// EÌÇðDæ
			if(cx!=4&&yoko[cy][cx]){
				cx++;
				cout<<"R";
				angle=0;
			}
			// Çª éÈç
			else if(nx>=0&&ny>=0&&ny<5&&nx<5&&tate[cy][cx]){
				cy=ny;
				cx=nx;
				cout<<'D';
			}
			// È¢ÈçAü«ðÏX
				// ¶
			else if(cx!=0&&yoko[cy][cx-1]){
				cx--;
				cout<<"L";
				angle=2;
			}
			// ÍñÄñ
			else{
				cy--;
				cout<<'U';
				angle=3;
			}
		}
		// ¶
		else if(angle==2){
			nx=cx-1;
			ny=cy;
			// ºÌÇªDæ
			if(cy!=4&&tate[cy][cx]){
				cout<<'D';
				cy++;
				angle=1;
			}
			// Çª éÈç
			else if(nx>=0&&ny>=0&&ny<5&&nx<5&&yoko[cy][cx-1]){
				cy=ny;
				cx=nx;
				cout<<'L';
			}
			// È¢ÈçAü«ðÏX
			// ã
			else if(cy!=0&&tate[cy-1][cx]){
				cout<<'U';
				angle=3;
				cy--;
			}
			// ÍñÄñ
			else{
				cout<<'R';
				angle=0;
				cx++;
			}
		}
		// ã
		else if(angle==3){
			nx=cx;
			ny=cy-1;
			// Çª éÈç
			// ¶ÌÇðDæ
			if(cx!=0&&yoko[cy][cx-1]){
				cout<<'L';
				angle=2;
				cx--;
			}
			else if(nx>=0&&ny>=0&&ny<5&&nx<5&&tate[cy-1][cx]){
				cy=ny;
				cx=nx;
				cout<<'U';
			}
			// È¢ÈçAü«ðÏX
			// E
			else if(cx!=4&&yoko[cy][cx]){
				angle=0;
				cout<<'R';
				cx++;
			}
			// ÍñÄñ
			else{
				cout<<'D';
				cy++;
				angle=1;
			}
	   }
		if(cx==0&&cy==0)
			break;
	}
	cout<<endl;
	
	return 0;
}

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

int func(int r, int x, int D){
  return r * x - D;
}

int main(){
  int r; scanf("%d", &r);
  int D; scanf("%d", &D);
  int x; scanf("%d", &x);
  int i;

  for(i = 0; i < 10; i++){
    x = func(r, x, D);
    printf("%d\n", x);
  }
  
  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int n;
	cin>>n;
	cout<<(n-1)/2<<endl;
	return 0;
}

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

static const int ds = 6;

void dbigsort( int a[], int i0, int i1, int i2, int i3 ) {
	int ta[] = { a[i0], a[i1], a[i2], a[i3] };
	int max = ta[0];
	for( int i = 0; i < 4; i++ ) {
		if( max < ta[i] ) {
			max = ta[i];
		}
	}

	int t = 0;
	while( true ) {
		if( a[i0] == max ) {
			break;
		}
		t = a[i0];a[i0]=a[i1];a[i1]=a[i2];a[i2]=a[i3];a[i3]=t;
	}

	return;
}

bool dcomp( int a[], int b[] )
{
	for( int i = 0; i < ds; i++ ) {
		if( a[i] != b[i] ) {
			return false;
		}
	}

	return true;
}

int main()
{
	int dx[ds], dy[ds];

	for( int i = 0; i < ds; i++ ) {
		cin >> dx[i];
	}
	dbigsort( dx, 0, 1, 5, 4 );
	dbigsort( dx, 0, 3, 5, 2 );
	dbigsort( dx, 1, 2, 4, 3 );

	for( int i = 0; i < ds; i++ ) {
		cin >> dy[i];
	}
	dbigsort( dy, 0, 1, 5, 4 );
	dbigsort( dy, 0, 3, 5, 2 );
	dbigsort( dy, 1, 2, 4, 3 );

	bool ret = false;
	ret = dcomp( dx, dy );
	cout << ( ret?"Yes":"No" ) << endl;

	return 0;
}


Measured memory_bytes: 3124
h,w=list(map(int,input().split()))
m=[]
for i in range(h):
  mm=[]
  for j in input():
    mm.append(1 if j=="#" else 0)
  m.append(mm)

wl=[[0 for i in range(w)]for j in range(h)]
for i in range(h):
  s=0
  t=0
  while t<w:
    while t<w and m[i][t]==0:
      t+=1
    for j in range(s,t):
      wl[i][j]=t-s
    s=t+1
    t=t+1
mx=0
for i in range(w):
  s=0
  t=0
  while t<h:
    while t<h and m[t][i]==0:
      t+=1
    for j in range(s,t):
      k=wl[j][i]
      if mx<k+t-s:
        mx=k+t-s
    s=t+1
    t=t+1


print(mx-1)


Measured memory_bytes: 140968
import numpy as np
a, b, x = map(int,input().split())
if x == 0:
    print(90)
elif a * a * b * (1 / 2) >= x:   
    l = (2 * x) / (a * b)
    print(180 / np.pi * np.arctan(b / l))
else:
    l = (2 * (a * a * b - x)) / (a * a)
    print(180 / np.pi * np.arctan(l / a))

Measured memory_bytes: 12420
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };


int main() {
	int n, d[3];
	scanf( "%d", &n );
	while ( n-- ) {
		for ( int i = 0; i < 3; i++ ) {
			scanf( "%d", &d[ i ] );
		}
		sort( d, d + 3 );
		printf( "%s\n", sq( d[ 0 ] ) + sq( d[ 1 ] ) == sq( d[ 2 ] ) ? "YES" : "NO" );
	}
	return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>
int main()
{
int s1,s2,s3,s4,s5,s6,s7,s8,s9,s10;
int sum;
scanf("%d %d %d %d %d %d %d %d %d %d",&s1,&s2,&s3,&s4,&s5,&s6,&s7,&s8,&s9,&s10);
sum=s1+s2+s3+s4+s5+s6+s7+s8+s9+s10;
printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){
  std::string a;
  int n, b;
  int s[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
  int h[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
  int c[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
  int d[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};

  cin>>n;

  for(int j=0; j<n; j++){
    cin>>a>>b;
    if(a=="S"){
      s[b-1]=100;
    }else if(a=="H"){
      h[b-1]=100;
    }else if(a=="C"){
      c[b-1]=100;
    }else if(a=="D"){
      d[b-1]=100;
    }
  }


  for(int i=0; i<13; i++){
    if(s[i]!=100){
      cout<<"S"<<" "<<s[i]<<endl;
    }
  }

  for(int i=0; i<13; i++){
    if(h[i]!=100){
      cout<<"H"<<" "<<h[i]<<endl;
    }
  }

  for(int i=0; i<13; i++){
    if(c[i]!=100){
      cout<<"C"<<" "<<c[i]<<endl;
    }
  }

  for(int i=0; i<13; i++){
    if(d[i]!=100){
      cout<<"D"<<" "<<d[i]<<endl;
    }
  }
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    int n,k;
    cin >> n >> k;
    vector<int>h(n);
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    int ans = MOD;
    for(int i=0;i<=n-k;i++){
        int x=h[i+k-1]-h[i];
        ans=min(ans,x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
vvi E(10010);
ll n,k;
vector<pair<ll,pair<ll,ll>>> par;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>k;
  par.resize(n);
  for(int i=0;i<n+10;i++)par[i].S.S=INF;
  for(int i=0;i<n-1;i++){
    ll a,b;cin>>a>>b;
    E[--a].pb(--b);
    E[b].pb(a);
  }
  /*
  ll d=0;
  for(int i=0;i<n;i++){
    if(E[i].size()!=1)continue;
    queue<pair<ll,ll>>que;
    bool visited[10000]={};
    que.push(mp(i,0));
    ll cnt=0;
    while(que.empty()==false){
      pair<ll,ll>now=que.front();
      que.pop();
      for(int j=0;j<E[now.F].size();j++){
	if(visited[E[now.F][j]]==false){
	  visited[E[now.F][j]]=true;
	  que.push(mp(E[now.F][j],now.S+1));
	  cnt=max(cnt,now.S+1);
	}
      }
    }
    d=max(d,cnt);
    }*/
  ll ans=INF;
  if(k%2){
    for(int i=0;i<n;i++){
      for(int j=0;j<E[i].size();j++){
      bool vis[2010]={};
      queue<pair<ll,ll>>que;
      que.push(mp(i,0));
      que.push(mp(E[i][j],0));
      vis[i]=true;
      vis[E[i][j]]=true;
      ll cnt=0;
      while(!que.empty()){
	pair<ll,ll>now=que.front();
	que.pop();
	for(int j=0;j<E[now.F].size();j++){
	  if(vis[E[now.F][j]]==false){
	    vis[E[now.F][j]]=true;
	    cnt+=(now.S+1>((k-1)/2));
	    que.push(mp(E[now.F][j],now.S+1));
	  }
	}
      }
      ans=min(ans,cnt);
      }
    }
  }else{
    for(int i=0;i<n;i++){
      bool vis[2010]={};
      queue<pair<ll,ll>>que;
      que.push(mp(i,0));
      ll cnt=0;
      vis[i]=true;
      while(!que.empty()){
	pair<ll,ll>now=que.front();
	que.pop();
	for(int j=0;j<E[now.F].size();j++){
	  if(vis[E[now.F][j]]==false){
	    vis[E[now.F][j]]=true;
	    cnt+=(now.S+1>(k/2));
	    que.push(mp(E[now.F][j],now.S+1));
	  }
	}
      }
      ans=min(ans,cnt);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef long long int ll;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
ll combination(ll n) {
	ll nck[100][100];
	nck[0][0] = 1;
	for (int i = 1; i < 1 + n; i++) {
		nck[i][0] = nck[i][i] = 1;
			for (int j = 1; j < i; j++) {
				nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
			}
	}

}
//------------------変数-----------------------//
ll n, m, a, b, k, d, c;;
typedef pair<ll, ll> P;
vector<vector<ll>> way(2001), money(2001);
ll maxa = 0, moto = 0;
ll retu[11451] = {};
queue <ll>q;
ll bitmax = 0;
//-------------------関数----------------------//

int main() {
	cin >> n>>a;
	//cin>>a>>b>>c;
	//REP(i, n) { cin >> retu[i]; }
	cout << (n - 1)*(a - 1) << endl;


	return 0;
}

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

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


Measured memory_bytes: 3132
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

const int dy[] = { 0, 1, 0, -1 };
const int dx[] = { 1, 0, -1, 0 };

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

struct Point {
	double x, y;
};

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

	string s;
	cin >> s;

	int ans = 0,  cnt = 0;
	bool check = false;
	REP(i, s.size()) {
		if (check) {
			cnt++;
			if (s[i] == 'Z') {
				ans = max(ans, cnt);
			}
		} else if (s[i] == 'A') {
			cnt++;
			check = true;
		}
	}

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

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

int main(){
  string str;
  int n;
  string a="CODEFESTIVAL2016";
  cin>>str;
  int cnt=0;
  for(int i=0;i<a.size();i++){
    if(a[i]!=str[i])cnt++;
  }
  cout <<cnt<<endl;

  return 0;
}


Measured memory_bytes: 764
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		java.util.Scanner sin = new java.util.Scanner(System.in);
		int a = sin.nextInt();
		int b = sin.nextInt();
		int ans1, ans2;
		if(1 <= a && b <= 100){
			ans1 = a * b;
			ans2 = 2 * a + 2 * b;
			System.out.println(ans1 + " " +ans2);
		}
	}
}


Measured memory_bytes: 26356
import java.util.*;
    public class Main {
    	public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		String s = sc.next();
    		// 出力
                int len = s.length(); 
                
                String subs;
                int diff;
                int mindiff = 0;
                for (int i = 1; i <= len -2; i++){
                    subs = s.substring(i -1, i +2);
                    //System.out.println(subs);
                    diff = Math.abs(753 - Integer.parseInt(subs));
                    if (i == 1 || diff < mindiff) {
                        mindiff = diff;
                    }
                }
                System.out.println(mindiff);
    	}
    }

Measured memory_bytes: 22612
from itertools import combinations

n, a, q, ms, cache = int(input()), list(map(int, input().split())), input(), map(int, input().split()), {}


def sum_a(tmp, t):
    global a, cache
    if t in cache:
        return tmp + cache[t]
    elif len(t) == 1:
        return tmp + a[t[0]]
    else:
        cache[t] = result = sum_a(tmp + a[t[0]], t[1:])
        return result


l = set(sum_a(0, t) for i in range(n) for t in combinations(range(n), i + 1))

for m in ms:
    print('yes' if m in l else 'no')

Measured memory_bytes: 220828
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int H, W;
    cin >> H >> W;
    V(string) a(H);
    rep(i, H) cin >> a[i];

    rep(i, H+2) {
        if(i==0 || i==H+1) {
            rep(j, W+2) cout << '#';
            cout << endl;
        } else {
            string out = "";
            out += '#';
            out += a[i-1];
            out += '#';
            cout << out << endl;
        }
    }
    
    return 0;
}

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

int main()
{
	long long n,m,sum=0;
	cin>>n>>m;
	long long days[m+1];
	for(int i=1;i<=m;i++)
	{
		cin>>days[i];
	}
	for(int i=1;i<=m;i++)
	{
		sum+=days[i];
	} 
	if(sum<=n)
	  cout<<n-sum;
    else
      cout<<"-1";
	return 0;
} 

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


int main(){
    int a, b, c, x, y, ans = 0;
    cin >> a >> b >> c >> x >> y;

    ans += 2*c*min(x,y);
    ans += x < y ? b*(y-x) : a*(x-y);

    int extra = 2*c*max(x,y);

    cout << min({a*x + b*y, ans, extra}) << endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a[100005];
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int x=0;
	for(int i=0;i<n;i++){
		if(i%2==0){
			x+=a[i];
		}
		else{
			x-=a[i];
		}
	}
	cout<<x<<" ";
	for(int i=0;i<n-1;i++){
		cout<<2*(a[i]-x/2)<<" ";
		x=2*(a[i]-x/2);
	}
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 100010;
const int INF = 2147483600;
#define pii pair<int,int> 

int N; char s[MAXN+1],t[MAXN+1]; 
pii sx[MAXN+1],tx[MAXN+1];
int sc=0,tc=0;
#define mp make_pair
#define fr first
#define sn second
LL ret=INF;

inline void solve(){
	t[N+1]='2';
	sc=tc=0; 
	for(int i=0;i<=N;i++){
		if(!i) sx[++sc]=mp(0,(s[1]-'0')^1);
		else if(s[i]!=s[i+1]) sx[++sc]=mp(i,(s[i]-'0'));
	}
	for(int i=0;i<=N;i++){
		if(!i) tx[++tc]=mp(0,(t[1]-'0')^1);
		else if(t[i]!=t[i+1]) tx[++tc]=mp(i,(t[i]-'0'));
	}
	for(int i=1;i<=sc;i++) {
		if(sx[i].sn!=tx[1].sn) continue;
		int nows=i,nowt=1; LL ans=0;
		for(int j=1;j<i;j++) ans+=sx[j].fr;
		while(nowt<=tc&&nows<=sc){
			ans+=abs(tx[nowt].fr-sx[nows].fr);
			++nows; ++nowt;
		}
		while(nows<=sc) ans+=N-sx[nows].fr,++nows;
		while(nowt<=tc) ans+=N-tx[nowt].fr,++nowt;
		ret=min(ret,ans);
	} 
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(); scanf("%s",s+1); scanf("%s",t+1);
	for(int i=1;i<=N;i++) sc+=(s[i]!=s[i+1]);
	for(int i=1;i<=N;i++) tc+=(t[i]!=t[i+1]);
	if(sc<tc) swap(s,t); solve(); reverse(s+1,s+N+1); reverse(t+1,t+N+1); solve();
	cout<<ret<<endl;
	return 0;
}




Measured memory_bytes: 640
r,p=range,print
n,a,b=map(int,input().split())
if a+b>n+1or a*b<n:exit(p(-1))
l=[[]for i in r(b-1)]+[list(r(1,a+1))]
for i in r(a,n):l[-2-(i-a)%(b-1)]+=[i+1]
for i in l:p(*i,end=" ")

Measured memory_bytes: 37504
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll h,w,k;
ll dp[110][10];
ll fib[10];
int main(){
	for(int i=0;i<110;i++){
		for(int j=0;j<10;j++){
			dp[i][j]=0;
		}
	}
	dp[0][1]=1;
	fib[0]=1;
	fib[1]=2;
	for(int i=2;i<10;i++)fib[i]=fib[i-1]+fib[i-2];
	
	cin>>h>>w>>k;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			ll t=1;
			if(j!=w){
				if(j-2>=0){
					t*=fib[j-2];
				}
				if(w-j-2>=0){
					t*=fib[w-j-2];
				}
				dp[i][j+1]+=(dp[i-1][j]*t)%MOD;
				dp[i][j+1]%=MOD;
			}
			t=1;
			if(j!=0){
				if(j-3>=0){
					t*=fib[j-3];
				}
				if(w-j-1>=0){
					t*=fib[w-j-1];
				}
				dp[i][j-1]+=(dp[i-1][j]*t)%MOD;
				dp[i][j-1]%=MOD;
			}
			t=1;
			if(j-2>=0)
				t*=fib[j-2];
			if(w-j-1>=0)
				t*=fib[w-j-1];
			dp[i][j]+=dp[i-1][j]*t;
			dp[i][j]%=MOD;
		}
	}
	cout<<dp[h][k]<<endl;
	return 0;
}

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

int main() {
  int64_t n, k;
  std::cin >> n >> k;
  std::vector<int64_t> before, after;
  before.reserve(n + 1);
  after.reserve(n + 1);
  after.push_back(0);

  for (int64_t i = 0; i < n; i++) {
    int64_t tmp;
    std::cin >> tmp;
    if (tmp < 0) {
      before.push_back(-tmp);
    } else {
      after.push_back(tmp);
    }
  }
  before.push_back(0);
  std::reverse(before.begin(), before.end());

  int64_t time = 3e8;

  for (int64_t i = 0; i <= k; i++) {
    if (i < after.size() && k - i < before.size()) {
      time = std::min(2 * after[i] + before[k - i], time);
      time = std::min(after[i] + 2 * before[k - i], time);
    }
  }

  std::cout << time << std::endl;
  return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

ll calOL(vector<pii>& v){
	ll rtn =0;
	priority_queue<int> pq;
	int m = sz(v);
	vector<VI> kh(m+2);
	for(auto x: v) kh[min(x.first, m)].push_back(x.second);
	
	repr(i, m, 1) {
		for(auto w: kh[i]) pq.emplace(w);
		if(sz(pq)){
			rtn += pq.top();
			pq.pop();
		}
	}
	return rtn;
}

ll cal(vector<pii>& v){
	ll rtn =0;
	int m = sz(v);
	sort(v.rbegin(), v.rend());
	bitset<200001> bt;
	bt.set();
	
	rep(i, m) {
		int st = min(v[i].second, m);
		int ps = bt._Find_next(m-st);
		if(ps > m) continue;
		rtn += v[i].first;
		bt[ps] = 0;
	}
	return rtn;
}

void solove(){
	int n; cin >>n;
	vector<pii> lf, rg;
	ll ans = 0;
	rep(i, n){
		int k, l, r;
		cin >>k >>l >>r;
		if(l >r){
			lf.emplace_back(l-r, k);
		}else if(l < r){
			rg.emplace_back(r-l, n-k);
		}
		ans += min(l, r);
	}
	
	ans += cal(lf) + cal(rg);
	cout << ans <<"\n";
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int t;
	cin >>t;
	rep(_g, t) solove();
	return 0;
}


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

int main()
{
	long long a, b, v, w, t;
	while (scanf("%lld%lld%lld%lld%lld", &a, &v, &b, &w, &t) != EOF) {
		if (v * t - w * t - abs(a - b) >= 0) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	return (0);
}


Measured memory_bytes: 1656
N, M, X = gets.chomp.split(" ").map(&:to_i)

line = []
N.times do
  line << gets.chomp
end


DATA = []
line.each_with_index do |row, i|
  values = row.split(" ").map(&:to_i)
  DATA[i] = {c: values.shift, a: values}
end
#p DATA


def hoge(arr)
  price = 0
  lern = []

  arr.each do |i|
    price += DATA[i][:c]

    M.times do |j|
      # 全参考書の学習度
      lern[j] = 0 unless lern[j]
      lern[j] += DATA[i][:a][j]
    end
  end

  {
    price: price,
    val: lern.map{|l| X - l},
    learned: lern.map{|l| X - l}.all?{|v| v <= 0}
  }
end

results = []

N.times do |j|
  (0..N-1).to_a.combination(j+1).to_a.each do |_arr|
    results << hoge(_arr)
  end
end
lern_arr = results.select{|h| h[:learned]}

#puts results


if lern_arr.count == 0
puts -1
else
  puts lern_arr.min{|a,b| a[:price] <=> b[:price]}[:price]
end


Measured memory_bytes: 16556
from collections import deque
# sts -> start topological sort   
def sts():
    for i in g:
        for j in i:
            incnt[j]+=1 
    for i in range(v):
        if incnt[i]==0:
            q.append(i)
    # Now start deleting elements
    while q:
        e=q.popleft()
        ans.append(e)
        for i in g[e]:
            incnt[i]-=1
            if incnt[i]==0:
                q.append(i)
    for i in ans:
        print(i)
            
v,e=map(int,input().split())
g=[[] for i in range(v)]
# incnt -> no of indirected edges to a vertex
incnt=[0]*v
# q -> queue containing nodes with 0 indirected edges
q=deque()
# ans -> topological sorted array
ans=[]
for i in range(e):
    x,y=map(int,input().split())
    g[x].append(y)
sts()



Measured memory_bytes: 9196
#include"iostream"
#include"string"
using namespace std;

int main() {
	string s;
	int ans = 0;
	cin >> s;
	for (int i = 0; i < 4; i++)
	{
		if (s.at(i) == '+')
		{
			ans++;
		}
		else
		{
			ans = ans - 1;
		}
	}
	cout << ans << endl;
}

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

int main()
{
    int r, c;

    while( cin >> r >> c )
    {
        if( r + c == 0 )
            break;

        int a[r+1][c];
        for( int i = 0; i < r + 1; i++ )
            for( int j = 0; j < c; j++ )
                a[i][j] = 0;
        
        for( int i = 0; i < r; i++ )
            for( int j = 0; j < c; j++ )
            {
                cin >> a[i][j];
                a[r][j] += a[i][j];
            }

        int sum = 0;
        for( int i = 0; i < c; i++ )
            sum += max( a[r][i], r - a[r][i] );

        int cnt = 5;
        while( cnt-- )
        {
            for( int i = 0; i < r; i++ )
            {
                int sum2 = 0;
                for( int j = 0; j < c; j++ )
                {
                    if( a[i][j] == 0 )
                    {
                        a[i][j] = 1;
                        a[r][j]++;
                    }
                    else
                    {
                        a[i][j] = 0;
                        a[r][j]--;
                    }
                    sum2 += max( a[r][j], r - a[r][j] );
                }
                if( sum < sum2 )
                    sum = sum2;
                else
                {
                    for( int j = 0; j < c; j++ )
                    {
                        if( a[i][j] == 0 )
                        {
                            a[i][j] = 1;
                            a[r][j]++;
                        }
                        else
                        {
                            a[i][j] = 0;
                            a[r][j]--;
                        }
                    }   
                }
            }
        }
        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 3456
import sys
N = int(input())
d = list(map(int, input().split()))
if len(d) % 2 != 0:
    print(0)
    sys.exit()
d.sort()
if d[N//2] == d[N//2-1]:
    print(0)
else:
    print(d[N//2] - d[N//2-1])


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

using namespace std;

typedef unsigned long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	ll T, N, H, K;
	long long T1, N1;
	cin >> T >> N >> H >> K;
	if((T > N? (long long)T-N:(long long)N-T) > 10e18) cout << "Unfair";
	else{
		T1 = (long long) T;
		N1 = (long long) N;
		cout << (K%2==0? T1-N1: N1-T1);
	}



	

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    const long long mod=1e9+7;
    int n;
    long long a[100010],inv[100010],pre[100010],ans,fac[100010];
    int main(){
    	scanf("%d",&n);
    	for(int i=1;i<=n;++i)
    	scanf("%lld",&a[i]);
    	inv[1]=1;
    	for(int i=2;i<=n;++i)
    	inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    	for(int i=1;i<=n;++i)
    	pre[i]=(pre[i-1]+inv[i])%mod;
    	for(int i=1;i<=n;++i)
    	ans=(ans+pre[n-i+1]*a[i]%mod+(pre[i]-1)*a[i]%mod)%mod;
    	fac[0]=1;
    	for(int i=1;i<=n;++i)
    	fac[i]=fac[i-1]*i%mod;
    	ans=(ans*fac[n])%mod;
    	printf("%lld\n",ans);
    }

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n; cin>>n;
  ll ans=1;
  rep(i,n){
    ll t; cin>>t;
    ans=ans/gcd(ans,t);
    ans*=t;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
List = []
for i in range (M):
  List.append(list(map(str, input().split())))
resList= [False]*N
res = 0
waList = [0]*N
for i in range(M):
  if resList[int(List[i][0])-1] == False:
    if List[i][1] == "AC":
      resList[int(List[i][0])-1] = True
      res += waList[int(List[i][0])-1] 
    else:
      waList[int(List[i][0])-1] += 1
print(resList.count(True),res)

Measured memory_bytes: 35228
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
char s[100][100];
int h,w;
int dx[8]={-1,0,1,-1,1,-1,0,1};
int dy[8]={-1,-1,-1,0,0,1,1,1};

int bomb(int i,int j){
    if(s[i][j]=='#'){
        return -1;
    }
    int res=0;
    for(int x=0;x<8;x++){
        if(i+dy[x]>=0 && i+dy[x]<h && j+dx[x]>=0 && j+dx[x]<w && s[i+dy[x]][j+dx[x]]=='#') res++;
    }
    return res;
}

int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char a;
            cin>>a;
            s[i][j]=a;
        }
    }
    vector<vector<int> > ans(h,vector<int>(w,0));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ans[i][j]=bomb(i,j);
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(ans[i][j]==-1){
                cout<<'#';
            }else{
                cout<<ans[i][j];

            }
        }
        cout<<endl;
    }

}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  string s;
  cin>>s;
  
  int l = 0, r = 0;
  int d;
  REP(i,n){
    if(s[i]=='('){
      l++;
    }else{
      r++;
    }
    d = l - r;
    if(d<0){
      s = "(" + s;
      l++;
      n++;
      i++;
    }
  }
  
  while(d>0){
    s += ')';
    d--;
  }
  cout<<s<<endl;
    
  return 0;
}


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

int Compare_Func(const int &arg_a, const int &arg_b , int a);
int Total_Func(int &arg_a, int &arg_b);

const int MIN   = 1;
const int MAX   = 10;
const int ERROR = -1;

int main()
{
	int a = 0;
	int Total = 0;
	int Result = 0;
	
	std::cin >> a;

	Result = Compare_Func(MIN, MAX, a);
	if (ERROR != Result)
	{
		Total = Total_Func(Total, a);
		std::cout << Total << std::endl;
	}
	return 0;
}

int Compare_Func(const int &arg_a, const int &arg_b, int a)
{
	if ((arg_a > a) || (arg_b < a))
	{
		return ERROR;
	}
	return 0;
}

int Total_Func(int &arg_a, int &arg_b)
{
	arg_a = arg_b + ((int)std::pow(arg_b, 2.0)) + ((int)std::pow(arg_b, 3.0));
	return arg_a;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a;
    cin >> a;
    switch(a%10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            puts("hon");
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            puts("pon");
            break;
        case 3:
            puts("bon");
            break;
    }
	return 0;
}

Measured memory_bytes: 3640
using System;

class Program {
  static void Main() {
    int r = int.Parse(Console.ReadLine());
    if (r < 1200) {
      Console.WriteLine("ABC");
    } else if (r < 2800) {
      Console.WriteLine("ARC");
    } else {
      Console.WriteLine("AGC");
    }
  }
}

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

bool can_move(int A, int B, string S){
    int num_b = 0;
    if(S[A]=='#') return false;
    if(S[B]=='#') return false;
    for (int ii = A; ii <= B; ii++){
        if (S[ii] == '#'){
            num_b++;
            if (num_b > 1){
                return false;
            }
        }else{
            num_b = 0;
        }
    }
    return true;
}

bool check(int A, int B, int C, int D, string S)
{
    if (C < D){
        if(can_move(B, D, S)==false) return false;
        S[D] = '#';
        if(can_move(A, C, S)==false) return false;
        return true;
    }else{
        bool exist_3_dots = false;
        int tmp_B = 0;
        for (int ii=B; ii<=D; ii++){
            if(S[ii-1]=='.' && S[ii]=='.' && S[ii+1]=='.'){
                exist_3_dots = true;
                tmp_B = ii;
                break;
            }
        }
        if(exist_3_dots == false) return false;
        if(can_move(B, tmp_B, S)==false) return false;
        S[tmp_B] = '#';
        if(can_move(A, C, S)==false) return false;
        S[C] = '#';
        S[tmp_B] = '.';
        if(can_move(tmp_B, D, S)==false) return false;
        return true;
    }
}

int main()
{
    int N, A, B, C, D;
    string S;
    cin >> N >> A >> B >> C >> D;
    cin >> S;
    A--;
    B--;
    C--;
    D--;
    cout << (check(A, B, C, D, S) ? "Yes" : "No") << endl;
    return 0;
}


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


void solve(long long N, std::vector<long long> A){
  long long count = 0;
  for(long long i = 0; i < (1<<(N*2)); i++) {
    bool similar = true;
    long long acc = 1;
    for(long long j = 0; j < N; j++) {
      long long current = (i&(0b11<<(j*2)))>>(j*2);
      if(current == 0b11) similar = false;
      acc *= ((A[j]+(current-1)) % 2);
    }

    if(similar && acc == 0) count++;
  }

  cout << count << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int N;
    cin >> N;
    ll sum = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 != 0  && i % 5 != 0) {
            sum += i;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3652
#define _GLIBCXX_DEBUG
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define mp make_pair
#define pb push_back
#define FI first
#define SE second
#define FOR(i,a,b) for(int (i)=((int)a); (i)<=((int)b); (i)++)
#define REP(i,N) FOR((i), 0, ((int)N)-1)
#define INF (1 << 30)
#define all(v) (v).begin(),(v).end()
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
#define vidx(v,it) distance((v).begin(),(it))
#define vsum(v) accumulate(all(v),0)
#define vfnd(v,val) find(all(v),val) // itrを返す
#define vcnt(v,val) count(all(v),val)
#define vrep(v,it) for(auto it=(v).begin(); it != (v).end(); ++it)

#ifdef LOCAL
    #define debug(...) fprintf(stderr, __VA_ARGS__)
    #define stopif(val) assert( !(val) )
#else
    #define debug(...) 1
    #define stopif(val) 1
#endif

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
int gcd(int a, int b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);}

int main(){
    int N,M;
    cin >> N >> M;
    vi X(M),Y(M-1);
    REP(i,M) cin >> X[i];
    sort(all(X));
    REP(i,M-1) Y[i] = X[i+1]-X[i];
    sort(all(Y));
    int ans = 0;
    REP(i,M-N) ans += Y[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

int GCD(int x,int y){
  	while(true){
      	if(x%y==0) return y;
     	if(y>x)swap(x,y);
        if(x>y) x%=y;
    }
}

signed main(){
    int N,ans;
    cin>>N;
    ans=0;
    int A[N];
    REP(i,N) cin>>A[i];
    int ls[N],rs[N];
    ls[0]=A[0];
    rs[N-1]=A[N-1];
    REP(i,N-1) ls[i+1]=GCD(ls[i],A[i+1]);
    REP(i,N-1) rs[N-2-i]=GCD(rs[N-1-i],A[N-2-i]);
    REP(i,N){
        if(i==0) ans=rs[1];
        if(i==N-1) ans=max(ans,ls[N-2]);
        if(i!=0 &&i!=N-1) ans=max(ans,GCD(ls[i-1],rs[i+1]));
    }
    cout<<ans<<endl;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    ll a,b;
    cin >> a >> b;

    if(a%2 == b%2)
        cout << (a+b)/2 << endl;
    else
        cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 3620
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut ws = vec![];
    let mut sum = 0;
    for i in 0 .. n {
        ws.push(get!());
        if i % 2 == 0 {
            sum += ws[i];
        } else {
            sum -= ws[i];
        }
    }
    let mut ans = vec![0; n];
    ans[0] = sum;
    for i in 0 .. n-1 {
        ans[i+1] = (ws[i] - ans[i] / 2) * 2;
    }
    for i in 0 .. n {
        if i > 0 {
            print!(" ");
        }
        print!("{}", ans[i]);
    }
    println!();
}

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

long long int i,j,m,d,ans;

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>m>>d;ans=0;
	for (i=2;i<10;i++) if (10*i<d)
	{
		for (j=2;j<10;j++) 
		if ((i<d/10 || j<=d%10) && i*j<=m) ans=ans+1;
	}
	cout<<ans;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;
int a[N];
int main()
{
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    int t=a[n]/2;
    ll mins=inf;
    int p;
    for(int i=1; i<=n; i++)
    {
        if(abs(a[i]-t)<=mins)
        {
            mins=abs(a[i]-t);
            p=a[i];
        }
    }
    if(n == 2)
        printf("%d %d\n", a[2], a[1]);
    else
        printf("%d %d\n", a[n], p);
    return 0;
}


Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    int A[214514];
    int B[214514]={};
    cin >> N;
    REP(i,N){
        cin >> A[i];
        A[i]--;
    }
    
    REP(i,N){
        B[A[i]]++;
    }
    
    int Ans=0;
    REP(i,N){
        Ans+=B[i]*(B[i]-1)/2;
    }
    
    REP(k,N){
        int num = Ans;
        num -= B[A[k]]*(B[A[k]]-1)/2;
        num += (B[A[k]]-1)*(B[A[k]]-2)/2;
        cout << num << endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 5888
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>

using namespace std;



int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<pair<long long, long long>,vector<pair<long long, long long>>,greater<pair<long long,long long >>> drink;

	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		drink.push(make_pair(a, b));

	}

	long long cnt = 0;
	long long money = 0;
	while (!drink.empty()) {
		long long price = drink.top().first;
		long long num = drink.top().second;

		drink.pop();

		if (cnt + num >= m) {
			money += (m - cnt)*price;
			cnt = m;
			break;
		}
		else {
			cnt += num;
			money += num * price;
		}

	}

	cout << money << endl;
}

Measured memory_bytes: 2420