akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 







const int maxn1=100005;
vector<int> adj[maxn1];
int p[maxn1];
bool visited[maxn1];
vector<int> chain,value;
int ans=0;
void dfs(int node){
     visited[node]=true;
  	 //cout<<node<<" "<<p[node]<<"\n";
  	 chain.push_back(node);value.push_back(p[node]);
     for(int child:adj[node]){
          if(!visited[child])
          dfs(child);
     }

}
int buf[maxn1];
int main()
{
     int n,m;
     cin>>n>>m;
     for(int i=1;i<=n;i++)cin>>p[i];
     for(int i=1;i<=m;i++){
          int x,y;
          cin>>x>>y;
          adj[x].pb(y);
          adj[y].pb(x);
     }
     for(int i=1;i<=n;i++){
          if(!visited[i]){
            dfs(i);
               for(auto x:chain)buf[x]=1;
               for(auto x:value)ans+=buf[x];
               for(auto x:chain)buf[x]=0;
            //cout<<ans<<"\n";
               chain.clear();value.clear();
          }

     }
     cout<<ans;



}






















Measured memory_bytes: 13444
from collections import Counter

N = int(input())
A=list(map(int,input().split(' ')))
counter = Counter(A)

flg = [0 for _ in range(10**6+1)]

ans = 0
for i in range(1,10**6+1):
    if counter[i] == 0:
        continue
    if flg[i] == 0 and counter[i] == 1:
        ans += 1
    for j in range(1,((10**6)//i)+1):
        flg[i*j] = 1

print(ans)


Measured memory_bytes: 44312
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

class Edge{
public:
  int from, to;
  double cost;

  Edge(){}
  Edge(int _from, int _to, double _cost){
    from = _from;
    to = _to;
    cost = _cost;
  }

  bool operator<(const Edge &e)const{
    return cost > e.cost;
  }
};

int n, m;
double x[10002], y[10002];
vector<Edge> es;

int par[10002];
int rank[10002];

double dist(int a, int b){
  return
    sqrt( (x[a] - x[b]) * (x[a] - x[b]) +
          (y[a] - y[b]) * (y[a] - y[b]) );
}

void init(void){
  for(int i = 0; i < 10002; i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  }
  else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return;
 
  if(rank[x] < rank[y]){
    par[x] = y;
  }
  else{
    par[y] = x;
    if(rank[x] == rank[y]) rank[x]++;
  }
}

bool same(int x,int y){
  return find(x) == find(y);
}

double solve(){
  sort(es.begin(), es.end());
  init();

  double res = 0;

  for(int i = 0; i < es.size(); i++){
    Edge e = es[i];

    if(!same(e.from, e.to)){
      unite(e.from, e.to);
      res += e.cost;
    }
  }

  return res;
}

int main(){
  while(cin >> n >> m){
    for(int i = 0; i < n; i++){
      cin >> x[i] >> y[i];
    }

    double sum = 0;
    es.clear();

    for(int i = 0; i < m; i++){
      int a, b;
      cin >> a >> b;
      a--;
      b--;

      double d = dist(a, b);

      es.push_back(Edge(a, b, d));
      sum += d;
    }

    printf("%.3f\n", sum - solve());
  }
}

Measured memory_bytes: 1572
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, i, *a;
	cin >> n;
	a = new int[n];
	for (i = 0; i < n; i++) cin >> a[i];
	 
	int q, o;
	cin >> q;
	while (q--)
	{
		cin >> o;
		cout << lower_bound(a, a + n, o) - a <<" "<<upper_bound(a,a+n,o )-a<<endl;
	}
	return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N)
        cin >> A[i];

    int count = 0;
    bool can_div = true;
    while(can_div)
    {
        rep(i, N)
        {
            if(A[i] % 2 != 0)
            {
                can_div = false;
                break;
            }
        }
        if(can_div)
        {
            rep(i, N) A[i] /= 2;
            count++;
        }
    }
    cout << count << endl;
}

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

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll s;
    vector<bool> table(1e9+1,false);
    for(int i=0;i<n;i++){
        cin >> s;
        table[s]=true;
    }
    int q;
    cin >> q;
    ll t;
    int cou=0;

    for(int i=0;i<q;i++){
        cin >> t;
        if(table[t])cou++;
    }

    cout << cou << endl;

}



