akhauriyash/Code-Regression huggingface dataset:
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	int n, m;
	cin >> n >> m;
	cout << (n - 1)*(m - 1) << endl;

	return 0;
}





Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort()
f.reverse()
l=-1;r=max(a)*max(f)+1
sum=sum(a)
while abs(l-r)>1:
  x=(l+r)//2
  ct=0
  for i in range(n):
    ct+=max(a[i]-(x//f[i]),0)
  if ct<=k:
    r=x
  else:
    l=x
print(r)

Measured memory_bytes: 119500
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<int,int> PII;
typedef long long int ll;
typedef pair< ll,ll> PLL;
typedef unsigned long long int ULL;
typedef pair<ULL,int> PUI;
#define S second
#define F first
typedef tree<
PLL,
null_type,
less<PLL>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


PLL operator+(PLL a,PLL b){ return {a.first + b.first, a.second + b.second}; }
PLL operator-(PLL a,PLL b){ return {a.first - b.first, a.second - b.second}; }
PLL operator*(PLL a,PLL b){ return {a.first * b.first, a.second * b.second}; }
PLL operator/(PLL a,PLL b){ return {a.first / b.first, a.second / b.second}; }
PLL operator%(PLL a,PLL b){ return {( b.first + a.first) % b.first, (b.second + a.second) % b.second}; }
PLL operator%(PLL a,ll b){ return {a.first % b, a.second % b} ;}
PLL operator+(PLL a,ll b){ return {a.first + b, a.second + b} ;}
PLL operator-(PLL a,ll b){ return {a.first - b, a.second - b} ;}
PLL operator*(PLL a,ll b){ return {a.first * b, a.second * b} ;}

ostream& operator<<(ostream &out,PLL a)
{
    out << "( " << a.first << ", " << a.second << " )" ;
    return out;
}

ostream& operator<<(ostream &out,PUI a)
{
    out << "( " << a.first << ", " << a.second << " )" ;
    return out;
}
/*
	Order Statistics Tree ( OST )

	find_by_order()
		takes an integer k and returns an iterator to the k'th largest element counting from zero
	order_of_key()
		takes an element, here an integer and returns the number of elements strictly smaller than input
*/


int const MOD = 1e9 + 7;

int const N = 1e5 + 10;
bool mark[N] ;

void sieve()
{
    for(int i = 2; i < N; i++){
        if(!mark[i]){
            for(int j = 2 * i ; j < N; j += i) 
                mark[j] = 1;
        }
    }
}
ll dp[N][20];
string s;
ll DP(int pos,int mod)
{
    if(pos == s.size()) return (mod == 5);
    ll &ret = dp[pos][mod] ;
    ret = 0;
    if(s[pos] != '?'){
        ret = DP(pos+1,(mod*10 + (s[pos] - '0'))%13 );
    }
    else{
        for(int i =0; i < 10; i++){
            ret += DP(pos+1,(mod*10 + i) % 13 ) ;
            ret %= MOD;
        }
    }
    return ret;
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);

    int a,b,n;
    cin >> a >> b >> n;
    cout << min(a*b,n) << endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;
const int DIM = 52;

struct Matrix {
  int a[DIM][DIM];
  int *operator [] (int r) { return a[r]; };

  Matrix(int x = 0) {
    memset(a, 0, sizeof a);
    if (x)
    {
		for(int i = 0; i < DIM; i++) a[i][i] = x;
	}
  }
} const I(1);

Matrix operator * (Matrix A, Matrix B) {
  const ll mod2 = ll(mod) * mod;
  Matrix C;
 for(int i = 0; i < DIM; i++)
 {
	 for(int j = 0; j < DIM; j++)
	 {
		ll w = 0;
		for(int k = 0; k < DIM; k++)
		{
			w += ll(A[i][k]) * B[k][j];
			if (w >= mod2) w -= mod2;
		}
    C[i][j] = w % mod;
	}
  }
  return C;
}

Matrix operator ^ (Matrix A, ll b) {
  Matrix R = I;
  for (; b > 0; b /= 2) {
    if (b % 2) R = R*A;
    A = A*A;
  }
  return R;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n,k;
    cin >> n >> k;
    Matrix mat;
    for (int z=0;z<n;z++){
        for (int x=0;x<n;x++){
            cin >> mat[z][x];
        }
    }
    Matrix a = mat^(k);
    ll ans = 0;
    for (int z=0;z<n;z++){
        for (int x=0;x<n;x++){
            ans += a[z][x];
            ans %= mod;
        }
    }
    cout << ans << endl;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (u == s) {
        a -= 1;
    }
    if (u == t) {
        b -= 1;
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int weights[100000];
int size = 0;
int truckAmount = 0;
long long num = 0;
long long upper = 0;
long long med = 0;
long long lower = 0;
long long sum = 0;
int count = 0;

bool test() {
	long long truck = 0;
	int trucks = 0;
	bool complete = false;
	if (truckAmount == 1) {
		return sum <= med;
	}
	for (int i = 0; i < size; i++) {
		if (weights[i] >  med) {
			return false;
		}
		complete = false;
		truck += weights[i];
		if ((truck + weights[i+1] > med)) {
			trucks++;
			truck = 0;
			complete = true;
		}
	}
	if (!complete) {
		trucks++;
	}
	return trucks <= truckAmount;
}

int main() {

	scanf("%d %d", &size, &truckAmount);
	for (int i = 0; i < size; i++) {
		scanf("%lld", &num);
		weights[i] = num;
	}
	upper = 1000000000;
	for (int i = 0; i < size; i++) {
		sum += weights[i];
	}
	num = 1000000000;
	med = (lower + upper) / 2;
	while (lower < upper - 1) {
		if (test()) {
			upper = med;
			if (med < num) {
				num = med;
			}
		} else {
			lower = med;
		}
		med = (lower + upper) / 2;
		count++;
	}
	printf("%lld\n", num);
}



Measured memory_bytes: 3104
#include<iostream>
#include<cstring>
using namespace std;
const int N = 310;
char s[N][N];
int id[N][N];
int spe[N][N];
bool check(int i,int j,int k){
	return spe[k][j]-spe[i-1][j];
}
int g(int i,int j){
	if(id[i-1][j-1]==id[i-1][j] && id[i-1][j]==id[i][j-1]){
		return id[i-1][j];
	}
	if(id[i-1][j+1]==id[i][j+1] && id[i][j+1]==id[i-1][j]){
		return id[i][j+1];
	}
	if(id[i+1][j+1]==id[i][j+1] && id[i][j+1]==id[i+1][j]){
		return id[i][j+1];
	}
	if(id[i+1][j-1]==id[i+1][j] && id[i+1][j]==id[i][j-1]){
		return id[i+1][j];
	}
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	memset(id,0,sizeof(id));
	memset(spe,0,sizeof(spe));
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>s[i][j];
		}
	}
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			spe[i][j]=spe[i-1][j];
			if(s[i][j]=='#'){
				spe[i][j]++;
			}
		}
	}

	int cnt=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i][j]=='#'){
				int l,r,u,d;
				for(u=i-1;u>=1 && s[u][j]!='#' && !id[u][j];u--) ;
				u++;
				
				for(d=i+1;d<=n && s[d][j]!='#' && !id[d][j];d++) ;
				d--;
								
				for(l=j-1;l>=1 && !id[i][l];l--){
					if(spe[n][l]!=0){
						break;
					}
				}
				
				for(r=j+1;r<=m && !id[i][r];r++){
					if(spe[n][r]!=0){
						break;
					}
				}
				l++;
				r--;
				
				for(int x=u;x<=d;x++){
					for(int y=l; y<=r;y++)
					id[x][y] = cnt;
				}
				
				cnt++;
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){		
			cout<<id[i][j]<<' ';
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E15;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


 
int main(){fastio
    
    ll n;cin>>n;
    ll ans=1;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0)Max(ans,i);
    }
    cout<<ans+n/ans-2<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
