akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    int W, H, N;
    cin >> W >> H >> N;
    int x1 = 0, x2 = W, y1 = 0, y2 = H;
    for (int i = 0; i < N; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) {
            x1 = max(x, x1);
        }
        if (a == 2) {
            x2 = min(x, x2);
        }
        if (a == 3) {
            y1 = max(y, y1);
        }
        if (a == 4) {
            y2= min(y, y2);
        }
    }
    cout << max(0, x2 - x1) * max(0, y2 - y1) << endl;
}

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

#define int long long
#define inf  1000000007
#define pb push_back
  using namespace std;


int po(int r,int k){
	if(k==1) return r;
	if(k%2) return po(r,k-1)*r%inf;
	int v=po(r,k/2);
	return v*v%inf;
}

int inv(int r){
	return po(r,inf-2);
}


int dp[2005][6005];
vector<pair<int,int>> G[2005];


void solve(){
	int n,m;
	if(!(cin>>n>>m))exit(0);
	if(n==0) exit(0);
	for(int i=0;i<n;i++)G[i].clear();
	for(int i=0;i<n;i++)for(int j=0;j<=3*n+4;j++)dp[i][j]=0;
	dp[0][0]=1;
	vector<int> nyu(n,0);
	
	for(int i=0;i<m;i++){
		int y,yy,yyy;
		cin>>y>>yy>>yyy;
		y--,yy--;
		G[y].pb({yy,yyy});
		nyu[yy]++;
	}
	
	// topological sort
	vector<int> topo(n);
	for(int i=0;i<n;i++)topo[i]=i;
	assert((int)topo.size()==n);
	
	// DP t= 0 ~ 3*n
	for(auto v:topo){
		for(int i=1;i<=3*n;i++){
				dp[v][i]+=dp[v][i-1];
				dp[v][i]%=inf;
		}
		for(auto w:G[v]){
		
			for(int i=0;i+w.second<=3*n;i++){
				dp[w.first][i+w.second]+=dp[v][i];
				dp[w.first][i+w.second]%=inf;
			}
		}
	}
	
	// 
	vector<int> frac(n+1,1);
	for(int i=1;i<=n;i++)frac[i]=frac[i-1]*i%inf;
	vector<int> frac_inv(n+1,1);
	frac_inv[n]=inv(frac[n]);
	for(int i=n;i>0;i--)frac_inv[i-1]=frac_inv[i]*i%inf;
	
	int Q;
	cin>>Q;

	while(Q--){
		
		int e,t;
		cin>>e>>t;
		e--;
		if(t<=3*n){
			cout<<dp[e][t]<<endl;
		}
		else{
			// i = 2*n ~ 3*n を使ってn次式を復元
			vector<int>bunsi_mae(n+1,0);
			bunsi_mae[0]=1;
			for(int i=1;i<=n;i++){
				bunsi_mae[i]=bunsi_mae[i-1]*(t-2*n-i+1)%inf;
			}
			vector<int>bunsi_ato(n+1,0);
			bunsi_ato[n]=1;
			for(int i=n-1;i>=0;i--){
				bunsi_ato[i]=bunsi_ato[i+1]*(t-2*n-i-1)%inf;
			}
			int bunsi_all=1;
			for(int i=2*n;i<=3*n;i++){
				bunsi_all*=t-i;
				bunsi_all%=inf;
			}
			
			int ans=0;
			for(int i=2*n;i<=3*n;i++){
				int bunsi=bunsi_mae[i-2*n]*bunsi_ato[i-2*n]%inf;
				int bunbo=frac_inv[i-2*n]*((3*n-i)%2?(inf-1)*frac_inv[3*n-i]%inf:frac_inv[3*n-i])%inf;
				ans+=dp[e][i]*bunsi%inf*(bunbo)%inf;
				ans%=inf;
			}
			cout<<ans<<endl;
		}
	}
}

 signed main(){
 	while(1) solve();
 	return 0;

  }
  


Measured memory_bytes: 97160
#include <iostream>
#include <cmath>
#include <vector>


using namespace std;

int main(){
  vector<int> a(4,0), b(4,0);
  while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){

    int hit=0;
    int blow=0;
    for(int i=0;i<a.size();i++){
      for(int j=0;j<b.size();j++){
	if(a[i]==b[j]){
	  if(i==j){
	    hit++;
	  }else{
	    blow++;
	  }
	}
      }
    }
    cout << hit << " " << blow << endl;
  }
}