Measured memory_bytes: 124796
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
using namespace std;
map<int, int> ct;
map<int, int> ct2;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPS 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define AFOR(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int n, m, l;
int a, b, c;
string s[MN];
string str;
string ans;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

/*
int N;
cin >> N;
vi vect(N);
FOR(i,N) cin >> vec.at(i);*/
//sort(vec.begin(),vec.end());
//vvi data(N,vi(4));


/*	int bfs(int x, int y,vvi &A,vvi flag) {
		queue<pii> que;
		que.push(pii(x, y));
		while (que.size()) {
			pii p = que.front(); que.pop();
			AFOR(i, 4) {
				int nx = p.first + dx[i]; int ny = p.second + dy[i];
				if (0 <= nx && nx < N && 0 <= ny && ny < N) {
					if (A.at(p.first).at(p.second) + flag.at(p.first).at(p.second) < A.at(nx).at(ny)) {
						A.at(nx).at(ny) = A.at(p.first).at(p.second) + flag.at(p.first).at(p.second);
						que.push(pii(nx, ny));
					}
				}
			}
		}
		return 0;
	}
	*/

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N >> str;
	long long  r = 0, g = 0, b = 0, e = 0;
	if (N == 1 || N == 2) cout << e << endl;
	AFOR(i, N) {
		if (str.at(i) == 'R') r++;
		else if (str.at(i) == 'G') g++;
		else b++;
	}
	FOR(i, 1, N - 2) {
		FOR(j, i + 1, N - 1) {
			if (2 * j - i <= N) {
				if (str.at(i - 1) != str.at(j - 1) && str.at(j - 1) != str.at(2 * j - i - 1) && str.at(2 * j - i - 1) != str.at(i - 1)) {
					e++;
				}
			}
		}
	}

	cout << r * g * b - e << endl;

	return 0;
}

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

typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


//===

const ll mod = static_cast<ll>(1e9 + 7);



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

	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}

	vector<Pii> xy(n);
	for (int i = 0; i < n; ++i) {
		cin >> xy[i].first >> xy[i].second;
	}

	map<Pii, int> m;
	int max_cnt = 0;
	Pii max_d;
	for (int i = 0; i < n - 1; ++i) {
		for (int j = i + 1; j < n; ++j) {
			Pii d, md, d_ins;
			d.first = xy[i].first - xy[j].first;
			d.second = xy[i].second - xy[j].second;
			md.first = -d.first;
			md.second = -d.second;
			
			if (m.find(md) != m.end()) {
				d_ins = md;
			}
			else {
				d_ins = d;
			}
			if (++m[d_ins] > max_cnt) {
				max_cnt = m[d_ins];
				max_d = d_ins;
			}
		}
	}

	set<Pii> s_xy;
	for (const auto& val : xy) {
		s_xy.insert(val);
	}
	
	int ans = 0;
	for (const auto& val : xy) {
		Pii xy_next;
		xy_next.first = val.first + max_d.first;
		xy_next.second = val.second + max_d.second;
		if (s_xy.find(xy_next) == s_xy.end()) ++ans;
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

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

  if ((A > B && B != 1) || (A == 1 && B != 1))
    cout << "Alice" << endl;
  else if (A == B)
    cout << "Draw" << endl;
  else
    cout << "Bob" << endl;

  return 0;
}


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

int main(){
  int h,w,x=0;
  bool finished=false;
  cin>>h>>w;
  vector<string> a(h);
  vector<vector<int>> b(h,vector<int>(w,1));
  for (int i=0;i<h;i++){
    cin>>a.at(i);
  }
  for (int i=0;i<h;i++){
    finished=false;
    for (int j=0;j<w;j++){
      if (a.at(i).at(j)=='#'){
        finished=true;
        break;
      }
    }
    if (finished){
      continue;
    }else{
      b.at(i)=vector<int>(w,0);
    }
  }
  for (int j=0;j<w;j++){
    finished=false;
    for (int i=0;i<h;i++){
      if (a.at(i).at(j)=='#'){
        finished=true;
        break;
      }
    }
    if (finished){
      continue;
    }else{
      for (int k=0;k<h;k++){
        b.at(k).at(j)=0;
      }
      x++;
    }
  }
  int y;
  for (int i=0;i<h;i++){
    y=0;
    for (int j=0;j<w;j++){
      if (b.at(i).at(j)==1){
        cout<<a.at(i).at(j);
        y++;
        if (w-x==y){
          cout<<endl;
        }
      }
    }
  }
}
    