#define int long long
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
int modpow(int a,int b){
    if(!b)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int fac(int a){
    int Ans=1;
    for(int i=1;i<=a;i++){
        Ans*=i;
        Ans%=MOD;
    }
    return Ans;
}//kaijo
int comb(int a,int b){
    return fac(a)*modpow(fac(a-b),MOD-2)%MOD*modpow(fac(b),MOD-2)%MOD;
}
signed main(){
	int h,w;
	int a[1000][1000];
	int x,y;
	cin>>h>>w;
	int ans=0;
	rep(i,h){
		rep(j,w){
			cin>>a[i][j];
			x=i+1,y=j+1;
			ans+=(h-x+1)*(w-y+1)*x*y*a[i][j];
		}
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 7012
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 0x3f3f3f3f

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    ll x,res=0,mx=0;
    while(n--)
    {
        cin>>x;
        mx=max(x,mx);
        res+=mx-x;
    }
    cout<<res;
}


Measured memory_bytes: 3652
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,a,b;
int main(){
	cin>>n>>a>>b;
	cout<<min(a*n,b);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
typedef struct D
{
	int ry,rx,ly,lx,t,s;//r l y x  0-nextR 1-nextL
	bool operator <(const D& a)const{return a.t<t;};
}D;

int W,H,F[63][33][2],ans,mv[9][2]={{-2,1},{-1,1},{-1,2},{0,1},{0,2},{0,3},{1,1},{1,2},{2,1}};
char C[63][33];

bool check(int y,int x)
{
	return 0<=y&&y<H&&0<=x&&x<W?true:false;
}

int cost(int y,int x)
{
	if('0'<=C[y][x]&&C[y][x]<='9')return C[y][x]-'0';
	return 0;
}

int main()
{
	for(;scanf("%d%d\n",&W,&H),W+H;)
	{
		memset(F,0x7f,sizeof(F));
		ans=1000000000;
		for(int i=0;i<H;i++)
			for(int j=0;j<W;j++)
				scanf("%c%*c",&C[i][j]);
		priority_queue<D>Q;
		for(int i=0;i<W;i++)
		{
			D tmp={H-1,0,H-1,0,0,0};
			if(C[H-1][i]=='S')
			{
				F[H-1][i][0]=F[H-1][i][1]=0;
				tmp.lx=tmp.rx=i;
				Q.push(tmp);
				tmp.s=1;
				Q.push(tmp);
			}
		}
		for(;!Q.empty();)
		{
			D t=Q.top();Q.pop();
			if(C[t.ly][t.lx]=='T'||C[t.ry][t.rx]=='T')
			{
				ans=min(ans,t.t);
				continue;
			}
			if(t.s==0)//move right leg
			{
				for(int i=0;i<9;i++)
				{
					int nry=t.ly+mv[i][0],nrx=t.lx+mv[i][1];
					if(check(nry,nrx)&&C[nry][nrx]!='X'&&F[nry][nrx][t.s]>t.t+cost(nry,nrx))
					{
						F[nry][nrx][t.s]=t.t+cost(nry,nrx);
						D ins={nry,nrx,t.ly,t.lx,t.t+cost(nry,nrx),1};
						Q.push(ins);
					}
				}
			}
			else
			{
				for(int i=0;i<9;i++)
				{
					int nly=t.ry+mv[i][0],nlx=t.rx-mv[i][1];
					if(check(nly,nlx)&&C[nly][nlx]!='X'&&F[nly][nlx][t.s]>t.t+cost(nly,nlx))
					{
						F[nly][nlx][t.s]=t.t+cost(nly,nlx);
						D ins={t.ry,t.rx,nly,nlx,t.t+cost(nly,nlx),0};
						Q.push(ins);
					}
				}
			}
		}
		printf("%d\n",ans==1000000000?-1:ans);
	}
}

Measured memory_bytes: 1096
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//
int main() {
	ll R;
	cin >> N >> R;
	if (N >= 10) {
		cout << R;
	}
	else {
		cout << R + 100 * (10 - N);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
    int X;
    cin>>X;
    if(X<1200){
        cout<<"ABC"<<endl;
    }else{
        cout<<"ARC"<<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++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;

int main() {
	rep(i, 5) {
		int x;
		cin >> x;
		if (x == 0) {
			cout << i + 1;
			return 0;
		}
	}
}


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

int main()
{
    int K, A, B;
    cin >> K >> A >> B;

    int x = A/K;
    int y;

    if (A % K == 0) {
        y = x * K;
    } else {
        y = x * K + K;
    }

    if (y >= A && y <= B) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
}

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

using namespace std;

int n;
vector<int> cnt(4, 0);
double a[333];
double dp[333][333][333];
int done[333][333][333];

double f(int a, int b, int c) {
    if (a == 0 && b == 0 && c == 0) {
        return 0.0f;
    }
    if (done[a][b][c] != -1) {
        return dp[a][b][c];
    }
    double ans = 0.0f;
    ans += (double)n/(a + b + c);

    if (a >= 1)
    ans += (double)a/(a+b+c) * f(a-1, b, c);

    if (b >= 1)
    ans += (double)b/(a+b+c) * f(a+1, b-1, c);

    if (c >= 1)
    ans += (double)c/(a+b+c) * f(a, b+1, c-1);
    done[a][b][c] = 1;
    dp[a][b][c] = ans;
    return ans;
}

int main(void) {
    memset(done, -1, sizeof(done));
    cin>>n;
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
        cnt[a[i]]++;
    }


    cout<<fixed<<setprecision(10)<<f(cnt[1], cnt[2], cnt[3]);


    return 0;
}



Measured memory_bytes: 405888
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            long ans = 0;
            for (int i = k + 1; i <= n; i++) {
                ans += (n / i) * (i - k);
                if (n % i != 0) {
                    if (k == 0) {
                        ans += n % i;
                    } else if (0 < k && k <= n % i) {
                        ans += (n % i) - k + 1;
                    }
                }
            }

            out.print(ans);
        }

    }
}



Measured memory_bytes: 21716
q,w,e=input,range,int

n, m = map(e,q().split())
V = n + m
par = [i for i in w(V)]
sizes = [1] * V


def f(x):
    if x == par[x]:
        return x
    par[x] = f(par[x])
    return par[x]


def u(x, y):
    x, y = f(x), f(y)
    if x == y:
        return
    if sizes[x] < sizes[y]:
        x, y = y, x
    par[y] = x
    sizes[x] += sizes[y]


[u(i,l-1+n)for i in w(n)for l in [e(k)for k in q().split()][1:]]
print("NO"if len([i for i in w(n)if f(i)!=f(0)])>0 else"YES")


Measured memory_bytes: 12676
//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>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//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;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i=0;i<N;++i) {
        cin >> A[i];
        }
    long long ans=0;
    if(A[0]==1){
        ++ans;
        swap(A[0],A[1]);
    }
    for(int i=1;i<N;++i){
        if(A[i]==i+1){
            if(A[i+1]==i+2){
                swap(A[i],A[i+1]);
                    ++ans;
            }
            else{
                swap(A[i],A[i-1]);
                ++ans;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 640
//  aoj -  - 0537  / 2016-03-04
#include<iostream>
#include<vector>
#include<cassert>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<tuple>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef ll int__;
#define rep(i,j) for(int__ i=0;i<(int__)(j);i++)
#define repeat(i,j,k) for(int__ i=(j);i<(int__)(k);i++)
#define all(v) v.begin(),v.end()

template<typename T>ostream& operator << (ostream &os , const vector<T> &v){
    rep(i,v.size()) os << v[i] << (i!=v.size()-1 ? " " : "\n"); return os;
}
template<typename T>istream& operator >> (istream &is , vector<T> &v){
    rep(i,v.size()) is >> v[i]; return is;
}

#ifdef DEBUG
void debug(){ cerr << endl; }
#endif
template<class F,class...R> void debug(const F &car,const R&... cdr){
#ifdef DEBUG
    cerr << car << " "; debug(cdr...);
#endif
}

const int MOD = 100000;

bool solve(){
    int N, M, S; cin >> N >> M >> S;
    if(N == 0) return false;
    vector<vector<int>> dp(N*N+1, vector<int>(S+1));
    // dp[i][j] := i???????????§?????????j????????????????????°
    dp[0][0] = 1;
    repeat(i, 1, M+1){
        for(int j = N*N-1; j >= 0; j--){
            rep(k, S+1-i){
                dp[j+1][k+i] += dp[j][k];
                dp[j+1][k+i] %= MOD;
            }
        }
    }
    cout << dp[N*N][S] << endl;
    
    return true;
}

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

Measured memory_bytes: 3392
#include <stdio.h>
#include <math.h>

long factor(long a){
  long tmp1,tmp2;
  tmp1=(a*a);
  tmp2=(tmp1*tmp1);
  return (tmp2*a);
}

int main(){
  long a,b,x;
  long a_tmp,b_tmp;
  
  scanf("%ld",&x);
  
  for(a=(-118);a<=119;a++){
    for(b=(-119);b<=118;b++){
      a_tmp=factor(a);
      b_tmp=factor(b);
      if((a_tmp-b_tmp)==x){
        printf("%ld %ld",a,b);
        return 0;
      }
    }
  }
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
#include <boost/range/adaptor/indexed.hpp>
using namespace std;

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

template <typename T>
std::ostream &operator<<(std::ostream &ostr, const std::vector<T> &v) {
  for (const auto &i : v | boost::adaptors::indexed())
    ostr << (i.index() > 0 ? " " : "") << i.value();
  return ostr;
}

int n, m, re = 0;
bool graph[10][10] = {false};
vector<int> che;

inline void input() {
  cin >> n >> m;
  int a, b;
  rep(i, m) {
    cin >> a >> b;
    graph[a][b] = true;
    graph[b][a] = true;
  }
}

inline bool check() {
  int co = 0;
  vector<int> ch = che;
  sort(all(ch));

  rep(i, n) {
    if(ch.at(i) == i+1) {
      co++;
    }
  }

  if(co==n) {
    re++;
  }

  return co==n;
}

inline void dfs(int x, int c) {
  che.push_back(x);

  if(c == n) {
    check();
    che.pop_back();
    return;
  }

  rep(i, 10) {
    if(graph[x][i]) {
      // cout << x << " to " << i << endl;
      dfs(i, c+1);
    }
  }

  che.pop_back();
}

inline void Main() {
  // code
  input();
  dfs(1, 1);
  cout << re << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
x=int(input())
ans=0
s=[]
s.append(1)
for i in range(2,32):
  num=i
  while num<=1000:
    num=num*i
    s.append(num)
s=sorted(s)
flag=False
for i in range(len(s)):
  if s[i]>x:
    ans=s[i-1]
    flag=True
    break
if flag:
  print(ans)
else:
  print(s[-1])

Measured memory_bytes: 3064
#include <iostream>
#include <set>

using namespace std;

int main() {
    set<int> st;
    
    int N;
    cin >> N;
    for(int n=0; n<N; n++) {
        int d;
        cin >> d;
        st.insert(d);
    }
    
    cout << st.size() << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <stack>

using namespace std;


int main(){

	int n;
	int year, month, date;
	int ans;

	cin >> n;

	for(int set=0 ; set<n ; set++){
		ans=0;
		cin >> year >> month >> date;

		for(int i=year ; i<1000 ; i++){
			if(i == year){

				for(int j=month ; j<=10 ; j++){

					if(j == month){
						if(i%3==0 || j%2==1){
							for(int k=date ; k<=20 ; k++){
								ans++;
							}
						}else{
							for(int k=date ; k<20 ; k++){
								ans++;
							}
						}
					}else{
						if(i%3==0 || j%2==1){
							for(int k=1 ; k<=20 ; k++){
								ans++;
							}
						}else{
							for(int k=1 ; k<20 ; k++){
								ans++;
							}
						}
					}
				}

			}else{
				for(int j=1 ; j<=10 ; j++){

					if(i%3==0 || j%2==1){
						for(int k=1 ; k<=20 ; k++){
							ans++;
						}
					}else{
						for(int k=1; k<20 ; k++){
							ans++;
						}
					}
				}
			}

		}
		cout << ans << endl;


	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e5+10;
const int M = 1e6+10;
/*=================================================================================*/


int main() {
   int n;
   cin>>n;
   int ans = n%1000;
   if(ans) ans = 1000 - ans;
   cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <stdlib.h>
#define MAX_LENGTH 1000
using namespace std;

int main()
{
  int *stack = new int[MAX_LENGTH]; 
  int current = -1;

  char in[100];
  while (1) {
    cin >> in;
    if (cin.eof()) {
      break;
    }

    int v1, v2;
    switch (in[0]) {
      case '+':
        v1 = stack[current--];
        v2 = stack[current--];
        stack[++current] = v2 + v1;
        break;
      case '-':
        v1 = stack[current--];
        v2 = stack[current--];
        stack[++current] = v2 - v1;
        break;
      case '*':
        v1 = stack[current--];
        v2 = stack[current--];
        stack[++current] = v2 * v1;
        break;
      default:
        stack[++current] = atoi(in);
        break;
    }
  }
  cout << stack[current] << endl;
}


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

int n,d1=0,d2=0,d4=0;
ll a[100007],x;
int main(){
  std::cin >> n;
  for(int i = 0; i<n; i++){
    std::cin >> x;
    if(x%4==0) d4++;
    else if(x%2==0) d2++;
    else d1++;
  }
  if((d4>=d1)||((d1-1==d4)&&(d4>0)&&(d2%2==0))) printf("Yes\n");
  else printf("No\n");
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int h, w; cin >> h >> w;
	vector<vector<int>> grid(h,vector<int>(w));
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> grid[i][j];
		}
	}
	vector<pair<pair<int, int>, pair<int, int>>> operation;
	pair<int, int> preb;
	bool under_ope = false;
	for(int i = 0; i < h; i++){
		if(i % 2 == 0){
			for(int j = 0; j < w; j++){
				if(under_ope){
					operation.push_back(make_pair(make_pair(preb.first, preb.second), make_pair(i, j)));
					preb = make_pair(i,j);
					grid[i][j]++;
					under_ope = false;
				}
				if(grid[i][j]  % 2 == 1 && !(i == h - 1 && j == w - 1)) {
					preb = make_pair(i,j);
					under_ope = true;
				}
			}
		}
		else{
			for(int j = w - 1; j >= 0; j--){
				if(under_ope){
					operation.push_back(make_pair(make_pair(preb.first, preb.second), make_pair(i, j)));
					preb = make_pair(i, j);
					grid[i][j]++;
					under_ope = false;
				}
				if(grid[i][j]  % 2 == 1 && !(i == h - 1 && j == 0)) {
					preb = make_pair(i,j);
					under_ope = true;
				}
			}
		}
	}
	cout << operation.size() << endl;
	for(int i = 0; i < operation.size(); i++){
		cout << operation[i].first.first + 1 << " " << operation[i].first.second + 1<< " " << operation[i].second.first + 1 << " " << operation[i].second.second + 1<< endl;
	}
	return 0;	
}
  

Measured memory_bytes: 5236
def solve(n: int, words: list):
    word_map = dict()
    max_count = 0
    for word in words:
        count = word_map.get(word, 0) + 1
        word_map[word] = count
        max_count = max(max_count, count)
   
    for word in sorted(word_map.keys()):
        if(word_map[word] == max_count):
            print(word)


def main():
    n = int(input())
    li = []
    for i in range(n):
        li.append(input())
    solve(n, li)


main()

Measured memory_bytes: 35220
n, m = map(int, input().split())
bool_lst = [False] * n
ac_lst = [0] * n
wa_lst = [0] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if bool_lst[p] == False:
        if s == 'AC':
            bool_lst[p] = True
            ac_lst[p] += 1
        else:
            wa_lst[p] += 1

ac_cnt = 0
wa_cnt = 0
for i in range(n):
    if bool_lst[i] == True:
        ac_cnt += ac_lst[i]
        wa_cnt += wa_lst[i]

print(ac_cnt, wa_cnt)


Measured memory_bytes: 5364
#include <algorithm>
#include <cstdio>
#include <queue>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,m;
	pair<int,int> a[100000];
	scanf("%d%d",&n,&m);
	rep(i,n) scanf("%d%d",&a[i].first,&a[i].second);

	sort(a,a+n);

	int ans=0,idx=0;
	priority_queue<int> Q;
	rep(i,m){
		for(;idx<n&&a[idx].first<=i+1;idx++) Q.push(a[idx].second);
		if(!Q.empty()) ans+=Q.top(), Q.pop();
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 1660
#include <stdio.h>

int main(void){

    int H,W,i,j;
    scanf("%d %d",&H,&W);
   
  while( H != 0 || W != 0){
    for( j=1 ; j<=H ; j++ ){
     for( i=1 ; i<=W ; i++ ){
       printf("#");
     }
       printf("\n");
     }
     scanf("%d %d",&H,&W);
     printf("\n");
    }

    return 0;
}

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

#define endl '\n'

using namespace std;

int main()
{
	int n;
	cin>>n;
	int a[n];
	long long int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(i!=0)
		{
			if(a[i]<a[i-1])
			{	
				sum+=a[i-1]-a[i];
				a[i]=a[i-1];
			}
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 4400
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define cy cout<<"Yes"
#define cn cout<<"No"
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7
#define LINF 1e18+10  
using ll = long long; 

using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
using Ps=pair<int,string>;

using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}

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

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

int main(){
    int n,k;
    cin>>n>>k;
    vi a(n);
    rep(i,n)cin>>a[i];

    auto f=[&](ll c){
        ll cnt=0;
        rep(i,n){
            cnt+=(a[i]-1)/c;
        }
        if(cnt<=k)return true;
        else return false;
    };
    ll l=0,r=1e9;
    while(l+1<r){
        ll mid=(l+r)/2;
        if(f(mid))r=mid;
        else l=mid;
    }
    cout<<r<<endl;
    return 0;

}

Measured memory_bytes: 4008
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    ll n,k;
    cin >> n >> k;
    n %= k;
    cout << min(n,(ll)fabs(n - k)) << "\n";
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]

if a[0] != 0:
    print(-1)
    exit()

l = [-1]
for i in a:
    if i == l[-1] + 1:
        l[-1] += 1
    elif i <= l[-1]:
        l.append(i)
    else:
        print(-1)
        exit()

print(sum(l))


Measured memory_bytes: 13408
sum = 0
bit = 0
N = int(input())

for i in range(N):
    x , u = map(str , input().split(" "))

    if u == "JPY":
        sum = sum + int(x)
    elif u == "BTC":
        bit = 380000 * (float(x) / 1.0)
        sum = sum + bit

print(sum)

Measured memory_bytes: 3060
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf8");

var reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});

let a = [1],
  p = [1];

reader.on("line", line => {
  let input = line.split(/\s/);
  let n = parseInt(input[0]);
  let x = parseInt(input[1]);

  for (let i = 1; i <= n; i++) {
    a.push(2 * a[i - 1] + 3);
    p.push(2 * p[i - 1] + 1);
  }
  
  console.log(f(n, x));
});

function f(n, x) {
  if (n == 0) {
    if (x <= 0) return 0;
    else return 1;
  } else if (x <= 1 + a[n - 1]) {
    return f(n - 1, x - 1);
  } else {
    return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1]);
  }
}


Measured memory_bytes: 7628
n = int(raw_input())
arr = map(int,raw_input().split())
ave = sum(arr)*1.0/n
arr_d = []
min = 100
min_i = -1
for i in range(n):
    if abs(ave-arr[i])<min:
        min=abs(ave-arr[i])
        min_i = i
print min_i

Measured memory_bytes: 2820
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

char a, b;

signed main() {
	cin >> a >> b;
	cout << (a==b ? 'H' : 'D') << ln;
}


Measured memory_bytes: 256
// ボール: 区別あり, 箱：区別なし, 入れ方: 1 つ以下
#include <iostream>
using namespace std;

int main() {
  
  int n, k; cin >> n >> k;
  
  // 箱が足りるなら 1
  // 足りないなら 0
  cout << (n <= k) << endl;

  return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	ll n,k;
	cin >> n >> k;
	vector <ll> arr(n);
	for (int z=0;z<n;z++){
		cin >> arr[z];
	}
	sort(arr.begin(),arr.end());
	vector <bool> dp(k+1,false);
	dp[0] = false;
	for (int z=1;z<=k;z++){
		for (int x=0;x<n;x++){
			if (z-arr[x] < 0) break;
			if (!dp[z-arr[x]]) {dp[z] = true; break;}
		}
	}
	if (dp[k]){
		cout << "First" << endl;
	} else {
		cout << "Second" << endl;
	}
	cin >> n;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

x = A[0]
y = sum(A[1:])
ans = abs(x - y)
for i in range(1, N - 1):
    x += A[i]
    y -= A[i]
    ans = min(ans, abs(x - y))
print(ans)


Measured memory_bytes: 24932
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    int c[10][10];
    int a[200][200];
    REP(i, 10)REP(j, 10) cin >> c[i][j];
    REP(i, h)REP(j, w) cin >> a[i][j];

    REP(k, 10)REP(i, 10)REP(j, 10)
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);

    int ans = 0;
    REP(i, h)REP(j, w){
        if(a[i][j] != -1){
            ans += c[a[i][j]][1];
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n;
  string a, b, c;

  cin >> n;
  cin >> a >> b >> c;

  int ans = 0;

  for(int i=0;i<a.size();i++){
    if (a[i] != b[i] && b[i] != c[i] && a[i] != c[i]){
      ans += 2;
    } else if(a[i] != b[i] || b[i] != c[i] || a[i] != c[i]){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

            // 入力されたrを定義

            double r = scanner.nextDouble();

            // 与えられた値rで面積と円周を計算
            double menseki = r * r * 3.141592653589;
            double enshuu = 2 * r * 3.141592653589;

            System.out.println(String.format("%.6f", menseki) + " " + String.format("%.6f", enshuu));
           // System.out.println(menseki + " " + enshuu);
	}
}



Measured memory_bytes: 28184
#include <iostream>
#include<iomanip>
#include <cstdint>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int abs( int a ) { return a < 0 ? -a : a; }
uint64_t gcd( uint64_t a, uint64_t b ) {
	return b == 0 ? a : gcd( b, a % b );
}

int main() {
	int n;
	cin >> n;
	typedef pair<uint64_t, uint64_t> pair_t;
	vector<pair_t> a( n );
	for ( int i = 0; i < n; i++ ) cin >> a[i].first >> a[i].second;
	sort( a.begin(), a.end(), []( pair_t i, pair_t j ) { return i.second < j.second; } );
	uint64_t p = 0;
	for ( int i = 0; i < n; i++ ) {
		p += a[i].first;
		if ( p <= a[i].second ) continue;
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3328
/**
*    author:  y_takano
*    created: 18.06.2020 17:27:01
**/

#include <bits/stdc++.h>

using namespace std;

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

  int a, b;
  char op;

  for (;;)
  {
    cin >> a >> op >> b;

    if (op == '?')
    {
      break;
    }

    switch (op)
    {
    case '+':
      cout << a + b << endl;
      break;
    case '-':
      cout << a - b << endl;
      break;
    case '*':
      cout << a * b << endl;
      break;
    case '/':
      cout << a / b << endl;
      break;

    default:
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3152
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	int n;
	cin >> n;

	vector<int> a(n);
	vector<int> cnt(n);
	REP(i, n - 1)
	{
		cin >> a[i + 1];
		a[i + 1]--;
	}

	for (int i = n - 1; 0 < i; i--)
	{
		cnt[a[i]]++;
	}
	REP(i, n)
	{
		cout << cnt[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 4780
import java.util.*;
public class Main{

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

        int r = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        
        int[][] list = new int[r+1][c+1];
        
        //標準入力
        for(int i=0; i<r; i++){
            for(int j=0; j<c; j++){
                list[i][j] = Integer.parseInt(sc.next());
            }
        }
        //r+1行目
        for(int i=0; i<c; i++){
            int sum=0;
            for(int j=0; j<r; j++){
                sum += list[j][i];
            }
            list[r][i] = sum;
        }
        //c+1列目
        for(int i=0; i<r+1; i++){
            int sum=0;
            for(int j=0; j<c; j++){
                sum += list[i][j];
            }
            list[i][c] = sum;
        }
        
        //出力
        for(int i=0; i<r+1; i++){
            StringBuilder sb = new StringBuilder();
            for(int j=0; j<c+1; j++){
                sb.append(list[i][j]).append(" ");
            }
            sb.deleteCharAt(sb.lastIndexOf(" "));
            System.out.println(sb);
        }

    }

}



Measured memory_bytes: 38232
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
int main() {
	int n,x;
	cin >> n >> x;
	vector<int> a;
	REP(i, n) {
		int b;
		cin >> b;
		a.push_back(b);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < a.size(); ++i) {
		x -= a[i];
		if (x < 0) {
			cout << i << endl;
			return 0;
		}
	}
	if (x != 0) {
		cout << n - 1 << endl;
	}
	else cout << n << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			const int x = 1000000007;

			int[] vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int N = vs[0];
			int M = vs[1];

			int[,] pt = new int[N + 3, 2];
			pt[0, 0] = 0;
			pt[0, 1] = 1;
			pt[1, 0] = 1;
			pt[1, 1] = 0;
			pt[2, 0] = 1;
			pt[2, 1] = 1;
			for (int i = 3; i <= N; i++) {
				pt[i, 0] = (pt[i - 1, 0] + pt[i - 1, 1]) % x;
				pt[i, 1] = pt[i - 1, 0];
			}

			int pos = 0, mv = 0;
			long ans = 1;
			for (int i = 0; i < M; i++) {
				int a = int.Parse(Console.ReadLine());
				if (a == pos) {
					Console.WriteLine(0);
					return;
				}
				mv = a - 1 - pos;
				ans = ans * (pt[mv, 0] + pt[mv, 1]) % x;
				pos = a + 1;
			}
			mv = N - pos;
			ans = ans * (pt[mv, 0] + pt[mv, 1]) % x;

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 13920
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)
function bsearch(a::Array{Int,1},x::Int);l,r=1,length(a);while l<=r;m=l+div(r-l,2);if a[m]<x;l=m+1;else;r=m-1;end;end;return(l-1);end

function main()
	n = readline() |> parseInt
	v = readline() |> split |> parseMap
	c = readline() |> split |> parseMap
	k = 0
	for i in 1:n
		if v[i]-c[i] > 0
			k += v[i]-c[i]
		end
	end
	println(k)
end
main()


Measured memory_bytes: 129800
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int n; cin >> n;
    cout << (n+1) / 2 << endl;
}

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

using namespace std;


int main() {
	vector<unsigned int> A(3);
	cin >> A[0] >> A[1] >> A[2];

	sort(A.begin(), A.end());

	if(A[0] + A[1] == A[2]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int W,H,x,y,r;
	
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	if((W>=x+r)&&(H>=y+r)&&(0<=x-r)&&(0<=y-r))
	{
		printf("Yes\n");
	}
	else if((W<=x+r)||(H<=y+r)||(0>x-r)||(0>y-r))
	{
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
typedef pair<string, int> P;

int main()
{
	int nTime = 0;
	int n = 0, q = 0;
	P p;
	queue<P> que;
	cin >> n >> q;
	string strIn;
	int nIn;
	for (int i = 0; i < n;++i)
	{
		cin >> strIn >> nIn;
		que.push(make_pair(strIn, nIn));
	}
	while (!que.empty())
	{
		p = que.front();
		que.pop();
		if (p.second <= q)
		{
			nTime += p.second;
			cout << p.first << " " << nTime << endl;
		}
		else
		{
			p.second -= q;
			nTime += q;
			que.push(p);
		}
	}
	return 0;
}


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

#define rep(i,n) for(ll i=0;i<n;i++)
#define repm(i,m,n) for(ll i=m;i<n;i++)
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define YesNo(a) (a)?cout<<"Yes"<<endl:cout<<"No"<<endl
#define YESNO(a) (a)?cout<<"YES"<<endl:cout<<"NO"<<endl
#define INF (2e9)
#define PI (acos(-1))
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

typedef long long ll;

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

  YesNo(x >= 30);
}

Measured memory_bytes: 3604