akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

//問題文より、入力される英文の最大の長さ
#define MAXLENGTH 1200

int main(void)
{
	//line_countは入力された行数を、alphabet_countはa～zの出現個数を格納
	int i;
	int row, column, row_count;
	int alphabet_count[26] = {0};
	char str[MAXLENGTH][MAXLENGTH];

	row_count = 0;
	//読み込み終了まで英文を読み込む
	while(fgets(str[row_count], MAXLENGTH, stdin) != NULL){
		row_count++;
	}

	//入力された行数文繰り返す
	for(row = 0; row < row_count; row++){
		column = 0;
		//文の最後まで繰り返す
		while(str[row][column] != '\0'){
			//A～Zまたはa～zの出現個数をそれぞれ数える
			for(i = 0; i < 26; i++){
				if(str[row][column] == (i + 'A')){
					alphabet_count[i]++;
				}
				else if(str[row][column] == (i + 'a')){
					alphabet_count[i]++;
				}
			}
			column++;
		}
	}

	//結果を出力
	for(i = 0; i < 26; i++){
		printf("%c : %d\n", (i + 'a'), alphabet_count[i]);
	}

	return 0;
}


Measured memory_bytes: 2104
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int N, M;
vector<int> edge[100000];
bool flg[100000] = {};
deque<int> ans;
void dfs1(int now){
	flg[now] = true;
	for(int i=0; i<edge[now].size(); i++){
		if(flg[edge[now][i]]) continue;
		ans.push_back(edge[now][i]);
		dfs1(edge[now][i]);
		break;
	}
}
void dfs2(int now){
	flg[now] = true;
	for(int i=0; i<edge[now].size(); i++){
		if(flg[edge[now][i]]) continue;
		ans.push_front(edge[now][i]);
		dfs2(edge[now][i]);
		break;
	}
}

int main(){
	cin >> N >> M;
	for(int i=0; i<M; i++){
		int a, b;
		cin >> a >> b;
		edge[a-1].PB(b-1);
		edge[b-1].PB(a-1);
	}
	ans.push_back(0);
	dfs1(0);
	dfs2(0);
	cout << ans.size() << endl;
	while(!ans.empty()){
		cout << ans.front()+1;
		ans.pop_front();
		if(!ans.empty()) cout << " ";
	}
	cout << endl;
}

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

void dfs(int node, vector<int> adj[], int dp[], bool vis[]){
	vis[node]=true;
	for(int i=0;i<adj[node].size();i++){
		if(!vis[adj[node][i]])
			dfs(adj[node][i], adj, dp, vis);

		dp[node] = max(dp[node], 1+dp[adj[node][i]]);
	}
}

int longest_path(vector<int>adj[], int n){
	int dp[n+1];
	memset(dp, 0, sizeof(dp));

	bool vis[n+1];
	memset(vis, false, sizeof(vis));

	for(int i=1;i<=n;i++){
		if(!vis[i])
			dfs(i, adj, dp, vis);
	}
	int res=0;
	for(int i=1;i<=n;i++)
		res=max(res, dp[i]);

	return res;
}

int main(){
	int n, m, x, y;
	cin>>n>>m;
	vector<int>adj[n+1];

	for(int i=1;i<=m;i++){
		cin>>x>>y;
		adj[x].push_back(y);
	}

	cout<<longest_path(adj, n);
}

Measured memory_bytes: 12880
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int a,b,c,d,e,f; cin>>a>>b>>c>>d>>e>>f;
    int w,s,wa=100*a,sa=0;
    rep(i,f/(a*100)+1){
        rep(j,f/(b*100)+1){
            rep(k,f/c+1){
                rep(l,f/d+1){
                    w=100*(a*i+b*j); s=c*k+d*l;
                    if(w+s<=f && 100*s<=e*w && (wa+sa)*s>(w+s)*sa){
                        wa=w; sa=s;
                    }
                }
            }
        }
    }
    cout<<sa+wa<<" "<<sa<<endl;
}

Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n\r\t', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)

    orは!忘れに注意(末尾再帰なら直前)
*/

f(N) :-
    between(1, 9, A),
    between(1, 9, B),
    A * B =:= N.

main :-
    get_number(N),
    f(N) -> writeln("Yes") ; writeln("No").

    % statistics(inferences, IC), writeln(IC).