Measured memory_bytes: 256
class UnionFind():
    # 作りたい要素数nで初期化
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズ
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

import sys
input = sys.stdin.buffer.readline
import heapq as hp

N = int(input())
XY = []
for i in range(N):
    x, y = map(int, input().split())
    XY.append((x, y, i))

XY.sort()

uni = UnionFind(N)
q = []
for x, y, i in XY:
    my = y
    while q and q[0][0] < y:
        jy, j = hp.heappop(q)
        my = min(jy, my)
        uni.Unite(i, j)
    hp.heappush(q, (my, uni.Find_Root(i)))

for i in range(N):
    print(uni.Count(i))

Measured memory_bytes: 110804
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
#define endl '\n'
#define F first
#define S second
#define lowbit(x) (__builtin_ffs(x)-1)
const int MAX_N=20;

int n;
int a[MAX_N][MAX_N];
ll score[1<<MAX_N];
ll dp[1<<MAX_N];

int main()
{
	memset(dp,-1,sizeof(dp));
	dp[0]=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) scanf("%d",&a[i][j]);
	for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) for(int k=0;k<(1<<n);k++)
		if(((1<<i)&k)&&((1<<j)&k)) score[k]+=a[i][j];
	for(int i=1;i<(1<<n);i++)
	{
		int now=i;
		do
		{
			dp[i]=max(dp[i],dp[now]+score[i-now]);
			now=(now-1)&i;
		} while(now!=i);
	}
	printf("%lld\n",dp[(1<<n)-1]);
	return 0;
}