Measured memory_bytes: 1192
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        int card[4][13];
        for(int i=0;i<4;i++){
                for(int j=0;j<13;j++){
                        card[i][j]=0;
                }
        }
        int n;
        scanf("%d",&n);
        for(int i=0;i<n;i++){
                char c;
                int m;
                cin>>c>>m;
                //scanf("%s %d",&c,&m);
                if(c=='S') card[0][m-1]=1;
                else if(c=='H') card[1][m-1]=1;
                else if(c=='C') card[2][m-1]=1;
                else if(c=='D') card[3][m-1]=1;
        }
        for(int i=0;i<4;i++){
                for(int j=0;j<13;j++){
                    if(i==0 && card[i][j]==0) printf("S %d\n",j+1);
                    else if(i==1 && card[i][j]==0) printf("H %d\n",j+1);
                    else if(i==2 && card[i][j]==0) printf("C %d\n",j+1);
                    else if(i==3 && card[i][j]==0) printf("D %d\n",j+1);
                }
        }
        return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main()
{
    f_io;
    ll n;
    cin >> n;
    vector<ll> arr(n),dp(n);
    foi(0,n)
        cin >> arr[i];
    dp[1] = abs(arr[0]-arr[1]);
    foi(2,n)
        dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 4716
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,A[100]={},count=0,k;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j=i;j<=n-1;j++){
            if(A[j]<A[minj]){
                minj=j;
            } 
        }
        if(A[i]>A[minj]){
            int tmp=A[i];
            A[i]=A[minj];
            A[minj]=tmp;
            count+=1;   
        }
        
    }
    for(int i=0;i<n;i++){
        if(i>0) cout<<" ";
        cout<<A[i];
    }cout<<endl;
    cout<<count<<endl;
    return 0;
}
    

    
    




Measured memory_bytes: 3096
#include<cstdio>
using namespace std;

const int N = 1000000;
int dp[2][N+1];

int main(){
  for(int i=0;i<=N;i++)dp[0][i] = dp[1][i] = N;
  dp[0][0] = dp[1][0] = 0;

  int val = 1;
  for(int i=1;val<=N;i++){
    for(int j=0;j+val<=N;j++){
      int nxt = j+val;
      if(dp[0][nxt]>dp[0][j])dp[0][nxt] = dp[0][j] + 1;
      if( (val&1) && (dp[1][nxt]>dp[1][j]))dp[1][nxt] = dp[1][j] + 1;
    }
    val *= (i+3), val /= i;
  }

  int n;
  while(scanf("%d",&n),n)printf("%d %d\n",dp[0][n],dp[1][n]);
}

Measured memory_bytes: 8840
#include<iostream>
using namespace std;
typedef long long ll;
ll p[51];
ll a[51];

ll f(ll n,ll k){
    //cout << "n=" << n << "k=" << k << endl;
    if(k == 1){
        if(n == 0){
            return 1;
        }
        else{
            return 0;
        }
        
    }
    else if(1 < k && k <= a[n-1] + 1){
        return f(n-1,k-1);
    }
    else if(k == a[n-1] + 2){
        return p[n-1] + 1;
    }
    else if(a[n-1] + 2 < k && k <= a[n-1] * 2 + 2){
        return p[n-1] + f(n-1,k-a[n-1]-2)+ 1;
    }
    else{
        return 2*p[n-1] + 1;
    }
}