Measured memory_bytes: 8072
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
   ll n,c=0;
   cin>>n;
   ll a[n+1];
   for(int i=0;i<n;i++)
    {
      cin>>a[i+1];
    } 
    for(int i=1;i<n;i++)
    {
      if(a[i]==i)
      {
        if(a[i+1]==i+1)
        {
          //i++;
          c+=1;
          swap(a[i],a[i+1]);
        }
        else
        {
          c++;
          swap(a[i],a[i+1]);
        }
      }
    }
    if(a[n]==n)
      c++;
    cout<<c<<endl;
}
return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> shukudai(m);
    rep(i,m) {
        cin >> shukudai.at(i); 
        n -= shukudai[i];
    }
    if(n<0) cout << "-1" << endl;
    else cout << n << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
using namespace std;


int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 0; i < N; i++) {
	  int a;
	  cin >> a;
	  while (a % 2 == 0) {
		  a /= 2;
		  ans++;
		}
	}
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }

  int mi = sum;
  for (int i = 0; i < n; ++i) mi = min(mi, abs(sum - n * a[i]));

  for (int i = 0; i < n; ++i) {
    if (abs(sum - n * a[i]) == mi) {
      cout << i << '\n';
      return 0;
    }
  }
  return 0;
}


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

class Program
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var H = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        string ans = "Yes";
        bool e = false; //同じか

        for(int i = 1; i < N - 1; i++)
        {
            if(!e)
            {
                H[i] = H[i] - 1;
            }

            if(H[i] < H[i + 1])
            {
                e = false;
            }
            else if (H[i] == H[i + 1])
            {
                e = true;
            }
            else if (H[i] > H[i + 1])
            {
                ans = "No";
                break;
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 30044
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

//桁数
int digit(long long N){
	int count = 0;
	while(N > 0){
		N /= 10;
		count++;
	}
	return count;
}

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

	long long N;
	cin >> N;

	int count = digit(N);//countは桁数.

	for(long long A = 1LL;A*A<=N;A++){
		if(N%A != 0) continue;
		long long B = N/A;

		int ans_digit = max(digit(B),digit(A));

		if(count > ans_digit){
			count = ans_digit;
		}
	}
	cout << count << endl;

	return 0;
}

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

using namespace std;

#define rep(a, b) for(int i = a; i <= b; i++)
#define mst(a) memset(a, 0, sizeof(a))
#define mem(a, p) memset(a, p, sizeof(a))

const int MAX = 1e2 + 10;


bool mtx[MAX][MAX];
int vis[MAX];
int n;

queue<int> q;

void init(void)
{
	while(!q.empty())
		q.pop();
	mem(vis, -1);
	return;
}

bool check(int x, int y)
{
	if(mtx[x][y] && vis[y] == -1)
		return true;
	return false;
}

void Bfs(void)
{
	int cnt = 1;
	q.push(1);
	vis[1] = 0;
	while(!q.empty())
	{
		int cur = q.front();
		q.pop();
		rep(1, n)
		{
			if(check(cur, i))
			{
				q.push(i);
				vis[i] = vis[cur] + 1;
				cnt++;
				if(cnt == n)
					return;
			}
		}
	}
	return;
}

int main()
{
	while(~scanf("%d", &n))
	{
		init();
		rep(1, n)
		{
			int row;
			scanf("%d", &row);
			int num;
			scanf("%d", &num);
			while(num--)
			{
				int tmp;
				scanf("%d", &tmp);
				mtx[row][tmp] = true;
			}
		}
		
		Bfs();
		
		rep(1, n)
			printf("%d %d\n", i, vis[i]);
	}
	return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  double a,b,c,ans,ans1;
  int t,i,j;
  cin >> a >> b ;
  t = a;
  int A[t];
  for(i=0;i<a;i++){
  	cin >> A[i] ;
  }
  for(i=0;i<a;i++){
    for(j=i;j<a;j++){
  	if(A[i] < A[j]){
      c = A[i] ;
      A[i] = A[j] ;
      A[j] = c ;
    }
  }
  }
  
  ans = 0;
  ans1 = 0;
  
    for(i=0;i<a;i++){
  	ans1 += A[i] ; }
  
 
  
    for(i=0;i<b;i++){
  	if(A[i] >= ans1/(4*b)){
      ans++;} 
  }
  
	for(i=0;i<a;i++){
      	if(A[i] == A[i+1]){
     ans-- ;
    }
      if(i+1 > a)
        ans-- ;
  }
  for(i=0;i<a;i++){
      	if(b > a){
     ans-- ;
    }
  }
  
  
  if(ans == b){
    cout << "Yes" ;
  }
  else{
    cout << "No" ;
  }
  
 
 
return 0;
}

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

int main()
{
	string s;
	int count = 0, max = 0;
	
	cin >> s;
	
	for (int i = 0; i < s.length(); i++) {
		switch (s[i]) {
		case 'A':
		case 'C':
		case 'G':
		case 'T':
			count++;
			break;
		default:
			if (max < count) {
				max = count;
			}
			
			count = 0;
			break;
		}
	}
  
 	if (max < count) {
		max = count;
	}
	
	cout << max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  rep(i,h){
    cin>>s[i];
  }
  set<int> gyo;
  set<int> retu;
  rep(i,h){
    bool flg=true;
    rep(j,w){
      if(s[i][j]=='#'){
        flg=false;
      }
    }
    if(flg){
      gyo.insert(i);
    }
  }
  rep(i,w){
    bool flg=true;
    rep(j,h){
      if(s[j][i]=='#'){
        flg=false;
      }
    }
    if(flg){
      retu.insert(i);
    }
  }
  rep(i,h){
    if(gyo.find(i)!=gyo.end()){
      continue;     
    }
    rep(j,w){
      if(retu.find(j)!=retu.end()){
        continue;
      }
      cout<<s[i][j];
    }
    cout<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
char a[10],b[10],c[10];
scanf("%s %s %s",a,b,c);
if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0])
printf("YES");
else
printf("NO");
return 0;
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author indy256
 */

#include <bits/stdc++.h>

using namespace std;

void solve(istream &in, ostream &out) {
    int n;
    in >> n;

    for (int i = 1; i <= n; ++i) {
        int res = 0;
        for (int x = 1; x * x <= i; ++x) {
            for (int y = 1; x * x + y * y <= i; ++y) {
                int b = x + y;
                int c = x * x + y * y + x * y - i;
                int d = b * b - 4 * c;
                if (d >= 0) {
                    int s = static_cast<int>(sqrt(d));
                    int z = (-b + s) / 2;
                    if (z > 0 && x * x + y * y + z * z + x * y + y * z + x * z == i) {
                        ++res;
                    }
                }
            }
        }
        out << res << '\n';
    }
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solve(in, out);
}


Measured memory_bytes: 3540
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
d = [I() for i in range(N)]

print(len(set(d)))

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> p(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> p[i];
	}

	sort(++p.begin(), p.end());

	int ans = 0;
	for (int i = 1; i <= K; i++) {
		ans += p[i];
	}

	cout << ans << endl;
}


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