Measured memory_bytes: 10496
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long
signed main() {
	int k; cin >> k;
	cout << "Christmas";
	switch (k)
	{
	case 22:cout << " Eve";
	case 23:cout << " Eve";
	case 24:cout << " Eve";
	default:
		break;
	}cout << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from math import sqrt
from heapq import heapify, heappop, heappush
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
from fractions import gcd
def inpl(): return list(map(int, input().split()))

N = int(input())
V = inpl()
heapify(V)

while len(V) > 1:
    x = heappop(V)
    y = heappop(V)
    heappush(V, (x+y)/2)
print(V[0])


Measured memory_bytes: 66156
#include<stdio.h>

#define MAX 2000000

int size,a[MAX+1];

void maxHeapify(int i){
  int l,r,large,t;

  l = 2*i;
  r = 2*i+1;

  if((l <= size) && (a[l] > a[i])){
    large = l;
  }

  else{
    large = i;
  }
  
  if((r <= size) && (a[r] > a[large])){
    large = r;
  }
  
  if(large != i){
    t = a[i];
    a[i] = a[large];
    a[large] = t;
    
    maxHeapify(large);

  }
}

int main(){

  int i;
  
  scanf("%d", &size);
  
  for(i=1;i<=size;i++){
    scanf("%d",&a[i]);
  }

  for(i=size/2;i>=1;i--){
    maxHeapify(i);
  }

  for(i=1;i<=size;i++){
    printf(" %d",a[i]);
  }

  
  printf("\n");

  return 0;

}



Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int a[101],n,k,ans;
int main(){
	cin>>n>>k;
	int ff,m;
	for(int i=0;i<k;i++){
		cin>>ff;
		for(int j=0;j<ff;j++){
			cin>>m;
			a[m]++;
		}
	}
	for(int i=1;i<=n;i++){
		if(a[i]==0){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3648
/*#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC target("avx2")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

//#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define endl '\n'


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

mt19937 mrand(random_device{}());

const double PI = acos((double)-1);
const double eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

void solve() {
	ll x; cin >> x;
	for (ll i = -1000; i <= 1000; i++) {
		ll a = pow(pow(i, 5) + x, 0.2);
		if (pow(a, 5) - pow(i, 5) == x) {
			cout << a << " " << i << endl;
			return;
		}
	}
	return;
}

Measured memory_bytes: 4072
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y;
    cin >> x >> y;

    cout << (a[x] == a[y] ? "Yes" : "No");
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    S = input()
    if S == "SUN":
        print(7)
    elif S == "MON":
        print(6)
    elif S == "TUE":
        print(5)
    elif S == "WED":
        print(4)
    elif S == "THU":
        print(3)
    elif S == "FRI":
        print(2)
    else:
        print(1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
import sys
sys.setrecursionlimit(10**7)
input=sys.stdin.readline
n=int(input())
points=[list(map(int,input().split()))+[i] for i in range(n)]
points.sort(key = lambda x:x[1])
edge=[]
for i in range(n-1):
    edge.append((points[i][2],points[i+1][2],points[i+1][1]-points[i][1]))
points.sort()
for i in range(n-1):
    edge.append((points[i][2],points[i+1][2],points[i+1][0]-points[i][0]))
class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for i in range(N)]
    
    def merge(self, a, b):
        if self.issame(a,b):
            return
        pa = self.root(a)
        pb = self.root(b)
        self.parent[pa] = pb
        self.size[pb] += self.size[pa]
    def root(self, x):
        p = self.parent[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.parent[x] = r
            return r
    
    def issame(self, x, y):
        return self.root(x) == self.root(y)
    
    def getsize(self, x):
        return self.size[self.root(x)]
edge.sort(key=lambda x:x[2])
uf=UnionFind(n)
ans=0
for ed in edge:
    if uf.issame(ed[0],ed[1]):continue
    ans+=ed[2]
    uf.merge(ed[0],ed[1])
print(ans)

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

const int MAXN = 1010;
typedef std::vector<int> VI;
typedef std::pair<int, int> pi;
VI out[MAXN], rout[MAXN], ine[MAXN];
int n, m;
int * ind; VI * so;
void dfs(int t) { for (auto i : so[t]) if (!ind[i]) ind[i] = t, dfs(i); }
std::map<pi, int> u2v, v2u;
int xs[200010], ys[200010];

int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		std::cin >> xs[i] >> ys[i];
		out[xs[i]].push_back(ys[i]);
		ine[ys[i]].push_back(xs[i]);
	}
	for (int i = 1; i <= n; ++i) {
		std::sort(out[i].begin(), out[i].end());
		rout[i].assign(out[i].rbegin(), out[i].rend());
	}
	static int i1[MAXN], i2[MAXN];
	for (int i = 1; i <= n; ++i) {
		memset(i1, 0, n + 1 << 2);
		memset(i2, 0, n + 1 << 2);
		so = out,  ind = i1, i1[i] = n + 1; dfs(i);
		so = rout, ind = i2, i2[i] = n + 1; dfs(i);
		for (auto t : ine[i]) if (i1[t]) v2u[pi(t, i)] = true;
		for (auto t : out[i])
			if (i1[t] != i2[t] || i1[t] != i)
				u2v[pi(i, t)] = true;
	}
	for (int i = 1; i <= m; ++i) {
		auto t = pi(xs[i], ys[i]);
		std::cout << (u2v[t] ^ v2u[t] ? "diff\n" : "same\n");
	}
	return 0;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
const ll mx=1e18+7;
 
int main() {
	int n;
	cin>>n;
	ll a, b;
	cin>>a>>b;
	n--;
	while(n--){
		ll x, y, k1=mx, k2=mx;
		cin>>x>>y;
		if( x >= a && y >= b) 
		{
			a=x;
			b=y;
			continue;
		}
	    if( x < a ) {
			k1=(a+x-1LL)/x;
			if(y*k1<b) k1= mx;
		}
		if( y < b ) {
			k2=(b+y-1LL)/y;
			if(x*k2<a) k2= mx;
		}
		a=x*min(k1,k2);
		b=y*min(k1,k2);				
		}
		
	cout<<a+b<<endl;	
	return 0;
}

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

public class Main{

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String line;
		while ((line = br.readLine()) != null) {
			String[] arr = line.split(" ");
			int a = Integer.parseInt(arr[0]);
			int b = Integer.parseInt(arr[1]);
			
			System.out.println(f(a + b));
		}
	}
	
	public static int f(int sum) {
		int i = 0;
		while (sum != 0) {
			sum /= 10;
			i++;
		}
		
		return i;
	}

}

Measured memory_bytes: 24288
#include<bits/stdc++.h>
using namespace std;
int main(){
string A,B;
  cin>>A>>B;
  int N=A.size();
  int M=B.size();
  if(N<M)
    cout<<"LESS"<<endl;
  else if(M<N)
    cout<<"GREATER"<<endl;
  else{
  if(A<B)
    cout<<"LESS"<<endl;
  else if(B<A)
    cout<<"GREATER"<<endl;
  else
    cout<<"EQUAL"<<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 COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  int a;
  M m;
  REP(i,n) {
    cin >> a;
    if (m[a]) m[a]++;
    else m[a] = 1;
  }

  ll ans = 0;
  for (auto x = m.begin(); x!=m.end(); x++) {
    int k = x->first;
    int v = x->second;
    if (v>k) ans+=v-k;
    else if (v<k) ans+=v;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4736
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		long sum = 0;
		for (int i = 1; i <= n; i++) {
			sum += 1l * i * (n - i + 1);
		}
		for (int i = 0; i < n - 1; i++) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			int min = Math.min(u, v);
			int max = Math.max(u, v);
			sum -= 1l * min * (n - max + 1);
		}
		pw.println(sum);
		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

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

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}

	}

}


Measured memory_bytes: 46424
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"basic.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
#endif

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> as(n);
    for(int i=0;i<n;i++){
        cin >> as[i];
    }
    ll block = 0;
    for(int i=0;i<k;i++){
        block += as[i];
    }
    ll lsum = 0, rsum = 0;
    for(int i=k;i<n;i++){
        rsum += max(0, as[i]);
    }
    ll ans = lsum + max(block, 0ll) + rsum;
    for(int i=k;i<n;i++){
        block += as[i];
        block -= as[i - k];
        lsum += max(0, as[i - k]);
        rsum -= max(0, as[i]);
        ans = max(ans, lsum + max(block, 0ll) + rsum);
    }
    cout << ans << '\n';
    return 0;
}


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

using namespace std;

static const int kModulo = 1000 * 1000 * 1000 + 7;

int main() {
    ios::sync_with_stdio(false);

    int N, K; cin >> N >> K;

    vector<int> ways(K + 1, 0);
    ways[0] = 1;

    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        vector<int> partial(K + 1);
        for (int j = 0; j <= K; ++j) {
            partial[j] = ways[j];
            if (j > 0)
                partial[j] = (partial[j] + partial[j - 1]) % kModulo;
        }

        for (int j = 0; j <= K; ++j) {
            ways[j] = partial[j];
            if (j > a)
                ways[j] = (ways[j] + kModulo - partial[j - a - 1]) % kModulo;
        }
    }

    cout << ways[K] << "\n";
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main
{
	public static void main(String[] args)
    {
     	Scanner sc = new Scanner(System.in); 
      
      	String[] words = sc.nextLine().split("");
      	
      	if(words[2].equals(words[3]) && words[4].equals(words[5]))
        {
          	System.out.println("Yes");
        }else{
          System.out.println("No");
        }
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vi d(k);
    rep(i,k) cin>>d[i];
    while(true){
        int t=n;
        bool ng=false;
        while(t){
            int c = t%10;
            rep(i,k)if(c==d[i]) ng=true;;
            t/=10;
        }
        if (!ng){
            cout<<n<<"\n";
            return 0;
        }
        n++;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
using namespace std;

int main(){
  int m;
  scanf("%d",&m);
  while(m-->0){

    set <string> s;
    string t;
    cin >> t;

    s.insert(t);
    reverse(all(t));
    s.insert(t);
    reverse(all(t));

    rep1(i,t.size()){
      string t1 = t.substr(0,i);
      string t2 = t.substr(i,t.size());

      string F2F1 = t2 + t1; s.insert(F2F1);
      reverse(all(t2));
      string R2F1 = t2 + t1; s.insert(R2F1);
      string F1R2 = t1 + t2; s.insert(F1R2);
      reverse(all(t1));
      string R1R2 = t1 + t2; s.insert(R1R2);
      string R2R1 = t2 + t1; s.insert(R2R1);
      reverse(all(t2));
      string F2R1 = t2 + t1; s.insert(F2R1);
      string R1F2 = t1 + t2; s.insert(R1F2);

    }
    cout << s.size() << endl;
  }
}

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

int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]!=s[i+1])ans+=1;
    }
    cout<<ans<<endl;
}

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

int main(){
    int n,key1,key2,i,j;scanf("%d%d%d",&n,&key1,&key2);
    int a[n+1][n+1],ans[n+1];

    for(i=1;i<=n-1;i++){
        ans[i]=0;
    }

    for(i=1;i<=n;i++){
        for(j=1;j<i;j++){
            if(i>=key2 && j<=key1){
                a[i][j]=i-j-(key2-key1-1);
            }else if(((key1<=i && i<=key2) && (j<=key1)) && (i-j>=key1+key2-i-j+1)){
                a[i][j]=key1+key2-i-j+1;
            }else if(((key1<=j && j<=key2) && (i>=key2)) && i-j>=j-key1-key2+i+1){
                a[i][j]=j-key1-key2+i+1;
            }else if(key1<=j && i<=key2 && i-j>=key2+j-i-key1+1){
                a[i][j]=key2+j-i-key1+1;
            }else{
                a[i][j]=i-j;
            }
        }
    }
    for(i=1;i<=n;i++){
        for(j=1;j<i;j++){
            ans[a[i][j]]++;
        }
    }
    for(i=1;i<=n-1;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 15616
#nを入力
n = int(input())
#wを入力
w = list(map(int, input().split()))

#全ての数の半分を出力
total = 0
for i in range(n):
    total += int(w[i])

double = total / 2

#合計が半分に最も近く時の値を出力
sum = 0
j = 0

for i in range(n):
    if abs(double) - sum >= abs(double - (sum + w[i])):
        sum += w[i]
    else:
        break

ans = total - sum - sum

print(abs(ans))


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
//the area and the perimeter of rectangle
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_C
int main() {
	int a, b;
	cin >> a >> b;
	cout << a*b << " " << 2 * (a + b) << "\n";
}

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


int main() {
	cout.precision(10);
	cout.setf(ios::fixed);

	for(string line; getline(cin, line);) {
		istringstream is(line);
		stack<double> sta;

		string token;
		while(is >> token) {
			if(isdigit(token[0]) || (token[0] == '-' && token.size() >= 2)) {
				sta.push(stod(token));
			}
			else { // binary operator
				assert(token.size() == 1);

				const double b = sta.top(); sta.pop();
				const double a = sta.top(); sta.pop();

				switch(token[0]) {
				case '+': sta.push(a + b); break;
				case '-': sta.push(a - b); break;
				case '*': sta.push(a * b); break;
				case '/': sta.push(a / b); break;
				default:
					assert(false);
				}
			}
		}

		assert(sta.size() == 1);
		cout << sta.top() << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1292
import java.io.*
import java.util.*

fun solve(N: Int){
    if (N==0) {println(0); return }
    var n = N.toLong()
    val ans = ArrayDeque<Int>()
    var ret = -2L
    for (i in 0 until 32){
        if (n % ret == 0L){
            ans.addFirst(0)
        }else{
            ans.addFirst(1)
            n -= -ret/2
        }
        ret *= -2
    }
    println(ans.dropWhile{ it == 0 }.joinToString(separator=""))
    return
}


fun floorDiv(a: Long, b: Long): Long = a / b + if ( a % b == 0L ) 0L else 1L

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    solve(N)
}


Measured memory_bytes: 29696
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

void solve(){
  ll w,h;cin>>w>>h;
  vector<ll>p(w);
  vector<ll>q(h);
  rep(i,w)cin>>p[i];
  rep(i,h)cin>>q[i];
  sort(all(p));
  sort(all(q));
  ll ans=0;
  rep(i,h){
    //qを考える。
    ll index=lower_bound(all(p),q[i])-p.begin();
    ans+=(w+1-index)*q[i];
    // cout<<q[i]<<" "<<w+1-index<<endl;
  }
  rep(i,w){
    //qを考える。
    ll index=lower_bound(all(q),p[i]+1)-q.begin();
    ans+=(h+1-index)*p[i];
    // cout<<p[i]<<" "<<h+1-index<<endl;
  }
  cout<<ans<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	solve();
}


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

int main() {
    int n; cin >> n;
    for (int i = 0; i <= n / 4; i++) for (int j = 0; j <= n / 7; j++) {
        if (i * 4 + j * 7 == n) return !(cout << "Yes" << endl);
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;

	S[K - 1] = S[K - 1] - 'A' + 'a';

	co(S);

	Would you please return 0;
}

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

int main() {
	int A,B,C;
	cin>>A>>B>>C;
	int tmp=A;
	A=B;
	B=tmp;
	tmp=A;
	A=C;
	C=tmp;
	cout<<A<<" "<<B<<" "<<C<<endl;
	return 0;
}

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

using namespace std;

const long long INF = 1LL<<60;

// 1. input
// 2. Floyd_Warshall
// 3. Is there any negative cycle???
// 4. Pirnt ans (if no negative cycle)

void Floyd_Warshall(int n, vector<vector<long long>> &dist){
    
    for (int k = 0; k < n; k++){
        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++){
                
                // distance INFのところはpathがないため無視する！！
                if (dist[i][k] == INF || dist[k][j] == INF) continue;
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    
}

int main(void){
    int n,e;
    cin >> n >> e;
    
    vector<vector<long long>> dist(n+1, vector<long long>(n+1, INF));
    
    for (int i = 0; i < n; i++) dist[i][i] = 0;
    
    for (int i = 0; i < e; i++){
        long long s, t, d;
        cin >> s >> t >> d;
        
        dist[s][t] = d;
    }
    
    Floyd_Warshall(n, dist);
    
    // Is there any negative cycle???
    for (int i = 0; i < n; i++){
        if (dist[i][i] < 0){
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }
    
    //  print ans
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if (j) cout << " ";
            
            if (dist[i][j] == INF) cout << "INF";
            else cout << dist[i][j];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"23"# => "25",
r#"5"# => "43",
r#"21"# => "27",
// r#"24"# => "No",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        m: usize,
    }

    (48 - m).to_string()
}

Measured memory_bytes: 4352
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int get(ll a, ll k) {
	if (a < k)
		return 0;
	if (a % k == 0) {
		return a / k;
	}
	int av = a / k + 1;
	int go = (a % k) - 1;
	int cnt = go / av + 1;
	return get(a - cnt * av, k);
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	int n;
	cin >> n;
	int cur = 0;
	for (int i = 0; i < n; ++i) {
		ll a, k;
		cin >> a >> k;
		cur ^= get(a, k);
	}
	if (cur == 0) {
		cout << "Aoki\n";
	}
	else {
		cout << "Takahashi\n";
	}
	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        int[] wt = new int[n];
        int[] p  = new int[n];
        for (int i = 0; i < n; i++) {
            wt[i] = scanner.nextInt();
            p[i]  = scanner.nextInt();
        }
        long[][] dp = new long[n+1][w+1];
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= w; j++) {
                if(i==0 || j==0)
                    dp[i][j]=0;
                else if(wt[i-1] <= j)
                    dp[i][j] = Math.max(dp[i-1][j],dp[i-1][j-wt[i-1]] + p[i-1]);
                else
                    dp[i][j] = dp[i-1][j];
            }
        }
        System.out.println(dp[n][w]);
    }
}

Measured memory_bytes: 138572
#include<stdio.h>
int main(void)
{
    int h/*row*/,w/*column*/,n/*number of colors*/;

    scanf("%d %d %d",&h,&w,&n);

    int i,j,k,a[n],sq[h][w];

    for(i=0,j=0;i<n;i++){
        scanf("%d",&a[i]);
        for(k=0;k<a[i];k++,j++)
            if((j/w)%2)
                sq[j/w][j%w]=i+1;
            else
                sq[j/w][w-1-j%w]=i+1;
    }

    for(j=0;j<h;j++){
        for(k=0;k<w;k++)
            printf("%d ",sq[j][k]);
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

struct City{
    int pref;
    int year;
    int order;
    int num;
    bool operator<( const City&right ) const {
        return pref == right.pref ? year < right.year : pref < right.pref;
    }
};

void printorder(string pref,string cccount){
    for(int i=0;i<6-pref.length();i++){
        cout<<'0';
    }
    cout<<pref;
    for(int i=0;i<6-cccount.length();i++){
        cout<<'0';
    }
    cout<<cccount;
    out("");
}

int N,M,previoous,cccount=1;

int main(){
    cin>>N>>M;
    vector<City> city(M),city2(M);
    rep(i,M){
        cin>>city[i].pref>>city[i].year;
        city2[i].pref=city[i].pref;
        city2[i].year=city[i].year;
        city2[i].num=i;
    }
    stable_sort(city2.begin(),city2.end());
    // rep(i,M){
    //     cout<<city2[i].pref<<" "<<city2[i].year<<" "<<city2[i].num<<endl;
    // }
    city[city2[0].num].order=cccount;
    previoous=city2[0].pref;
    cccount++;
    repi(i,1,M){
        if(city2[i].pref==previoous){
            city[city2[i].num].order=cccount;
            cccount++;
        }
        else{
            cccount=1;
            city[city2[i].num].order=cccount;
            previoous=city2[i].pref;
            cccount++;
        }
    }
    rep(i,M){
        printorder(to_string(city[i].pref),to_string(city[i].order));
    }
}


Measured memory_bytes: 5376
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var nk = IO.RSInt;
            var a = IO.RSInt;
            Array.Sort(a);
            var sum = 0;
            for (int i = 0; i < nk[1]; i++)
            {
                sum += a[i];
            }
            WriteLine(sum);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 28524
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define pb push_back
#define mem(a) memset(a,1,sizeof(a))
typedef long long ll;
typedef pair<int,int> pii;

const int mn=1e4+5;

struct edge{
	int to,dist,cost;

};
vector<edge> g[mn];

struct node {
    int id,dist,cost;
    bool operator < (const node &p) const{
		return dist==p.dist?cost>p.cost:dist>p.dist;
	}
};

int n,m;

int d[mn];
int c[mn];
int sum=0;
void dijk(){
    priority_queue<node> q;
    for(int i=1;i<=n;i++) d[i]=1e9+7,c[i]=1e9+7;
    q.push(node{1,d[1]=0,c[1]=0});
    while(!q.empty()){
        node u=q.top();q.pop();
        if (d[u.id]<u.dist||c[u.id]<u.cost) continue;
        //printf("%d %d %d\n",u.id,u.dist,u.cost);
        sum+=u.cost;
        for(edge &e:g[u.id]){
            int t=e.dist+u.dist;
            if (d[e.to]>t||(d[e.to]==t&&c[e.to]>e.cost)){
                q.push(node{e.to,d[e.to]=t,c[e.to]=e.cost});
            }
        }
    }
}

int main() {
	while(~scanf("%d%d",&n,&m)&&n){
		sum=0;
		for(int i=1;i<=n;i++) g[i].clear();
        for(int i=1;i<=m;i++){
			int u,v,d,w;
			scanf("%d%d%d%d",&u,&v,&d,&w);
			g[u].pb(edge{v,d,w});
			g[v].pb(edge{u,d,w});
        }
        dijk();
        printf("%d\n",sum);
	}
	return 0;
}



Measured memory_bytes: 5216
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d,z;
    cin>>n;
    int ara[n];
    for(i=0;i<n;i++){
       cin>>ara[i];
    }
    p=ara[0];
    for(i=1;i<n;i++){
        if(ara[i]>p){
            p=ara[i];
        }
        if(ara[i]<p){
            sum+=p-ara[i];
        }
    }
    cout<<sum<<endl;
    return EXIT_SUCCESS;
}



Measured memory_bytes: 4372
#include <stdio.h>

int main(void) {
  int i,max1=0,max2=0;

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

  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]>=max1){
      max2=max1;
      max1=a[i];
    }else if(a[i]>max2){
      max2=a[i];
    }
  }

  for(i=0;i<n;i++){
    if(a[i]==max1){
      printf("%d\n",max2);
    }else{
      printf("%d\n",max1);
    }
  }


  return 0;
}


Measured memory_bytes: 2304
def insertionSort(A,n,g,cnt):
    for i in range(g,n):
        v = A[i]
        j = i-g
        while (j>=0)*(A[j]>v):
            A[j+g]=A[j]
            j = j-g
            cnt[0] += 1
        A[j+g] = v
A =[]
N = int(input())
for i in range(N):
    A.append(int(input()))
cnt = [0]
import math
m = math.floor(math.log(N,2))+1
G = [math.ceil(N/2)]
for i in range(1,m-1):
    G.append(math.ceil(G[i-1]/2))
G.append(N-sum(G))
if G[len(G)-1] != 1:
    G[len(G)-1] = 1
for k in range(m):
    insertionSort(A,N,G[k],cnt)
print(m)
for i in range(m):
    print(f"{G[i]}",end=" ")
print(f"\n{cnt[0]}")
for i in range(N):
    print(f"{A[i]}")


Measured memory_bytes: 45556
N = int(input())
bl = [input() for i in range(N)]
M = int(input())
rl = [input() for i in range(M)]

result_yen = 0
for i in set(bl):
    yen = 0
    yen += bl.count(i)
    yen -= rl.count(i)
    if yen > result_yen:
        result_yen = yen
print(0 if result_yen == 0 else result_yen)


Measured memory_bytes: 3060