akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<cfloat>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<numeric>
#include<functional>
using namespace std;

const int mod = 1e9+7;
const int INFINT = INT_MAX/2;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Block;

vector<ull> SnukeColoring(ull H, ull W, vector<Block> &blocks){
    vector<ull> res(10, 0);
    int N = blocks.size();
    if(N==0){
        res[0] = (H-2)*(W-2);
        return res;
    }
    vector<Block> count;
    for(int i=0;i<N;i++){
        ll a = blocks[i].first;
        ll b = blocks[i].second;
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(a-j >= 0 && a-j < H-2 && b-k >= 0 && b-k < W-2){
                    count.push_back(make_pair(a-j, b-k));
                }
            }
        }
    }
    sort(count.begin(), count.end());
    Block b = count[0];
    int ind = 0;
    int size = 0;
    while(ind < count.size()){
        if(b == count[ind]){
            size++;
            ind++;
        }else{
            res[size]++;
            size = 0;
            b = count[ind];
        }
    }
    res[size]++;
    res[0] = (H-2)*(W-2) - accumulate(res.begin(), res.end(), 0ull);
    return res;
}

int main(){
    ull H, W, N, a, b;
    cin >> H >> W >> N;
    vector<Block> blocks(N);
    for (int i=0;i<N;i++){
        cin >> a >> b;
        blocks[i] = make_pair(a-1, b-1);
    }
    vector<ull> res = SnukeColoring(H, W, blocks);
    for(int i=0;i<res.size();i++){
        cout << res[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 11244
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;




int main(){
    int N,K;cin >> N >> K;
    vector<LL> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    vector<LL> cum;
    for (int i = 0; i < N; i++) {
        LL sum=0;
        for (int j = i; j < N; j++) {
            sum+=a[j];
            cum.pb(sum);
        }
    }
    sort(RALL(cum));
    vector<bool> f(cum.size(),true);
    LL ans=0;
    for (int k = 45; k >=0 ; k--) {
        vector<bool> s(cum.size(),false);
        int count=0;
        for (int i = 0; i < cum.size(); i++) {
            if(f[i]){
                if((cum[i]>>k)&1){
                    count++;
                    s[i]=true;
                }
            }
        }
        if(count>=K){
           ans+=(1LL<<k);
           for (int i = 0; i < cum.size(); i++) {
               f[i]=s[i];
           }
        }
    }
    cout << ans << endl;
    return 0;
}


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

ll dp[110][110000];

int main() {
    int n, W; cin >> n >> W;
    ll w[n], v[n];
    rep(i, n) cin >> w[i] >> v[i];
    rep(i, n) {
        rep(j, W+1) {
            if(w[i] <= j) chmax(dp[i+1][j], dp[i][j-w[i]]+v[i]);
            chmax(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[n][W] << endl;
}

Measured memory_bytes: 87424
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define end cout<<'\n';
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
int main()
{
fast;
    string s,t;
    cin>>s>>t;
    ll n=s.size();
    ll n1=t.size();
    ll dp[n+1][n1+1];
    memset(dp,0,sizeof(dp));
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=n1;j++)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    ll index=dp[n][n1];  
    char lcs[index+1]; 
 //   cout<<index<<endl;
    lcs[index] = '\0'; 
    ll i=n,j=n1; 
    while(i>0&&j>0) 
    {  
      if(s[i-1]==t[j-1]) 
      { 
          lcs[index-1]=s[i-1];  
          i--; j--;index--;      
      } 
      else if (dp[i-1][j]>dp[i][j-1]) 
         i--; 
      else
         j--; 
   }
    cout<<lcs;
    return 0;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
int main(){

   long long int n,a,b,c,d,e,f,g,i,j,k,l,t,u;
   double res,arr[100][100];
   string x,y;
   char ch,ch1;
   vector<int> v;
   vector<int> v1;
   cin>>a>>b;
   if(a<=b){
     cout<<"unsafe"<<endl;
   }
   else cout<<"safe"<<endl;

 return 0;
}


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

int main(){
int n;
scanf("%d",&n);
double base = 100000;
for(int i=0;i<n;i++){
base*=1.05;
if((int)base %1000 !=0) {
int tmp = (int)base / 1000;
base = tmp*1000 + 1000;
}

}
printf("%d\n",(int)base);
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class Main {
    static final int MAX = 1000;
    static final int VMAX = 10000;

    public static void main(String[] args) throws Exception {
        // 入力
        int n = 0;
        int[] A = new int[MAX];
        int min = VMAX;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            n = Integer.parseInt(br.readLine());
            String[] lines = br.readLine().split(" ");
            for (int i = 0; i < n; i++) {
                A[i] = Integer.parseInt(lines[i]);
                min = Math.min(min, A[i]);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        // 最小コストソート
        int ans = 0;
        boolean[] isProcessed = new boolean[MAX];
        int[] B = new int[MAX];
        System.arraycopy(A, 0, B, 0, n);
        // 与えられた数列が昇順でそれぞれ何番目かを
        // バケット法で調べる
        Arrays.sort(B, 0, n);
        int[] order = new int[VMAX + 1];
        for (int i = 0; i < n; i++) {
            order[B[i]] = i;
        }

        for (int i = 0; i < n; i++) {
            // 真ならばサイクルで計算済みなので飛ばす
            if (isProcessed[i]) {
                continue;
            }

            int cur = i;
            // サイクル内の合計
            int cycleSum = 0;
            // サイクル内の最小値
            int cycleMin = VMAX;
            // サイクルに含まれた数
            int cycleN = 0;
            // サイクルを一周するまで
            while (true) {
                isProcessed[cur] = true;
                cycleN++;
                int v = A[cur];
                cycleMin = Math.min(cycleMin, v);
                cycleSum += v;// ΣWiの部分
                cur = order[v];// ソート前の数列Aの値の移動先の添字
                if (isProcessed[cur]) {
                    // サイクルを一周したのでループを抜ける
                    break;
                }
            }
            ans += Math.min(cycleSum + (cycleN - 2) * cycleMin, cycleSum + cycleMin + (cycleN + 1) * min);
        }

        // 出力
        System.out.println(ans);
    }
}



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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    string N;
    int sum = 0; 
    cin>>N;
    REP(i, 0, N.size()){
        sum += (int)(N[i] - '0');
    }
    string ans = "No";
    if(sum % 9 == 0) ans = "Yes";
    cout << ans << endl;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    ll ans=0;
    for(int i=0;i<=n/r;i++){
        for(int j=0;j<=(n-r*i)/g;j++){
            if((n-r*i-g*j)%b==0)ans++;
        }
    }
    cout<<ans<<endl;
}


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

bool f[100][100];

int H,W;
int bfs() {
  vector<vector<int>> dist(H + 1,vector<int>(W + 1, -1));
  queue<pair<int,int>> que;
  que.push({1,1});
  dist[1][1] = 1;
  int d[] = {0,0,1,-1};
  while(!que.empty()) {
    auto p = que.front();
    int x = p.first;
    int y = p.second;
    que.pop();
    for(int i = 0;i < 4;i++) {
      int a = x + d[i ^ 2];
      int b = y + d[i];
      if(!f[a][b]) continue;
      if(dist[a][b] != -1) continue;
      dist[a][b] = dist[x][y] + 1;
      que.push({a,b});
    }
  }

  return dist[H][W];
}

int main() {
  cin >> H >> W;
  int cnt = 0;
  rep(i,1,H) {
    string s;
    cin >> s;
    rep(j,1,W) {
      if(s[j - 1] == '.') f[i][j] = true;
      else cnt++;
    }
  }
  int b = bfs();
  if(b == -1) {
    cout << -1 << endl;
    return 0;
  }
  cout << H * W - cnt - b << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;
vector<int>a[100020];
int n,m,x,y,c[100005],cnt[3];
bool dfs(int x, int y){
	if(c[x]){
		if(c[x] != y) return true;
		return false;
	}
	c[x] = y;
	++cnt[y - 1];
	y ^= 3;
	for(int i = 0; i < a[x].size();i++)
		if(dfs(a[x][i],y)) return true;
	return false;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i = 0;i < m; i++){
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	if(dfs(1,1)){
		printf("%lld\n",(LL)n * (n - 1) /2 - m);
	}
	else{
		printf("%lld\n",(LL)cnt[0] * cnt[1] - m);
	}
}


Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;


int main(void){
    int s,w;
    cin>>s>>w;
    if(w>=s)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;

string RecoverString(VVI &dp, int st, int ss, string &s) {
    string ans = "";
    while(st > 0 && ss > 0) {
        if(dp[st][ss] == dp[st-1][ss]) st--;
        else if (dp[st][ss] == dp[st][ss-1]) ss--;
        else {
            st--;
            ss--;
            ans.push_back(s[ss]);
        }
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

string Main(string &s, string &t) {
    int ss = s.size();
    int st = t.size();
    VVI dp(st+1, VI(ss+1, 0));
    REP(i, st) {
        REP(j, ss) {
            if(t[i] == s[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else {
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }
    string res = RecoverString(dp, st, ss, s);
    return res;
}

int main(void) {
    string s, t;
    cin >> s;
    cin >> t;
    cout << Main(s, t) << endl;
    return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
int main()
{
    ll n;
    scanf("%lld",&n);
    ll ans=0;
    ll a=n/500;
    ll b=(n-a*500)/5;
    ans=a*1000+b*5;
    printf("%lld\n",ans);
    return 0;
}

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

#ifndef DEBUG
#define DEBUG false
#endif

#define REP(t,i,a,b) for(t i = a; i < b; ++i)

typedef long long ll;

ll calc(ll goal, std::vector<ll>& h)
{
    if (goal == 0) return 0;
    ll ret = 0;
    for(ll i=goal-1; i>=0; --i) {
        if (h[i] >= h[i+1]) ++ret;
        else break;
    }
    return ret;
}

int main (void) {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    ll n;
    std::cin >> n;
    std::vector<ll> h(n);
    REP(ll, i, 0, n) std::cin >> h[i];

    ll max_c = 0;
    ll goal = n - 1;
    while(goal >= 0) {
        ll c = calc(goal, h);
        if (c >= max_c) max_c = c;
        goal -= c + 1;
    }

    std::cout << max_c << std::endl;

    return 0;
}

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

vector<pair<int,int>> g[100100];
long long dp[100100];

void solve(int u,int pa=-1){
    for(auto e:g[u]){
        int v=e.first;
        int c=e.second;
        if(v==pa) continue;
        dp[v]=dp[u]+c;
        solve(v,u);
    }
}

int main(){
    int N; cin >> N;
    for(int i=0;i<N-1;i++){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        g[a].push_back({b,c});
        g[b].push_back({a,c});
    }
    int q,K; cin >> q >> K;
    K--;
    dp[K]=0;
    solve(K);
    while(q--){
        int x,y; cin >> x >> y;
        x--;y--;
        cout << dp[x]+dp[y] << endl;
    }
}

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

public class Main{
	public static void main(String args[]){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{
			String strX = insBR.readLine();
			int intX = Integer.parseInt(strX);
			int intCube = intX * intX * intX;
			System.out.println(intCube);
		}catch(IOException e){

		}catch(NumberFormatException e){

		}


	}
}


Measured memory_bytes: 24220
#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 RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.precision(10);

	int N;
	cin>>N;

	int m=(sqrt(1+8*N)-1)/2;
	if(m*(m+1)/2==N){
		REP(i, m){
			cout<<i+1<<endl;
		}
	}else{
		vector<int> v(m);
		REP(i, m){
			v[i]=i+1;
		}
		v[(m+1)*(m+2)/2-N-1]=m+1;
		REP(i, m){
			cout<<v[i]<<endl;
		}
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ss(x) (int) x.size()
#define cat(x) cout << #x << " = " << x << endl
 
using namespace std;

int n;
int a[200001];
ll best = 1e18;
ll sum = 0, S = 0;

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		S += a[i];
	}
	for(int i = 1; i < n; ++i) {
		sum += a[i];
		best = min(best, abs(S - sum - sum));
	}
	printf("%lld", best);
	
	
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	int sx, sy, tx, ty;

	scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

	for (int i = 0; i < tx - sx; i++)
		putchar('R');
	for (int i = 0; i < ty - sy; i++)
		putchar('U');
	for (int i = 0; i < tx - sx; i++)
		putchar('L');
	for (int i = 0; i < ty - sy + 1; i++)
		putchar('D');
	for (int i = 0; i < tx - sx + 1; i++)
		putchar('R');
	for (int i = 0; i < ty - sy + 1; i++)
		putchar('U');
	putchar('L');
	putchar('U');
	for (int i = 0; i < tx - sx + 1; i++)
		putchar('L');
	for (int i = 0; i < ty - sy + 1; i++)
		putchar('D');
	puts("R");

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

//#define int long long
#define endl "\n"
#define fi first
#define se second
#define fr front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}




int main() {
	queue<string>que;
	queue<int>q;
	int n;
	cin >> n;
	que.push("a");
	q.push(1);
	while (que.front().size() <= n - 1) {
		for (int i = 0; i <= q.front(); i++) {
			que.push(que.front() + (char)(97 + i));
			if (i == q.front()) {
				q.push(q.front() + 1);
				continue;
			}
			q.push(q.front());
		}
		que.pop();
		q.pop();
	}
	while (!que.empty()) {
		cout << que.front() << endl;
		que.pop();
	}
}



Measured memory_bytes: 8320
#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

struct edge { ll to, cost; };
typedef pair<ll, ll>P; //firstは最短距離、secondは頂点番号
ll d[213456];//始点sから終点tまでのコストd[t]
vector<edge> G[213456];//コスト
void dijkstra(ll s) {
	//greater<P>を指定→firstが小さい順
	priority_queue<P, vector<P>, greater<P> >que;
	fill(d, d + 213456, INF);//←TLE気を付ける
	d[s] = 0; que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) { continue; }
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

ll x[1234567], y[1234567];
signed main() {
	ll n, m, l, r, c; cin >> n >> m;
	rep(i, m) {
		cin >> l >> r >> c;
		G[l].push_back({ r,c });
		G[r].push_back({ l,c });
	}
	rep(i, n - 1) {
		G[i + 1].push_back({ i,0 });
	}
	dijkstra(1);
	if (d[n] == INF) { cout << -1 << endl; }
	else { cout << d[n] << endl; }
	return 0;
}

Measured memory_bytes: 19244
// includes, macros {{{
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <climits>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

#define rep(i, s, e)    for (int i = (s); i < (int)(e); i++)
//#define PB(e) push_back(e)
//#define MP(a, b) make_pair(a, b)

// for debug
#define kita            cout << "kita\n"
#define print2(i, n)    cout << (i) << ": " << (n) << endl
#define print3(i, j, n)     cout << "(" << (i) << ", " << (j) << ") : " << (n) << endl
#define print4(i, j, n, m)  cout << "(" << (i) << ", " << (j) << ") : " << (n) << ", " << (m) << endl
#define print_mat(mat, h, w) for(int i=0;i<(h);i++){for(int j=0;j<(w);j++){cout << mat[i][j] << " ";}cout << endl;}
 
typedef long long ll;
typedef unsigned long long ull; // }}}

int main(){
    vector<int> data;
    int n;
    cin >> n;
    rep(i, 0, n*2){
        int l;
        cin >> l;
        data.push_back(l);
    }
    sort(data.begin(), data.end());

    int ans = 0;
    for(int i=0;i<n*2;i+=2){
        ans += data[i];
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
ll nCr(ll n, ll r){
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
  ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
  return ret;
}

int main(void){
  int n;cin>>n;
  vector<ll> B;
  B.push_back(LINF);
  rep(i,n-1){
    ll b;
    cin>>b;
    B.push_back(b);
  }
  B.push_back(LINF);
  ll ans = 0;
  rep(i,n){
    ans += min(B[i], B[i+1]);
  }
  cout<<ans<<endl;
  return 0;
}


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

namespace ABC088
{
    class B
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).OrderByDescending(ai => ai).ToArray();
            var alice_score = a.Where((ai, index) => index % 2 == 0).Aggregate((n, next) => n + next);
            var bob_score = a.Where((ai, index) => index % 2 == 1).Aggregate((n, next) => n + next);
            Console.WriteLine(alice_score-bob_score);
        }
    }
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int ar[n],copy[n];
  for(int i=0;i<n;++i)
  {
    cin>>ar[i];
    copy[i]=ar[i];
  }
  sort(copy,copy+n,greater<int>());
  for(int i=0;i<n;++i)
  {
    if(ar[i]==copy[0]){cout<<copy[1]<<"\n";}
    else{cout<<copy[0]<<"\n";}
  }
}
  


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return ('0' <= c && c <= '9')?(c - '0'):-1;}

// TODO: write
int main() {
  string s,t;cin>>s>>t;
  int n,m;cin>>n>>m;
  string u;cin>>u;
  if(u == s)n--;
  if(u == t)m--;
  cout<<n<<" "<<m<<endl;;
  return 0;
}



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

using namespace std;

bool ok(int N, const string &S)
{
	if (N % 2 != 0) {
		return false;
	}
	return S.substr(0, N / 2) == S.substr(N / 2);
}

int main()
{
	int N;
	string S;
	cin >> N >> S;
	if (ok(N, S)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
cost_zero = 0
cost_n = 0
n, m, x = (int(i) for i in input().split())
A = [int(i) for i in input().split()]

index = 0
for i in range(n+1):
    if i == A[index]:
        if i < x:
            cost_zero += 1
        else:
            cost_n += 1
        index = min(index+1, m-1) 
print(min(cost_zero, cost_n))

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

using namespace std;

int N, M;
int G[10][10];

int main(void)
{
	cin >> N >> M;
	
	int a, b;
	for(int i = 0; i < M; i++){
		cin >> a >> b;
		G[a][b] = G[b][a] = 1;
	}
	
	int perm[10];
	for(int i = 1; i <= N; i++) perm[i] = i;
	
	int ans = 0, pos;
	do{
		pos = 1;
		for(int i = 2; i <= N; i++){
			if(!G[pos][perm[i]]) goto NG;
			pos = perm[i];
		}
		ans++;
		NG:;
	}while( next_permutation(perm+2, perm+N+1) );
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N, ans = 0;
    cin >> N;
    vll xs(N + 1), s(N + 1);
    xs[0] = s[0] = 0;
    ll a;
    rep(i, N)
    {
        cin >> a;

        xs[i + 1] = xs[i] xor a;
        s[i + 1] = s[i] + a;
    }
    int l = 0, r = 1;
    while (r < N + 1)
    {
        if ((s[r] - s[l]) == (xs[r] xor xs[l]))
        {
            ans += r - l;
            r++;
        }
        else
        {
            l++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>

using namespace std;

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

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    vector<int> color;
    color.push_back(a[0]);
    for(int i = 1; i < n; i++){
        int l = 0, r = color.size() - 1;
        if (color[r] < a[i]) {
            while(l < r){
                int idx = (r + l) / 2;
                if (color[idx] >= a[i]) {
                    l = idx + 1;
                }else{
                    r = idx;
                }
            }
            color[l] = a[i];
        }else{
            color.push_back(a[i]);
        }
    }
    cout << color.size() << endl;
}

Measured memory_bytes: 1276
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	i, err := strconv.Atoi(readString())
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func vi(n int, args ...int) []int {
	res := make([]int, n)
	if len(args) == 0 {
		return res
	}
	v := args[0]
	if v == 0 {
		return res
	}
	for i := 0; i < n; i++ {
		res[i] = v
	}
	return res
}

func vvi(n int, args ...int) [][]int {
	res := make([][]int, n)
	m := n
	if len(args) > 0 {
		m = args[0]
	}
	v := 0
	if len(args) > 1 {
		v = args[1]
	}
	for i := 0; i < n; i++ {
		res[i] = vi(m, v)
	}
	return res
}

func main() {
	defer stdout.Flush()

	// readString() string
	// readInt() int
	// readIntSlice(n int) []int
	// readLengthAndSlice() []int

	d := readInt()
	n := readInt()

	b := 1
	for i := 0; i < d; i++ {
		b *= 100
	}
	if n == 100 {
		n++
	}
	println(n * b)
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String S_ = sc.next();

    sc.close();

    String[] S = S_.split("");

    int start = 0;
    
    for (int i = 0; i < S.length; i++) {

      if (S[i].equals("A")) {
        start = i;
        break;
      }

    }

    int end = 0;

    for (int i = S.length - 1; 0 <= i; i--) {

      if (S[i].equals("Z")) {
        end = i;
        break;
      }

    }

    System.out.println(end - start + 1);

  }

}

Measured memory_bytes: 53328
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  int flag = 0;
  REP(i, N){
    cin >> A[i];
    if(A[i]%2==1){
      flag=1;
    }
  }
  if(flag==1){
    cout << "first" << endl;
  }else{
    cout << "second" << endl;
  }
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char a = sc.next().charAt(0);
		if (Character.isUpperCase(a)) {
			System.out.println("A");
		} else {
			System.out.println("a");
		}
		sc.close();
	}

}


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

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define NCK_MAX 510000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
	int n; std::cin >> n;
	std::map<std::string, int> map{};
	std::string temp;
	REP(i,n) {
		std::cin >> temp;
		map[temp]++;
	}
	std::cout << SIZE(map) << '\n';
	return 0;
}


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

int main() {
  string s;
  int count = 0;
  cin >> s;

  if (s[0] == '1') {
    count += 1;
  }
  
  if (s[1] == '1') {
    count += 1;
  }
  
  if (s[2] == '1') {
    count += 1;
  }

  cout << count << endl;
}


Measured memory_bytes: 3604
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Great Ocean View
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int maxh = 0, c = 0;
  for (int i = 0; i < n; i++) {
    int h;
    scanf("%d", &h);
    if (maxh <= h) c++, maxh = h;
  }

  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, K := sc.nextInt(), sc.nextInt()
	R, S, P := sc.nextInt(), sc.nextInt(), sc.nextInt()
	T := sc.nextRuneSlice()
	//bR, bS, bP := int(1e+9), int(1e+9), int(1e+9)
	ans := 0
	//str := ""
	before := make([]rune, N)
	for i, r := range T {
		if r == 'r' {
			if K <= i && before[i-K] == 'p' {
				ans += 0
				//str += "x"
				before[i] = 'x'
			} else {
				before[i] = 'p'
				ans += P
				//str += "p"
			}
		} else if r == 's' {
			if K <= i && before[i-K] == 'r' {
				ans += 0
				//str += "x"
				before[i] = 'x'
			} else {
				before[i] = 'r'
				ans += R
				//str += "r"
			}
		} else {
			if K <= i && before[i-K] == 's' {
				ans += 0
				//str += "x"
				before[i] = 'x'
			} else {
				before[i] = 's'
				ans += S
				//str += "s"
			}
		}
	}

	//fmt.Println(str)
	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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

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


Measured memory_bytes: 256
a,b = map(int,input().split())
l= []
L = []
for i in range(a):
    t= input()
    l.append(t)
for i in range(b):
    t = input()
    L.append(t)
f = 'No'
for i in range(a-b+1):
    for j in range(a-b+1):
        s = 0
        for I in range(b):
            for J in range(b):
                if l[i+I][j+J] == L[I][J] :s+=1
        if s==b**2:f='Yes'
print(f)

Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

printList [a] = print a
printList (a:as) = putStr ( show a ) >> putChar ' ' >> printList as

main = readInteger >>= putStrLn . which "Yes" "No" . ( == 0 ) . ( `mod` 9 )

Measured memory_bytes: 21264
import sys
input = sys.stdin.readline
from operator import itemgetter
from scipy.sparse import csr_matrix
import numpy as np

N = int(input())

XY = [[i] + [int(x) for x in input().split()] for i in range(N)]
#print(XY)

edge = set()

#sortする際にインデックス1,2でそれぞれsortする
for key in [itemgetter(1),itemgetter(2)]:
  XY.sort(key = key)
  #print("XY",XY)
  for i in range(N-1):
    i1,x1,y1 = XY[i]
    i2,x2,y2 = XY[i+1]
    d = min(abs(x1-x2),abs(y1-y2))
    edge.add((i1,i2,d))
    
#print(edge)    
    
# csr形式に直す
row,col,value = zip(*edge)
#print(row,col,value)

value = np.array(value,dtype=int)
graph = csr_matrix((value,(row,col)),shape=(N,N))
#print(graph)

# 最小全域木
from scipy.sparse.csgraph import minimum_spanning_tree
tree = minimum_spanning_tree(graph, overwrite = True).astype(int)
#print(tree)

answer = tree.sum()
print(answer)


Measured memory_bytes: 84616
N, M = map(int, input().split())
price = []
keys = []
dp = [float('inf') for i in range(1<<N)]
dp[0] = 0
for k in range(M):
    price.append(int(input().split()[0]))
    keys.append(list(map(int,input().split())))
for p,key in zip(price,keys):
    key_open = 0
    for k in key:
        key_open |= 1 << (k-1)
        for j in range(1 << N):
            dp[j|key_open] = min(dp[j|key_open], dp[j] + p)

if dp[(1<<N)-1] == float('inf'):
    dp[(1<<N)-1] = - 1
print(dp[(1 << N) - 1])

Measured memory_bytes: 50264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

vector< int64_t > divisor(int64_t n) {
    vector< int64_t > res;
    for(int64_t i=1; i*i<=n; i++) {
        if(n % i == 0) {
            res.push_back(i);
            if(i*i != n) res.push_back(n/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main(void) {
    int N;
    cin >> N;
    vector<int> cnt(1000001);
    // map<int,int> mp;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
        cnt[A[i]]++;
        // mp[A[i]]++;
    }

    int ans = 0;
    for(int i=0; i<N; i++) {
        bool ok = true;
        auto d = divisor(A[i]);
        d.pop_back();
        if(cnt[A[i]] > 1) continue;
        for(auto e: d) {
            if(cnt[e]) {
                ok = false;
                break;
            }
        }
        if(ok) {
            ++ans;
        }
    }

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


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

int main(){
  string S;
  cin >> S;
  
  map<char,int> cnt;
  
  rep(i,4){
    cnt[S.at(i)]++;
  }
  
  string ans = "Yes";
  for(auto i:cnt){
    if(i.second != 2) ans = "No";
  }
  
  cout << ans << endl;
}

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

int int_cmp(const int *a, const int *b){
	if(*a<*b) return 1;
	else if(*a>*b) return -1;
	return 0;
}

int main(void){
	while(1){
		int n, s, i, j;
		int r[20000];
		long ans=0;
		
		scanf(" %d %d", &n, &s);
		if(n==0) break;
	
		for(i=0; i<n; i++)
			scanf(" %d", &r[i]);
	
		qsort(r, n, sizeof(int), (int(*)(const void*, const void*))int_cmp);
	
		for(i=0; i<n-1; i++) {
			if(r[i] > s) ans += n-i-1;
			else{
				for(j=i+1; j<n; j++) {
					if(r[i]+r[j] > s) ++ans;
					else break;
				}
			}
		}
				
		printf("%ld\n", ans);
	}

	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const long long MOD = 1000000007;

void solve(long long N, std::vector<long long> A){
  ll ans=0;
  REP(60){
    ll z=0,o=0;
    For(j,N){
      if(A[j]&(1LL<<i)){
        ++o;
      }else{
        ++z;
      }
    }
    ans+=(1LL<<i)%MOD*z%MOD*o%MOD;
    ans%=MOD;
    dump(ans);
  }
  cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(void){
  long long n,ans;
  scanf("%lld",&n);
  for(long long i=10;i<=n;i*=5){
    ans+=(n/i);
  }
  if(n%2){
    printf("0\n");
  }else{
    printf("%lld\n",ans);
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        
        for(int j = n-1; j > 0; j--){
            System.out.print(a[j] + " ");
        }
        System.out.print(a[0]);
        System.out.println();
    }
}


Measured memory_bytes: 26276
#include <stdio.h>

int main(void) {
	int i;
	char s[21];
	int len, cnt;

	scanf("%s%n", s, &len);

	i = cnt = 0;
	while (1) {
		while (i < len && s[i] != 'A')
			i++;
		if (i == len)
			break;

		while (i < len && s[i] != 'Z')
			i++;
		if (i == len)
			break;

		cnt++;
	}

	if (cnt == 0)
		puts("-1");
	else {
		for (i = 0; i < cnt; i++)
			printf("AZ");
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> w(n, 0);
	vector<int> b(n, 0);
	vector<int> r(n, 0);
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (i != 0) {
			w[i] += w[i-1];
			b[i] += b[i-1];
			r[i] += r[i-1];
		}
		for (int j = 0; j < m; j++) {
			if (s[j] == 'W') {
				b[i]++;
				r[i]++;
			} else if (s[j] == 'B') {
				w[i]++;
				r[i]++;
			} else {
				w[i]++;
				b[i]++;
			}
		}
	}
	int MIN = w[0]+(b[n-2]-b[0])+(r[n-1]-r[n-2]);
	for (int i = 0; i < n-2; i++) {
		for (int j = i+1; j < n-1; j++) {
			MIN = min(MIN, w[i]+(b[j]-b[i])+(r[n-1]-r[j]));
		}
	}
	cout << MIN << endl;
	return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>

int main(void) {

	int a = 0;	scanf("%d", &a);
	int b = 0;	scanf(" %d", &b);
	int c = 0;	scanf(" %d", &c);

	if ((a < b) && (b < c)) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>
#include <complex>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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


bool dp[5010][5010];

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n); rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    // 単調性が成り立つことを示す。
    // k - a[i] <= S < k となるSが存在するとすると、
    // a[j] > a[i] を満たす任意のa[j]について、k - a[j] <= S' < k が成り立つようなS'が存在することが示せる。
    // (Sに a[j]が含まれる場合と、a[j]が含まれる場合に分けると示せた。)

    int left = -1;
    int right = n;
    int mid;
    while (right - left > 1) {
        mid = (left + right) / 2;
        memset(dp, false, sizeof(dp));
        dp[0][0] = true;

        rep(i, n) {
            rep(j, k+1) {
                if (i == mid) {
                    dp[i+1][j] |= dp[i][j];
                } else {
                    dp[i+1][j] |= dp[i][j];
                    if (j + a[i] <= k) {
                        dp[i+1][j+a[i]] |= dp[i][j];
                    } else {
                        dp[i+1][k] |= dp[i][j];
                    }
                }
            }
        }
        
        bool flag = 0;
        for (int j = max(0, k - a[mid]); j < k; j++) {
            flag |= dp[n][j];
        }
        if (flag) right = mid;
        else left = mid;
    }

    cout << left + 1 << endl;

    return 0;
}


    

Measured memory_bytes: 24832
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

struct data{
    int team, solve, penalty;
    data(int team, int solve, int penalty): team(team), solve(solve), penalty(penalty){}
};

bool cmp(data d1, data d2){
    if(d1.solve == d2.solve){
        if(d1.penalty == d2.penalty) return d1.team < d2.team;
        return d1.penalty < d2.penalty;
    }
    return d1.solve > d2.solve; 
}

signed main(){
    int t, p, r;
    while(1){
        cin >> t >> p >> r;
        if(t + p + r == 0) break;
        int tid, pid, time;
        string message;
        vector<data> d(t,data(0,0,0));
        rep(i, 0, t){
            d[i].team = i;
            d[i].solve = 0;
            d[i].penalty = 0;
        }
        int l[51][11]={0};
        rep(i, 0, r){
            cin >> tid >> pid >> time >> message;
            tid --;
            pid --;
            if(message == "CORRECT" && l[tid][pid] != -1){
                d[tid].solve ++;
                d[tid].penalty += time + 1200*l[tid][pid];
                l[tid][pid] = -1;
            }else if(message == "WRONG" && l[tid][pid] != -1){
                l[tid][pid] ++;
            }
        }
        sort(all(d), cmp);
        rep(i, 0, t){
            cout << d[i].team + 1 << " " << d[i].solve << " " << d[i].penalty <<endl;
        }
    }
}

Measured memory_bytes: 1224
import fractions
li = list(map(int,input().split()))
a=li[0]
b=li[1]
k=li[2]
saidai=fractions.gcd(a,b)
yakusuu=[]
for i in range(100):
    if saidai%(i+1)==0:
        yakusuu.append(i+1)
yakusuu.sort()
yakusuu.reverse()
print(yakusuu[k-1])

Measured memory_bytes: 5304