ll dp[100][100][5000];
int x[100],n,a;

int main(){
  cin>>n>>a;
  for(int i=0;i<n;i++)cin>>x[i];
  dp[0][0][0]=1;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      for(int k=0;k<5000;k++){
        if(dp[i][j][k]){
          dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
          dp[i+1][j][k]+=dp[i][j][k];
        }
      }
  ll ans;
  for(int i=1;i<=n;i++)ans+=dp[n][i][i*a];
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 151808
from collections import defaultdict

n,m = map(int,input().split())
k = [0]*n
a = [0]*n

for i in range(n):
    k[i],*a[i] = map(int,input().split())


d = defaultdict(int)

for j in a:
    for k in j:
        d[k] += 1

flg = 0
for k in d.values():
    if k == n:
        flg +=1

print(flg)

Measured memory_bytes: 38384
/************************************************************LET US BREAK BAD!****************************************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

int main(){
	//#ifndef ONLINE_JUDGE
	//    freopen("../input.txt", "r", stdin);
	//    freopen("../output.txt", "w", stdout);
	//#endif
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll t;
	// cin>>t;
	t = 1;
	while(t--){
		ll k;
		cin>>k;
		if(k%2==0){
			cout<<-1<<endl;
			continue;
		}    
		k/=__gcd(k, 7LL);
		ll sum = 0;
		ll ans = 0;
		vl v(1000001, 0);
		while(true){
			sum*=10;
			sum++;
			sum%=k;
			if(v[sum]){
				ans = -1;
				break;
			}
			v[sum] = 1;
			ans++;
			if(sum==0){
				break;
			}	
		}
		cout<<ans<<endl;

	}
return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if(n % 2 == 1){
        cout << b[n/2] - a[n/2] + 1 << endl;
    } else {
        cout << b[(n-1)/2] + b[(n-1)/2 + 1] - a[(n-1)/2] - a[(n-1)/2 + 1] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4820
#include <stdio.h>
#include <math.h>
int main(void) {
    int A,B,C,x;
    int count=0;

    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
    scanf("%d", &x);
    
    for(int a = 0; a <= A; a++) {
	    for(int b = 0; b <= B; b++) {
		    for(int c = 0; c <= C; c++) {
		    	int total = a * 500 + b * 100 + c * 50;
		    	if(total == x) {
		    		count++;
		    	}
		    }
	    }
    }
	
    printf("%d\n", count);
	
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N = 505;
int x[N*N], y[N*N];
int n;

int d[N][N];
bool del[N][N];
const int xx[4]={1,0,-1,0};
const int yy[4]={0,1,0,-1};

void extend(int x,int y){
	// cout << x << " " << y << ":" << d[x][y] << endl;
	for(int i=0;i<4;i++){
		int nx=x+xx[i], ny=y+yy[i];
		int nd=d[x][y]+1-del[nx][ny];
		if(d[nx][ny]>nd){
			d[nx][ny]=nd;
			extend(nx,ny);
		}
	}
}

int main()
{
	cin >> n;
	for(int i=1;i<=n*n;i++){
		int p;scanf("%d",&p);
		x[i] = (p+n-1)/n,y[i] = p-(x[i]-1)*n;
		// cout << x[i] << ":" << y[i] << endl;
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)d[i][j]=min(min(i,j),min(n-i+1,n-j+1));
	int ans=0;
	for(int i=1;i<=n*n;i++){
		ans+=d[x[i]][y[i]]-1;
		del[x[i]][y[i]]=1;
		for(int j=0;j<4;j++){
			int nx=x[i]+xx[j],ny=y[i]+yy[j];
			d[x[i]][y[i]] = min(d[x[i]][y[i]], d[nx][ny]);
		}
		extend(x[i],y[i]);
		
	}
	cout << ans << endl;
}

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

using namespace std;

#define ll long long

void solve() {
	int x, a, b;
	cin >> x >> a >> b;
	int e = abs(x-a);
	int f = abs(x-b);
	cout << (e > f ? "B" : "A") << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main()
{
	cin>>a>>b>>c;
	if(a>=b&&a>=c)
	{
		cout<<b+c;
		return 0;
	}
	if(b>=a&&b>=c)
	{
		cout<<a+c;
		return 0;
	}
	else
	{
		cout<<a+b;
		return 0;
	}
	return 0;
}


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

main(){
  vector<int> a(3);for(int i=0;i<3;i++) cin >> a[i];
  sort(a.begin(),a.end());
  int sum=0;for(int i=0;i<3;i++) sum+=a[i];
  int ans=0;
  int x=a[2];
  int diff=3*x - sum;
  if(diff%2 == 0){
    ans = diff/2;
  } else {
    x++;
    diff=3*x-sum;
    ans = diff/2;
  }
  cout << ans << endl;
  return 0;
} 

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scan =new Scanner(System.in);

  int A=scan.nextInt();

int B=scan.nextInt();
        int C=scan.nextInt();

        int D=scan.nextInt();

        while (A>0&&C>0){
            C=C-B;
            if (C<=0){int y=0;}
            else {A=A-D;}

        }
if (A<=0){System.out.println("No");}
        if (C<=0){System.out.println("Yes");}


    }
}

Measured memory_bytes: 35692
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(998244353);
const long long INIT=(long long)(1e7+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work
ll fact[INIT]={0};
int main()
{
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    READV(N);
    ll ans=power(3,N);
    fact[0]=1;
    FORI(i,1,N+1)
    {
        fact[i]=(fact[i-1]*i)%MOD;
    }
    ll sub=0;
    FORI(i,(N/2)+1,N+1)
    {
        sub=(sub+(2*power(2,N-i)*((fact[N]*modInverse((fact[i]*fact[N-i])%MOD)%MOD)))%MOD)%MOD;
    }
    ans=(MOD+ans-sub)%MOD;
    cout<<ans<<endl;
    

    return 0;
}

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



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    string s;
    cin >> n >> s;
    rep(i,0,s.size()){
      int x=s[i]-'A';
      x=(x+n)%26;
      s[i]='A'+ x;
    }
    cout << s << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main(void)
{
  ll x;
  cin >> x;
  ll result = 0;
  ll now = 100;
  while (now < x) {
    result++;
    now += now / 100;
  }
  cout << result << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
const int N = 3e4 + 5;
const int M = 1e6 + 5;
const int Mod = 1e9 + 7;


int main()
{
	GO;
	string s;
	cin >> s;
	for (auto i : s)
		if (i == '7')
			return cout << "Yes\n", 0;
	cout << "No\n";
	return 0;
}

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

int n, inf=1e9, ans=inf;
vector<int>G[2020];
char s[2020];

int mx[2020], mn[2020], sz[2020];

void dfs(int x,int fff){
	sz[x]=s[x]=='1';
	int smx=0, smn=0, bs=0;
	for (auto y:G[x])
		if (y!=fff){
			dfs(y,x);
			smx+=mx[y];
			smn+=mn[y];
			sz[x]+=sz[y];
			bs=max(bs,mn[y]);
		}
	mx[x]=smx;
	mn[x]=0;
	for (auto y:G[x])
		if (y!=fff){
			if (mn[y]==bs){
				if (mn[y]<=smx-mx[y]){
					mn[x]=smx&1;
				}else{
					mn[x]=mn[y]-(smx-mx[y]);
				}
			}
		}
	if (fff){
		mx[x]+=sz[x];
		mn[x]+=sz[x];
	}
}

int fuck(int rt){
	dfs(rt,0);
	if (mn[rt]==0) return mx[rt]/2;
	return inf;
}

int main(){
	cin>>n>>s+1;
	for (int i=1;i<n;++i){
		int x, y; cin>>x>>y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	for (int i=1;i<=n;++i)
		ans=min(ans,fuck(i));
	if (ans==inf) cout<<-1<<endl;
	else cout<<ans<<endl;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10 ** 9)

n, m = map(int, input().split())
v = [[] for _ in range(n)]
for i in range(m):
	a, b = map(int, input().split())
	v[a - 1].append(b - 1)

memo = [-1] * n

def dp(x):
	if memo[x] != -1:
		return memo[x]
	r = 0
	for i in v[x]:
		r = max(r, dp(i) + 1)
	memo[x] = r
	return r

res = max([dp(i) for i in range(n)])
print(res)

Measured memory_bytes: 138828
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int a,b,N,s,f,i,sum=0;
  cin >> a >> b;
  cin >> N;
  for(i=0;i<N;i++){
    cin >> s >> f;
    if(a>s&&a<f){
      sum=1;
    }
    if(b>s&&b<f){
      sum=1;
    }
    if(a<s&&b>s){
      sum=1;
    }
    if(a<f&&b>f){
      sum=1;
    }
    if(a==s){
      sum=1;
    }
  }
  cout << sum << endl;
  return(0);
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

    FOR(i, 1, 10) {
        if (n % i == 0 && n / i < 10) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


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

int main() {
    string s;
    cin >> s;

    if(s == "SUN") cout << 7 << endl;
    if(s == "MON") cout << 6 << endl;
    if(s == "TUE") cout << 5 << endl;
    if(s == "WED") cout << 4 << endl;
    if(s == "THU") cout << 3 << endl;
    if(s == "FRI") cout << 2 << endl;
    if(s == "SAT") cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = []
xy = []
for i in range(N):
  a = int(input())
  A.append(a)
  xykari = []
  for j in range(a):
    xykari2 = list(map(int, input().split()))
    xykari.append(xykari2)
  xy.append(xykari)

ans = 0

for i in range(2**N): # iはケース名
  honest = 0
  ng = 0
  for j in range(N):  # jはケースiでチェックする人j
    if ((i>>j)&1)==0:
      continue        # jが不親切なら次の人（j+1）のチェックに移る
    else:
      for k in range(A[j]):
        taisho = xy[j][k][0] - 1
        if xy[j][k][1] != ((i>>taisho)&1):
          ng = 1
          break
    if ng == 1:
      break
    honest += 1
  if ans < honest and ng == 0:
    ans = honest      # ansを更新

print(ans)


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

using namespace std;
int n,h[100001],d[100001],i;
int main()
{
    cin>>n;

    for(i=1;i<=n;i++)
    {
        cin>>h[i];
    }
     d[1]=0;
     d[2]=abs(h[1]-h[2]);
     for(i=3;i<=n;i++)
     {
         d[i]=min(d[i-2]+abs(h[i-2]-h[i]),d[i-1]+abs(h[i-1]-h[i]));
     }
     cout<<d[n];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long
typedef long double ld;
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>
#define vpii vector<pii>
#define vb vector<bool>
#define vbb vector<vb>
#define vs vector<string>
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define in(a) for (int i = 0; i < (a).size(); ++i) cin >> (a)[i]
#define out(a) for (auto qwe : a) cout << qwe << " "

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int MOD3 = 998244353;
const int P = 37;

const int mxn = 300;

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

    int n;
    cin >> n;

    vii a(n, vi(3));
    for (int i = 0; i < n; ++i) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }

    vii dp(n, vi(3, 0));

    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];

    for (int j = 1; j < n; ++j) {
        dp[j][0] = max(dp[j - 1][1], dp[j - 1][2]) + a[j][0];
        dp[j][1] = max(dp[j - 1][0], dp[j - 1][2]) + a[j][1];
        dp[j][2] = max(dp[j - 1][1], dp[j - 1][0]) + a[j][2];
    }

    cout << *max_element(all(dp[n - 1]));
}

Measured memory_bytes: 11136
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
    int n;
    cin>>n;
    double sum=0.0;
    for(int i = 0; i<n; i++){
        double x;
        string s;
        cin>>x>>s;
        if(s == "JPY") sum+=x;
        else sum+=380000*x;
    }
    cout<<sum<<endl;
    return 0;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

 int a, b, k;
 cin >> a >> b >> k;

 for(int i = min(a, b); i >= 1; --i){
     if((a % i == 0) && (b % i == 0))
        k--;
     if(k == 0){
        cout << i << endl;
        return 0;
     }
 }



  return 0;
}


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


int main()
{
    int n;
    vector <int> vi, vj;

    cin>>n;
    int a[n+5];

    int p=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]<0) p++;
    }
    if(!p) p++;
    if(p==n) p--;

    sort(a,a+n);

    for(int i=p; i<n-1; i++)
    {
        vi.push_back(a[0]);
        vj.push_back(a[i]);
        a[0]-=a[i];
    }

    for(int i=0; i<p; i++)
    {
        vi.push_back(a[n-1]);
        vj.push_back(a[i]);
        a[n-1]-=a[i];
    }

    cout<<a[n-1]<<endl;
    for(int i=0; i<vi.size(); i++)
        cout<<vi[i]<<" "<<vj[i]<<endl;

    return 0;
}


Measured memory_bytes: 3316
N, M  = map(int, input().split(" "))
Alist = list(map(int, input().split(" ")))
bclist = []
leng = len(Alist)
ans = 0
#print(Alist)
for i in range(M):
    b, c = (map(int, input().split(" ")))
    bclist.append([c,b])
bclist.sort(reverse = True)
#print(bclist)

count = 0
for j in range(M):
    for n in range(bclist[j][1]):
        Alist.append(bclist[j][0])
    count += bclist[j][1]
    if count >= leng:
        break
    

Alist.sort()

for k in range(leng):
    ans += Alist[-k-1]

print(ans)

Measured memory_bytes: 27072
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input;
        int sum;
        int i;
        while (true) {
            input = sc.nextLine();
            if (input.equals("0")) break;
            sum = 0;
            for (i = 0; i < input.length(); i++) {
                sum += input.charAt(i) - '0';
            }
            System.out.println(sum);
        }
    }
}



Measured memory_bytes: 26584
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int n,m,p,q;
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  lli ans=0;
  int a[200001];
  cin>>n;
  rep(i,n) cin>>a[i];
  int mt=a[0];
   reps(i,1,n){
       if(mt>a[i])
       ans+=(mt-a[i]);
       mt=max(a[i],mt);
   } 
   cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4396
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int[][] f;
    int i, j, k, x, y, z, t, w, max;
    String str;
    char[] ch;

    f = new int[10][10];

    for(;sc.hasNext();){
      str = sc.next();
      ch = new char[str.length()];
      for(j = 0;j < str.length();j++)ch[j] = str.charAt(j);
      x = 0; y = 0; z = 0; k = 0;

      for(j = 0;j < str.length();j++){
        if(ch[j] == ','){
          x = readint(ch, 0, j);
          k = ++j; break;
        }
      }
      for(;j < str.length();j++){
        if(ch[j] == ','){
          y = readint(ch, k, j);
          j++; break;
        }
      }
      z = readint(ch, j, str.length());

      if(z == 1){
        f[x][y]++;
        if(x != 0)f[x - 1][y]++;
        if(y != 0)f[x][y - 1]++;
        if(x != 9)f[x + 1][y]++;
        if(y != 9)f[x][y + 1]++;
      }else if(z == 2){
        f[x][y]++;
        if(x != 0)f[x - 1][y]++;
        if(y != 0)f[x][y - 1]++;
        if(x != 9)f[x + 1][y]++;
        if(y != 9)f[x][y + 1]++;
        if(x != 0 && y != 0)f[x - 1][y - 1]++;
        if(x != 0 && y != 9)f[x - 1][y + 1]++;
        if(x != 9 && y != 0)f[x + 1][y - 1]++;
        if(x != 9 && y != 9)f[x + 1][y + 1]++;
      }else{
        f[x][y]++;
        if(x != 0)f[x - 1][y]++;
        if(y != 0)f[x][y - 1]++;
        if(x != 9)f[x + 1][y]++;
        if(y != 9)f[x][y + 1]++;
        if(x != 0 && y != 0)f[x - 1][y - 1]++;
        if(x != 0 && y != 9)f[x - 1][y + 1]++;
        if(x != 9 && y != 0)f[x + 1][y - 1]++;
        if(x != 9 && y != 9)f[x + 1][y + 1]++;
        if(x > 1)f[x - 2][y]++;
        if(y > 1)f[x][y - 2]++;
        if(x < 8)f[x + 2][y]++;
        if(y < 8)f[x][y + 2]++;
      }
    }

    w = 0; max = 0;
    for(i = 0;i < 10;i++)for(j = 0;j < 10;j++){
      if(f[i][j] == 0)w++;
      if(max < f[i][j])max = f[i][j];
    }

    out.println(w);
    out.println(max);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }

  private static int readint(char[] ch, int l, int r){
    int i, d, res;
    d = 1; res = 0;
    for(i = r - 1;i >= l;i--){
      res += d * (int)(ch[i] - '0');
      d *= 10;
    }
    return res;
  }
}

Measured memory_bytes: 17144
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG nikkei2019/b.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int n;
    string a, b, c;
    cin >> n;
    cin >> a;
    cin >> b;
    cin >> c;

    int v[n];
    int ans = 0;
    rep(i, n){
        if(a[i] == b[i] && a[i] == c[i]){
            continue;
        }else if(a[i] == b[i] || b[i] == c[i] || c[i] == a[i]){
            ans++;
        }else{
            ans += 2;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#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>;
using graph = vector<vector<int>>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, ans;
    cin >> n;
    ans = 0;
    vll a(n, 0);
    REP(i, n) cin >> a[i];
    for(ll i=0;i<n;i+=2){
        if(a[i] % 2 == 1)ans++;
    }
    cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>

int main(void){
int a;
scanf("%d",&a);
int b;
scanf("%d",&b);

if(a == b){
printf("a == b\n");
}else if(a < b){
printf("a < b\n");
}else if(a > b){
printf("a > b\n");
}
return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	string s;
	int cnt = 0;
	cin >> s;
	rep(i,s.size()) {
		if(s[i] == 'C' && cnt == 0) cnt++;
		else if(s[i] == 'F' && cnt == 1) cnt++;

		if(cnt == 2) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int expr(string& s, int& i);
int term(string& s, int& i);
int factor(string& s, int& i);
int number(string& s, int& i);

int expr(string& s, int& i) {
    int val = term(s, i);
    while(s[i] == '+' || s[i] == '-') {
        char op = s[i];
        i++;
        int val2 = term(s, i);
        if (op == '+') val += val2;
        else val -= val2;
    }
    return val;
}

int term(string& s, int& i) {
    int val = factor(s, i);
    while(s[i] == '*' || s[i] == '/') {
        char op = s[i];
        i++;
        int val2 = factor(s, i);
        if (op == '*') val *= val2;
        else val /= val2;
    }
    return val;
}

int factor(string& s, int& i) {
    if (isdigit(s[i])) return number(s, i);

    // ここで構文が正しければ s[i] == '(' となる
    i++; // '('を読み飛ばす
    int ret = expr(s, i);
    i++; // ')'を読み飛ばす
    return ret;
}

int number(string& s, int& i) {
    int n = s[i++] - '0';
    while(isdigit(s[i])) n = n*10 + s[i++] - '0';
    return n;
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string str;
        cin >> str;
        int j = 0;
        cout << expr(str, j) << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

int n, m, t, a[mxN];
vi v;

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  string a, b;
  cin >> a >> b;
  string c = a + b;
  if (sqrt(stod(c)) - floor(sqrt(stod(c))) == 0 == true)
    cout << "Yes";
  else
    cout << "No";

  return 0;
}



Measured memory_bytes: 3712
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

//最大公約数
ll gcd(ll m, ll n) {
	if (n == 0)return m;
	return gcd(n, m % n);
}//gcd

void solve() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a<b || b>d) {
		cout << "No" << en;
		return;
	}
	if (d%b==0) {
		if (a % b > c) cout << "No" << en;
		else cout << "Yes"<<en;
		return;
	}
	if (c >= b) {
		cout << "Yes" << en;
		return;
	}
	ll g = gcd(b, d);
	if (b - g + a % g > c) cout << "No" << en;
	else cout << "Yes" << en;
}

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

	//solve();
	int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char a[1000],b[1000];
	scanf("%s %s",&a,&b);
	int la=strlen(a);
	int lb=strlen(b);
	if(la>lb) printf("GREATER\n");
	else if(la<lb) printf("LESS\n");
	else{
		for(int i=0;i<la;i++){
		        if(a[i]>b[i]){
		        	printf("GREATER\n");break;
				}
		        if(a[i]<b[i]){
		        	printf("LESS\n");break;
				}
		        if(a[i]==b[i]){
                   if(i==la-1 && a[i]==b[i])
		        	  printf("EQUAL\n");
		           else continue;
				}
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
#define PI 3.14159265359 
int main(void){
    int a,b,C;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&C);
    double S,L,h,c;
    S=(a*b*sin(C*PI/180.0))/2;
    c=pow(a,2)+pow(b,2)-2*a*b*cos(C*PI/180.0);
    c=sqrt(c);
    L=a+b+c;
    h=b*sin(C*PI/180.0);
    printf("%f\n%f\n%f\n",S,L,h);
    return 0;
}


Measured memory_bytes: 2928
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        int area = a*b;
        int length = 2*(a+b);
        System.out.println(area+" "+length);
    }
}


Measured memory_bytes: 26100
import scala.io.StdIn._

object Main {
  def replaceCard(l: List[String] = Nil): List[String] = {
    val originCard = readLine()

    if (originCard == "-") l
    else {
      val shuffleNum = readInt()

      def loop(n: Int, s: String): String = {
        if (n > 0) {
          val replaceCardNum = readInt()
          loop(n - 1, s.drop(replaceCardNum) + s.take(replaceCardNum))
        } else s
      }

      replaceCard(l :+ loop(shuffleNum, originCard))
    }
  }

  def main(args: Array[String]): Unit = {
    replaceCard().foreach(println)
  }
}

Measured memory_bytes: 43856
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
int main(){
	vector<int> m(10);
	for(int i = 0; i < 10; i++)
		scanf("%d\n", &m[i]);
	sort(m.begin(), m.end());
	for(int i = 0; i < 3; i++)
		printf("%d\n", m[9-i]);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cmath>
using namespace std;
typedef pair<int,int> pii;
#define MAXN 100007
#ifdef LOCAL
#define DBG(...) printf(__VA_ARGS__)
#else
#define DBG(...) (void)(0)
#endif
int vis[MAXN];
int a[MAXN];
long long s[MAXN];
int nn;
int st=-1;
int main() {
#ifndef LOCAL
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
	long long N;
	int x,y,m; cin >> N >> x >> m;
	y=x;
	memset(vis,0,sizeof vis);
	s[0]=0;
	for(nn=1; !vis[y]; nn++, y=1ll*y*y%m) {
		vis[y]=nn;
		a[nn]=y;
		s[nn]=s[nn-1]+a[nn];
		DBG("%d %d %d\n", nn, y, s[nn]);
	}
	nn--;
	st=vis[y];
	if(N>st) {
		long long ans=s[st-1]; N-=st-1;
		DBG("@st = %d %lld\n", st, ans);
		long long cnt=N/(nn-st+1);
		DBG("@cnt = %lld\n", cnt);
		long long rem=N%(nn-st+1);
		DBG("@rem = %lld\n", rem);
		ans=ans+cnt*(s[nn]-s[st-1])+(s[st-1+rem]-s[st-1]);
		DBG("@nn = %d, seg = %lld\n", nn, s[nn]-s[st-1]);
		cout << ans << '\n';
	} else {
		cout << s[N] << '\n';
	}
}


Measured memory_bytes: 4592
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    int p[n];
    for(int i = 0;i < n;i++)
    {
        cin >> p[i];
    }
    int ans = 0;
    int Min = p[0];
    for(int i = 0;i < n;i++)
    {    
        if(p[i] > Min)
        {
            continue;
        }
        else
        {
            Min = p[i];
            ans++;
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1024