int main(){
    ll n;ll k;cin >> n >> k;
    ll ans  = 0;
    p[0] = 1;
    a[0] = 1;
    for(int i=1;i<=50;i++){
        p[i] = p[i-1] * 2 + 1;
        //cout << p[i] << endl;
    }
    for(int i=1;i<=50;i++){
        a[i] = a[i-1] * 2 + 3;
        //cout << a[i] << endl;
    }
    ans = f(n,k);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX_N 100000

bool seen[MAX_N];
vector<P> G[MAX_N + 1];
int ans[MAX_N + 1];

void DFS(int now, int pre){
    if(seen[now]) return;
    seen[now] = true;
    int color = 1;
    REP(i,G[now].size()){
        if(color == pre) color++;
        if(seen[G[now][i].first]) continue;
        ans[G[now][i].second] = color;
        DFS(G[now][i].first, color);
        color++;
    }
    return;
}

signed main(){
    int n;
    cin >> n;
    int a,b;
    REP(i,n - 1){
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b, i);
        G[b].emplace_back(a, i);
    }
    DFS(0, 0);
    int mx = 0;
    REP(i,n - 1){
        mx = max(mx, ans[i]);
    }
    cout << mx << endl;
    REP(i,n - 1){
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main() {
  int N, sum=0;
  
  cin >> N;
  for(int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum = sum + r - l +1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
R, G, B, N = map(int, input().split())
ans = 0
for r in range(N//R + 1):
    for g in range((N - R*r)//G + 1):
        b = (N - (R*r+G*g)) / B
        if b == int(b):
            ans += 1
print(ans)


Measured memory_bytes: 40812
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

int main()
{
  int X, Y;
  cin >> X >> Y;

  int sum = 0;
  if (X == 3)
    sum += 100000;
  else if (X==2)
    sum += 200000;
  else if (X==1)
    sum += 300000;

  if (Y == 3)
    sum += 100000;
  else if (Y==2)
    sum += 200000;
  else if (Y==1)
    sum += 300000;

  if (X==1 && Y==1)
    sum += 400000;

  cout << sum << endl;

  return 0;
}


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

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    int ans = 0;
    for (int i = 0; i < N-2; i++)
    {
        for (int j = i+1; j < N-1; j++)
        {
            if (L[i] == L[j])
            {
                continue;
            }
            for (int k = j+1; k < N; k++)
            {
                if (L[i] == L[k] || L[j] == L[k])
                {
                    continue;
                }
                if (L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[j] + L[k] > L[i])
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

class info{
public:
	int id,penalty,num;
	info(int id,int penalty,int num):id(id),penalty(penalty),num(num){}
};

bool operator < (info a,info b){
	if(a.num!=b.num) return a.num>b.num;
	if(a.penalty!=b.penalty) return a.penalty<b.penalty;
	return a.id<b.id;
}


int main()
{
	int T,P,R;
	while(cin>>T>>P>>R && T!=0){
		vector<vector<bool> > done(T,vector<bool>(P,false));
		vector<vector<int> >  num_wrong(T,vector<int>(P,0));
		vector<int> num_correct(T,0);
		vector<int> penalty(T,0);

		for(int i=0;i<R;i++){
			int team,problem,time;
			string s;
			cin>>team>>problem>>time>>s;
			problem--;team--;
			if(s=="WRONG"){
				num_wrong[team][problem]++;
			}
			else{
				num_correct[team]++;
				penalty[team]+=num_wrong[team][problem]*1200+time;
			}
		}
		vector<info> work;
		for(int i=0;i<T;i++){
			work.push_back(info(i,penalty[i],num_correct[i]));
		}
		sort(work.begin(),work.end());
		for(int i=0;i<T;i++)
			cout<<work[i].id+1<<" "<<work[i].num<<" "<<work[i].penalty<<endl;
	}
}

Measured memory_bytes: 936
def fizzbuzz(i):
    if i % 15 == 0:
        return 'FizzBuzz'
    elif i % 5 == 0:
        return 'Buzz'
    elif i % 3 == 0:
        return 'Fizz'
    else:
        return str(i)

import sys
f = sys.stdin


while True:
    m, n = map(int, f.readline().split())
    if m == n == 0:
        break
    member = list(range(1, m + 1))
    s = [f.readline().strip() for _ in range(n)]

    pos = 0
    for i in range(n):
        if s[i] != fizzbuzz(i + 1):
            del member[pos]
            m = len(member)
            if m == 1:
                break
        else:
            pos += 1
        pos %= m
        
    print(*member)

Measured memory_bytes: 8556
#include<bits/stdc++.h>
#include<iomanip>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
using namespace std;

const long long INF=9000000000000000;
const long long mod=1000000007;
typedef long long ll;

int main(){
  int n,ans=0;
  cin>>n;
  vector<int> num(n);
  vector<int> aans(n);
  for(int i=0;i<n;i++){
    cin>>num[i];
    aans[i]=num[i];
  }
  sort(aans.begin(),aans.end());
  reverse(aans.begin(),aans.end());
  for(int i=0;i<n;i++){
    if(num[i]==aans[0])
    cout<<aans[1]<<endl;
    else
    cout<<aans[0]<<endl;
  }
}


Measured memory_bytes: 3200
#include <iostream>
#include <deque>
using namespace std;
typedef long long ll;
const int MAX_N = 200005;
int main(){
  int n;cin>>n;
  ll a[MAX_N];
  for(int i=1;i<=n;i++) cin >> a[i];
  deque<int> dq;
  for(int i=1;i<=n;i++){
    if(i % 2 == 1){
      if(n % 2 == 1){
        dq.push_front(a[i]);
      }else{
        dq.push_back(a[i]);
      }
    }else{
      if(n % 2 == 1){
        dq.push_back(a[i]);
      }else{
        dq.push_front(a[i]);
      }
    }
  }
  for(int i=0;i<n;i++){
    cout << dq[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

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

    int s = 0, num = n;
    while(num > 0){
        s += num % 10;
        num /= 10;
    }
    cout << (n % s ? "No" : "Yes") << endl;
}


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

int n;
int x[51], y[51];

int main() {
	int caseId = 0;
	
	while (cin >> n) {
		if (n == 0) break;
		caseId++;
		int i;
		for (i = 0; i < n; i++) cin >> x[i] >> y[i];
		x[n] = x[0]; y[n] = y[0];
		
		int area = 0;
		for (i = 0; i < n; i++) {
			area += x[i] * y[i + 1] - y[i] * x[i + 1];
		}
		printf("%d %.1f\n", caseId, abs(area) * 0.5);
	}
	return 0;
}

Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}

int main(){
       string s,t;
        cin>>s>>t;
       ll count1=0;
       rep(i,0,s.size(),1)if(s[i]!=t[i])count1++;
       cout<<count1<<endl;
}


// 1 2 3 1 5 3 1 0 1 0 2
// 1 2 3 4 5 6 7 8 9 10 11






Measured memory_bytes: 3852
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
	int H, W;
	while (true){
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}

}

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

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


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n, m;
	cin >> n >> m;

	ll ans = 0;
	ans += 1900*m+100*(n-m);
	rep(i, m) ans *= 2;
	co(ans);

	return 0;
}


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

using namespace std;

#define ll long long




void solve() {

	
	int k, x;	
	cin >> k >> x;
	for(int i = max(-1000000, x - k + 1); i <= min(1000000, x + k - 1); i++) {
		cout << i << " ";
	}	
	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	vector<ll> t, h, f, s, ans;
	rep(i, 1, 5000){
		t.push_back(6*i-4);
		h.push_back(6*i-3);
		f.push_back(6*i-2);
		s.push_back(6*i);
	}
	
	ll n;
	cin >> n;
	if(n == 3){cout << "2 5 63" << endl; return 0;}
	if(n == 4){cout << "2 5 20 63" << endl; return 0;}
	
	ll ti = min(5000LL, n/2-1);
	ll fi = min(5000LL, n/2-1);
	ll hi = min(5000LL, 2*((n-ti-fi)/2));
	ll si = n-ti-hi-fi;
	
	zep(i, 0, ti){ans.push_back(t[i]);}
	zep(i, 0, hi){ans.push_back(h[i]);}
	zep(i, 0, fi){ans.push_back(f[i]);}
	zep(i, 0, si){ans.push_back(s[i]);}
	
	zep(i, 0, ans.size()){cout << ans[i] << " ";}cout << endl;
	return 0;
}

Measured memory_bytes: 896
MAX_A = 10**6 + 1

def prim_gen():
    num = [i%2==1 for i in range(MAX_A)]
    num[0] = False; num[2] = True
    prim = set()
    prim.add(2)
    for i in range(3, MAX_A, 2):
        if num[i]: prim.add(i)
        for j in range(i+i, MAX_A, i): num[j] = False
    return prim

def solve():
    C = [0] * MAX_A
    for a in A: C[a] += 1
    pairwise = True
    for p in prim:
        if sum(C[p:MAX_A:p]) > 1: pairwise = False
    if pairwise: return 'pairwise'
    from math import gcd
    g = 0
    for a in A: g = gcd(g, a)
    if g == 1: return 'setwise'
    return 'not'

n = int(input())
A = [*map(int, input().split())]
prim = prim_gen()
print(solve(), 'coprime')


Measured memory_bytes: 127144
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("Failed to read line.");
    let x: Vec<&str> = input.trim().split_whitespace().collect();
    if x.len() == 3 {
        let mut count = 0;
        if x[0] == x[1]{
            count+=1;
        }
        if x[0] == x[2]{
            count+=1;
        }
        if x[2] == x[1]{
            count+=1;
        }
        if count == 1{
            println!("Yes");
        }
        else {
            println!("No")
        }
    }
}

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

int compare_int(const void *a,const void *b){
	return *(int*)a - *(int*)b;
}

int main(void){
	int n;
	int num[100];
	int i;
	int sum = 0;
	while(scanf("%d",&n)){
		if(n == 0){
			break;
		}
		for(i = 0;i < n;i++){
			scanf("%d",&num[i]);
		}
		qsort(num,n,sizeof(int),compare_int);
		num[0] = 0; num[n-1] = 0;
		for(i = 0;i < n;i++){
			sum += num[i];
		}
		printf("%d\n",sum / (n - 2));
		sum = 0;
	}
	return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	int n;
	double x[111111];
	string u[111111];
	cin>>n;
	double ans=0;
	for(int i=0;i<n;i++){
	    cin>>x[i]>>u[i];
	    if(u[i]=="JPY"){
	        ans+=x[i];
	    }
	    else ans+=x[i]*380000;
	}
	cout<<ans<<endl;
	

}

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

int main() {
	int		a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	str;
	
	cin >> k >> x;
	
	if ( k*500 >= x ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	

}


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

void chmin(int& a, int b){
    a = min(a, b);
}

const int Tmax = 10000;
int N, M;
int Dst[Tmax];

int dist[400][400], E[400][400], Nxt[400][400];

void initialize(){
    cin >> N >> M;
    for(int i=0; i<M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        E[a][b] = E[b][a] = c;
    }
    int _; cin >> _;
    for(int i=0; i<Tmax; i++){
        int n; cin >> n;
        if(n) cin >> _ >> Dst[i];
        Dst[i]--;
    }

    for(int i=0; i<N; i++) for(int j=0; j<N; j++) if(i != j) dist[i][j] = (E[i][j] ? E[i][j] : 1e9);
    for(int k=0; k<N; k++) for(int i=0; i<N; i++) for(int j=0; j<N; j++) chmin(dist[i][j], dist[i][k] + dist[k][j]);
    for(int i=0; i<N; i++) for(int j=0; j<N; j++){
        for(int k=0; k<N; k++) if(i != k && E[i][k] && E[i][k] + dist[k][j] == dist[i][j]){
            Nxt[i][j] = k;
            break;
        }
    }
}

vector<int> ans;
vector<int> stock[400], have[400];
int pos, now, havesum;
int64_t score;
int scorenum = 0;

void addtime(){
    if(now < Tmax && Dst[now] >= 0) stock[Dst[now]].push_back(now);
    now++;
}
void visit(int v){
    if(now > Tmax) return;
    cerr << "Visit " << v << " on " << now << endl;
    if(v == 0) for(int i=0; i<N; i++){
        for(int a : stock[i]) have[i].push_back(a);
        havesum += stock[i].size();
        stock[i].clear();
    }
    for(int a : have[v]) score += Tmax*Tmax - (now-a)*(now-a);
    scorenum += have[v].size();
    havesum -= have[v].size();
    have[v].clear();
}

void moveto(int v){
    if(pos == v){
        addtime();
        ans.push_back(-1);
        visit(pos);
        return;
    }
    while(pos != v){
        int nxt = Nxt[pos][v];
        int d = E[pos][nxt];
        bool leave = false;
        while(d--){
            addtime();
            if(!leave) visit(pos);
            leave = true;
            ans.push_back(nxt);
        }
        pos = nxt;
        visit(nxt);
    }
}

int main(){
    initialize();
    int len = 0;
    while(ans.size() < Tmax){
        if(havesum <= 100 || len >= 15){
            moveto(0);
            len = 0;
            continue;
        }
        len++;
        int nxt = 0;
        double eff = 0;
        for(int i=0; i<N; i++){
            int p = pos, tm = now;
            double eff2 = 0;
            while(p != i){
                tm += E[p][Nxt[p][i]];
                p = Nxt[p][i];
                for(int a : have[p]) eff2 += Tmax*Tmax - (tm-a)*(tm-a);
            }
            eff2 /= dist[pos][i];
            if(eff < eff2){
                nxt = i;
                eff = eff2;
            }
        }
        moveto(nxt);
        cerr << "!!iter!!" << endl;
    }
    ans.resize(Tmax);
    for(int a : ans) cout << (a == -1 ? -1 : a+1) << endl;
    cerr << "score: " << score << endl;
    cerr << "scorenum: " << scorenum << endl;
}


Measured memory_bytes: 2304
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
x,y,z = 0,0,0
for i in p:
    if i <= a:
        x += 1
    elif b+1 <= i:
        z += 1
    else:
        y += 1
print(min(x,y,z))

Measured memory_bytes: 9040
s=[int(c) for c in input()]
n=len(s)
dp=[0]*n
dp2=[0]*n

dp[0]=s[0]
dp2[0]=s[0]
for i in range(1,n):
    dp2[i]=dp2[i-1]*10+s[i]*2**i
    dp[i]=dp2[i]+2*dp[i-1]-dp2[i-1]

print(dp[n-1])

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

const int maxn=20;
int n,x,y,a,ans;
int g[maxn][maxn][2],p[maxn];

void dfs(int x)
{
	if(x==n+1) {
		for(int i=1;i<=n;++i) {
			if(p[i]) {
				for(int j=1;j<=n;++j) {
					if(g[i][j][0]==1&&p[j]==1) return ;
					if(g[i][j][1]==1&&p[j]==0) return ;
				}
			}
		}
		int cnt=0;
		for(int i=1;i<=n;++i) cnt+=p[i];
		ans=max(ans,cnt);
		return ; 
	}
	p[x]=1;
	dfs(x+1);
	p[x]=0;
	dfs(x+1);
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%d",&a);
		for(int j=1;j<=a;++j) {
			scanf("%d %d",&x,&y);
			g[i][x][y]=1;
		}
	}
	dfs(1);
	printf("%d",ans);
}

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

int main() {
	long long N, A, B, INF = 1000000000000000000;
	cin >> N >> A >> B;
	vector<long long> P(N);
	vector<vector<long long> > DP(N + 1, vector<long long>(N + 1, INF));
	DP[0][0] = 0;
	for (int i = 0; i < N; i++) cin >> P[i];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= N; j++) {
			if (DP[i][j] >= INF) continue;
			if (j < P[i]) {
				DP[i + 1][P[i]] = min(DP[i + 1][P[i]], DP[i][j]);
				DP[i + 1][j] = min(DP[i + 1][j], DP[i][j] + A);
			}
			else {
				DP[i + 1][j] = min(DP[i + 1][j], DP[i][j] + B);
			}
		}
	}
	long long ANS = INF;
	for (int i = 0; i <= N; i++) {
		ANS = min(ANS, DP[N][i]);
	}
	cout << ANS << endl;
}

Measured memory_bytes: 195840
#include <iostream>
#include <stdlib.h>
using namespace std;

void DFS(int* arr, int pos, int* res, int index, bool& flag) {
	if (pos >= 10||flag)
	{
		return;
	}
	if ((index==0) || (index >= 1 && res[index - 1] < arr[pos]))
	{
		res[index] = arr[pos];
		arr[pos] = 0;
	}
	DFS(arr, pos+1, res, index+1, flag);
	if (flag)
	{
		return;
	}
	int pre = 0;
	int cur = 0;
	flag = true;
	for (int i = 0; i < 10; i++)
	{
		if (arr[i]!=0)
		{
			pre = pre == 0 ? arr[i] : cur;
			cur = arr[i];
			if (cur < pre)
			{
				flag = false;
				break;
			}
		}
	}
}

int main()
{
	int N, arr[11], res[10];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			cin >> arr[j];
		}
		bool flag = false;
		DFS(arr, 0, res, 0, flag);
		if (flag)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2988
N = input()
list1 = list(map(int,input().split()))
list2 = []
for i in range(min(list1),max(list1)+1):
    a = 0
    for j in range(len(list1)):
        a += (list1[j] - i)**2
    list2.append(a)
print(min(list2))

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

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            n = int.Parse(Console.ReadLine());
            if (n % 10 == 9 || n / 10 == 9)
                Console.WriteLine("Yes");
                else

                Console.WriteLine("No");
            


            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>

int main(void){
   int w,a,b;
   int r1r,r1l,r2r,r2l;
   scanf("%d%d%d",&w,&a,&b);

   r1l=a; r1r=a+w;
   r2l=b; r2r=b+w;

   if(r1r<r2l) printf("%d\n",r2l-r1r);
   else if(r1l>r2r) printf("%d\n",r1l-r2r);
   else printf("0\n");
   return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
	int d,n; cin>>d>>n;
	long ans=1;
	rep(i,d){
		ans*=100;
	}
	ans*=n;
	if(d==0&&n==100) ans+=1;
	if(d==1&&n==100) ans+=1*100;
	if(d==2&&n==100) ans+=1*10000;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;
#define ALL(x)			(x).begin(),(x).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF				(int)2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;
typedef vector<ll>		VLL;
typedef vector<VLL>		VVLL;
typedef vector<VVLL>	VVVLL;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int N, C;
	cin >> N >> C;
	VLL s(N), t(N), c(N);
	REP(i, N) {
		cin >> s[i] >> t[i] >> c[i];
		c[i]--;
	};

	VVLL cSum(C, VLL(100001, 0));
	REP(i, N) {
		ll ch = c[i];
		cSum[ch][s[i]]++;
		cSum[ch][t[i]]--;
	}

	ll ans = 0;
	ll nowNum = 0;
	VLL totalSum(100001, 0);
	REP(i, totalSum.size()) {
		REP(j, C) {
			if (1 == cSum[j][i]) {
				nowNum++;
			}
		}
		ans = max(ans, nowNum);
		REP(j, C) {
			if (-1 == cSum[j][i]) {
				nowNum--;
			}
		}
	}

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


Measured memory_bytes: 26880
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim S As String = NextString()

        For i As Integer = Asc("a"c) To Asc("z"c)
            Dim c As Char = Chr(i)
            If Not S.Contains(c) Then
                WriteLine(c)
                Exit Sub
            End If
        Next

        WriteLine("None")
    End Sub

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 21968
#include <cassert>
#include <iostream>
#include <vector>
/*
` `: Free
`Q`: Queen
`A`: Attackable
*/
typedef std::vector<std::vector<char> > TBoard;
struct TResult
{
    TBoard Board;
    bool IsOk;
    TResult(const TBoard& ABoard, bool AIsOk)
     : Board(ABoard), IsOk(AIsOk){}
};
TBoard AddQueen(const TBoard& ABoard, int r, int c)
{
    TBoard Board = ABoard;
    assert(Board[r][c] == ' ');
    Board[r][c] = 'Q';
    for(int i = 0; i < 8; ++i){
        Board[i][c] = 'A';
    }
    for(int i = 0; i < 8; ++i){
        Board[r][i] = 'A';
    }
    for(int i = -std::min(r, c); i < 8 - std::max(r, c); ++i){
        Board[r+i][c+i] = 'A';
    }
    for(int i = -std::min(r, 7-c); i < 8 -std::max(r, 7-c); ++i){
        Board[r+i][c-i] = 'A';
    }
    Board[r][c] = 'Q';
    return Board;
}

TResult Solve(const TBoard& ABoard, int n)
{
    if(n == 0) return TResult(ABoard, true);
    TBoard Board = ABoard;
    for(int r = 0; r < 8; ++r){
        for(int c = 0; c < 8; ++c){
            if(Board[r][c] != ' ') continue;
            TResult Result = Solve(AddQueen(Board, r, c), n-1);
            if(Result.IsOk) return Result;
        }
    }
    return TResult(Board, false);
}
void Print(const TBoard& Board, std::ostream& out)
{
    for(int r = 0; r < 8; ++r){
        for(int c = 0; c < 8; ++c){
            char symbol = Board[r][c] == 'Q' ? 'Q' : '.';
            out << symbol;
        }
        out << std::endl;
    }
}
int main()
{
    int k;
    std::cin >> k;
    TBoard Board(8, std::vector<char>(8, ' '));
    for(int i = 0; i < k; ++i){
        int r, c;
        std::cin >> r >> c;
        Board = AddQueen(Board, r, c);
    }
    TResult Result = Solve(Board, 8 - k);
    Print(Result.Board, std::cout);
    return 0;
    
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N),F(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> F[i];
    // 大きいものと小さいものがペアになるように掛け算をする
    sort(A.begin(),A.end());
    sort(F.rbegin(),F.rend());
    ll ok = 1000000000100;
    ll ng = -1;
    ll AAA = 0;
    while(ok-ng>1){
        AAA++;
        ll mid = (ok+ng)/2;
        ll cnt = 0;
        bool f = true;
        rep(i,N){
            if(A[i]*F[i]>mid){
                cnt+=(A[i]-mid/F[i]);
                if(cnt>K){
                    ng = mid;
                    f = false;
                    break;
                }
            }
        }
        if(f) ok = mid;
    }
    cout << ok << endl;
    return 0;
}

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

int main(int argc, char *argv[])
{
   
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, q, S[100100], T[50000];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> S[i];
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> T[i];
    }
    int cnt = 0;
    for (int i = 0; i < q; i++) {
        if (binary_search(S, S + n, T[i])) {
            cnt++;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}



Measured memory_bytes: 3648
import java.lang.*;
import java.io.*;
import java.util.*;


public class Main {

	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {

	public void solve(InputReader in, PrintWriter out) {
		String s = in.next();
		int slen = s.length();
		StringBuilder sb = new StringBuilder();

		for (int i=0; i<slen; ++i) {
			if (s.charAt(i) == ',')
				sb.append(' ');
			else
				sb.append(s.charAt(i));
		}

		out.println(sb.toString());
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;


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

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}
}

Measured memory_bytes: 23380
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        int prev = reader.nextInt();
        reader.close();
        Set<Integer> numbers = new HashSet<>();
        int i = 1;
        do {
            ++i;
            numbers.add(prev);
            prev = f(prev);
        } while (!numbers.contains(prev));
        System.out.println(i);
    }

    private static int f(int n) {
        return n % 2 == 0 ? n / 2 : 3 * n + 1;
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long  n,k;
    cin>>n>>k;
    vector<long long>a(n),f(n);
    for(int i=0;i<n;i++)
	{
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
	{
        cin>>f[i];
    }
    sort(a.begin(),a.end());
    sort(f.begin(),f.end());
	reverse(f.begin(),f.end());
    long long  cnt = -1;
    long long  ans = 1e13+10;
    while (abs(ans - cnt)>1)
	{
        long long  mid = (ans + cnt) / 2;
        long long  ss = 0;
        for(int i=0;i<n;i++){
            if(a[i]*f[i]>mid)
			{
                ss+=a[i]-(mid/f[i]);
            }
        }
        if (ss<=k)
		{
			ans=mid;
		}
        else
		{
			cnt=mid;
		}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int &i:A)
    cin>>i;
  sort(A.begin(),A.end());
  vector<int> B(N);
  B[0]=0;
  for(int i=0;i<N-1;i++)
    B[i+1]=B[i]+A[i];
  for(int i=N-1;i>=0;i--){
    if(B[i]*2<A[i]){
      cout<<N-i<<endl;
      return 0;
    }
  }
  cout<<N<<endl;
}

Measured memory_bytes: 4764
def getlist():
	return list(map(int, input().split()))

S = input()
N = len(S)
v1 = S[0]
v2 = ""
ans = 1
for i in range(1, N):
	v2 += S[i]
	if v1 != v2:
		ans += 1
		v1 = v2
		v2 = ""


print(ans)

Measured memory_bytes: 3500
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

a = int(input())
b = int(input())
h = int(input())
ans = (a+b)*h/2
print(int(ans))

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n, AC = 0, WA = 0, TLE = 0, RE = 0;
    string s;

    cin >> n;
    for (int i = 0 ; i < n ; i++)
    {
        cin >> s;
        if (s == "AC")
            AC++;
        else if (s == "WA")
            WA++;
        else if (s == "TLE")
            TLE++;
        else if (s == "RE")
            RE++;
    }
    cout << "AC x " << AC << "\nWA x " << WA << "\nTLE x " << TLE << "\nRE x " << RE << endl;
    return 0;
}


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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ref=INT32_MAX;
    for(int i = 0; i < n-1; i++) {
        ref=min(ref,__gcd(a[i],a[i+1]));
        if(ref==1) break;
    }
    cout << ref << "\n";
    return 0;
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int main(){
    fcin;

    int n;
    cin >> n;

    unordered_map<string, int> f;
    
    int m = 0;
    while(n--){
        string s;   cin >> s;
        f[s]++;
        m = max(m, f[s]);
    }

    set<string> s;
    for(auto it = f.begin(); it != f.end(); it++) if(it->se == m) s.insert(it->fi);

    for(auto i : s) cout << i << endl;
    return 0;
}



Measured memory_bytes: 32072
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

struct Team {
    int team_id;
    int ac_num;
    int time;
    int fail[10];
};

auto cmp = [](Team x, Team y) {
    if (x.ac_num != y.ac_num) {
        return x.ac_num > y.ac_num;
    }
    else if (x.time != y.time) {
        return x.time < y.time;
    }
    else {
        return x.team_id > y.team_id;
    }
};

int main()
{
    int M, T, P, R;
    int m, p, t, j;
    vector<Team> team(50);

    while(1) 
    {
        cin >> M >> T >> P >> R;
        if ((M == 0) && (T == 0) && (P == 0) && (R == 0)) {
            break;
        }

        for (int i = 0; i < 50; i++) {
            team[i].team_id = i+1;
            team[i].ac_num = 0;
            team[i].time = 0;
            for (int j = 0; j < 10; j++) {
                team[i].fail[j] = 0;
            }
        }
        
        for (int i = 0; i < R; i++) {
            cin >> m >> t >> p >> j;
            if (j != 0) {
                team[t-1].fail[p-1] += 1;
            }
            else {
                team[t-1].ac_num += 1;
                team[t-1].time += m;
                if (team[t-1].fail[p-1] > 0) {
                    team[t-1].time += 20*team[t-1].fail[p-1];
                }
            }
        }

        sort(team.begin(), team.begin()+T, cmp);

        for (int i = 0; i < T; i++) {
            if (i == 0)
                cout << team[i].team_id;
            else {
                if (team[i].ac_num != team[i-1].ac_num)
                    cout << "," << team[i].team_id;
                else if (team[i].time != team[i-1].time)
                    cout << "," << team[i].team_id;
                else {
                    cout << "=" << team[i].team_id;
                }
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
// $%U%$
// $%D%$/$%M%$/$%Y%$
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
const int INF = 1e9 + 7;
const ll mod = 998244353;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}

int main(){
    int n = nxt(), q = nxt();
    ll black = ll(n-2)*(n-2);
    VI a(n+1, n), b(n+1, n);
    int h = n, w = n;
    while(q--){
        int t, x;
        cin >> t >> x;
        if(t == 1){
            if(x < w){
                for(int i = x; i < w; i++){
                    b[i] = h;
                }
                w = x;
            }
            black -= b[x] - 2;
        }
        else{
            if(x < h){
                for(int i = x; i < h; i++){
                    a[i] = w;
                }
                h = x;
            }
            black -= a[x] - 2;
        }
    }
    printf("%lld\n", black);
    return 0;
}




Measured memory_bytes: 4864
/*
貪欲
後ろから見る
DP
順位表をチェック
二分探索


*/
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
#include<set>
using namespace std;
#define INF 1100000000000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair< pair<int,int>,pair<int,int> > p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());


int main(){
    int N;
    cin>>N;
    ll sum=0,x=1100000000;
    bool flag=true;
    for(int i=0;i<N;i++){
        ll A,B;
        cin>>A>>B;
        if(A!=B) flag=false;
        if(A>B) x=min(x,B);
        sum+=A;
    }
    if(flag) cout<<0<<endl;
    else{
        cout<<sum-x<<endl;
    }

}


Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main()
{
  int h,m,z=0;
 char array[100][100];
  cin>>h>>m;
  for(int i=0;i<h;i++){
        for(int j=0;j<m;j++)
        cin>>array[i][j];
  }
  for(int i=0;i<h;i++){
        for(int j=0;j<m;j++){
                z=0;
            if(array[i][j]=='.')
                {if(array[i][j-1]=='#'&&j!=0)z+=1;
                if(array[i][j+1]=='#'&&j!=m-1)z+=1;
                    if(array[i-1][j]=='#'&&i!=0)z+=1;
                    if(array[i-1][j-1]=='#'&&j!=0&&i!=0)z+=1;
                    if(array[i-1][j+1]=='#'&&i!=0&&j!=m-1)z+=1;
                    if(array[i+1][j]=='#'&&i!=h-1)z+=1;
                    if(array[i+1][j-1]=='#'&&i!=h-1&&j!=0)z+=1;
                    if(array[i+1][j+1]=='#'&&i!=h-1&&j!=m-1)z+=1;cout<<z;
                }else cout<<'#';
            }
            cout<<endl;}

return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())

    data = []
    for i in range(N):
        A = int(input())
        items = []
        for j in range(A):
            x, y = map(int, input().split())
            items.append((x-1, y))
        data.append(items)

    ans = 0

    for i in range(1, 2**N):
        tmp = 0
        flag = True
        for j in range(N):
            if (i>>j)&1 == 1:
                tmp += 1
                for d in data[j]:
                    if (i>>d[0])&1 != d[1]:
                        flag = False
        if (flag) & (tmp > ans):
            ans = tmp
    print(ans)

    return 0
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {


	int n;
	cin >> n;
	vector<int>p(n);
	for (int i = 0; i < n; i++)cin >> p[i];
	int ans = 0;
	while (1) {
		int t = ans;
		bool f = 0;
		for (int i = 0; i < n; i++) {
			if (p[i]) {
				if (!f) {
					f = 1; ans++;
					p[i]--;
				}
				else p[i]--;
			}
			else f = 0;
		}
		if (t == ans)break;
	}
	cout << ans << endl;

	return 0;

}

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

using namespace std;

int main(int argc, char const *argv[])
{
    long long N;
    cin >> N;

    long long sum = 0;
    long long prv;
    long long num = 1;
    int i;
    for (i = 1; ; i++)
    {
        prv = sum + 1;
        num *= 26;
        sum += num;
        if (N <= sum) break;
    }
    
    string S;
    long long ord = N - prv;
    for (int j = 0; j < i; j++)
    {
        S.push_back((char)(int)(97 + ord % 26));
        ord = (ord - (ord % 26)) / 26;
    }
    
    
    reverse(S.begin(), S.end());
    cout << S << endl;

    return 0;
}

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

int main(void) {
    int N, P; cin >> N >> P;
    int flag = 0;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (a % 2) flag = 1;
    }
    
    if (flag) {
        long long ans = 1;
        for (int i = 0; i < N-1; i++) {
            ans *= 2;
        }
        cout << ans << endl;
    } else if (!P) {
        long long ans = 1;
        for (int i = 0; i < N; i++) {
            ans *= 2;
        }
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256