akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define pos position<int>
#define at_(p) at(p.x).at(p.y)

#define GCD(v) gcd(ALL(v), 0l)

template <typename T>
using vec =vector<T>;

template <typename T>
using vvec =vector<vector<T>>;

int main(){
  int n,m;
  cin>>n>>m;
  vvec<int> v(n+1,vec<int>(0));
  int a,b;
  for (int i = 0; i < m; i++) {
    cin>>a>>b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  vec<int> parent(n+1,0);
  queue<int> q;
  q.push(1);
  while(!q.empty()){
    int p=q.front();
    q.pop();
    for (int i:v[p]) {
      if(parent[i]==0){
        parent[i]=p;
        q.push(i);
      }
    }
  }
  for (int i = 1; i < n+1; i++) {
    if(parent[i]==0){
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  for (int i = 2; i < n+1; i++) {
    cout<<parent[i]<<endl;
  }
}



/* きょむ〜 */


Measured memory_bytes: 10152
from collections import deque
H, W = map(int,input().split())
S = [input() for _ in range(H)]

Q = deque([[0,0]])
dist = [[-1] * W for _ in range(H)]
dist[0][0] = 0

while Q:
    h, w = Q.popleft()

    for nh, nw in [[h+1,w],[h-1,w],[h,w-1],[h,w+1]]:
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == "." and dist[nh][nw] == -1:
            dist[nh][nw] = dist[h][w] + 1
            Q.append([nh,nw])

if dist[H-1][W-1] == -1:
    print(-1)
else:
    ans = 0
    for s in S: ans += s.count(".")
    print(ans - dist[H-1][W-1] - 1)



Measured memory_bytes: 73984
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<int,ll>Pil;
typedef pair<int,Pil>Piil;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};

int main() {

	int n,a[81];
	cin>>n;
	rep(i,n)cin>>a[i];

	ll m=1000;
	rep(i,n-1){
		if(a[i]<a[i+1]){
			ll c=m/a[i];
			m=m-c*a[i]+c*a[i+1];
		}
	}
	cout<<m<<endl;

	return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

/*template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
*/
int main(){
    int n;cin>>n;
    ll a[n+1];
    ll suf[n+1]={};
    for(int i=0;i<n+1;i++){
    	cin>>a[i];
	}
	
	if(a[0]>1){
		cout<<-1<<endl;return 0;
	}
	
	if(a[0]==1){
		for(int i=1;i<=n;i++){
			if(a[i]!=0){
				cout<<-1<<endl;return 0;
			}
		}
		cout<<1<<endl;return 0;
	}
	
	suf[n]=a[n];
	for(int i=n-1;i>=0;i--){
		suf[i]=a[i];
		suf[i]+=suf[i+1];
	}
	
	ll pre=1;
	ll ans=1;
	
	for(int i=1;i<=n;i++){
		if(a[i]>2*pre){
			cout<<-1<<endl;return 0;
		}
		if(pre<=1e13){
			pre=min(pre*2,suf[i]);
			ans+=pre;
		}
		else{
			pre=suf[i];
			ans+=pre;
		}
		pre-=a[i];
		//cout<<ans<<endl;
	}

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

Measured memory_bytes: 5156
n=int(input())
h=list(map(int,input().split()))
ans=0
while(sum(h) is not 0):
    is0 = True
    for i in range(n):
        if(h[i]==0):
            is0 =True
        else:
            if(is0):
                ans += 1
                is0=False
            h[i]-=1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
  int n;
  cin>>n;
  int a[200000];
  
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int minv=a[0];
  int maxv=a[1]-a[0];
  for(int j=1;j<n;j++){
    if(maxv<a[j]-minv)
      maxv=a[j]-minv;
     if(minv>a[j])
      minv=a[j];
  }
  cout<<maxv<<endl;

  return 0;
}


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

typedef long long int ll;

int main()
{
    ll n, ans = 0;
    cin >> n;
    vector<ll> p(n), q(n);
    for(ll i = 0;i < n;i++){
        cin >> p[i];
    }

    for(ll i = 0;i < n;i++){
        if(p[i] == i + 1){
            q[i] = 1;
        }
    }

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

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

    cout << ans;

    return 0;
}

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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if ((0 <= (x - r) && (x + r) <= W) && (0 <= (y - r) && (y + r) <= H)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;

ll a[100005];
int main(){
	ll t;
    ll x,n;
    cin>>x>>n;
    map<ll,ll> help;
    
    for(ll i=1;i<=n;i++){
    	ll j;
		cin>>j;
		help[j]++;
    }
    ll diff=1e9+7;
    ll sol=1e9+7;
    
    for(ll i=-100;i<=300;i++){
    	if(help[i]==0){
    		if(abs(i-x)<diff){
    			diff=abs(i-x);
    			sol=i;
			}
		}
	}
    
    cout<<sol;
    
	
	
	
	
    
}

Measured memory_bytes: 3652
// #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;

#define MP make_pair
#define fastIO	cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c)	for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(), c_end=c.end(); it!=c_end; ++it)

void solveAndOutput(MAPII result){
	int count = 0;
	MAPII::iterator it_end = result.end();
	it_end--; it_end--;
	foreach_it(MAPII, it, result){
		count++;
		if (count <= 2)
			cout << (*it).second << endl;
		if (it == it_end)
			cout << (*it).second << endl;
	}
}

int main(){
	int n;
	int c1, m1, s1, m2, s2, m3, s3, m4, s4;
	MAPII result;
	fastIO;

	while (cin >> n, n){
		while (n--){
			cin >> c1 >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
			result.insert(MP(m1 * 60 + s1 + m2 * 60 + s2 + m3 * 60 + s3 + m4 * 60 + s4, c1));
		}
		solveAndOutput(result);
		result.clear();
	}
	return 0;
}

Measured memory_bytes: 1672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

/* modとる */
inline ll modu(ll a){
    return(a % mod + mod) % mod;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N = in<ll>();
    ll answer = 0;
    vector<ll> A(N);
    REP(i,N)A[i] = in<ll>();
    REP(i,62){
        ll sum = 0;
        REP(l,N){
            if(A[l] & 1LL << i)sum++;
        }
        answer = modu(answer + modu(sum*(N-sum))*modu(1LL << i));
    }
    cout << answer << "\n";
}

Measured memory_bytes: 2560
#include <iostream>
#include<set>
#include<vector>
#include<string>

using namespace std;
int mod = 1000000007;
int inv = (mod + 1) / 2;

int add(int x, int y)
{
	int c = x + y;
	if (c >= mod)c -= mod;
	return c;
}

int sub(int x, int y)
{
	int c = x - y;
	if (c < 0)c += mod;
	return c;
}

int mlt(int x, int y)
{
	long long c = x * 1LL * y;
	if (c >= mod)c %= mod;
	return c;
}

int main()
{
	int n;
	cin >> n;
	vector<int> p(n), comps(n), broken(n), sz(n);
	for (int i = 0; i < n; i++)
		comps[i] = i;
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
		p[i]--;
		if (p[i] != -2)
		{
			int vall = comps[p[i]];
			for (int j = 0; j < n; j++)
				if (comps[j] == vall)
					comps[j] = comps[i];
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (p[i] == -2)
			broken[comps[i]] = -1;
	}
	int val = 0, ans = 0;
	for (int i = 0; i < n; i++)
		if (p[i] == -2)val++;
	vector<int> nm;
	vector<int> facts(9999), pows(9999);
	facts[0] = 1;
	pows[0] = 1;
	for (int i = 1; i < (int) facts.size(); i++)
	{
		facts[i] = mlt(facts[i - 1], i);
		pows[i] = mlt(pows[i - 1], n - 1);
	}
	for (int i = 0; i < n; i++)
		sz[comps[i]]++;
	for (int i = 0; i < n; i++)
	{
		if (sz[i] > 0)
		{
			if (broken[i] == 0)
			{
				ans = add(ans, pows[val]);
			}
			else
				nm.push_back(sz[i]);
		}
	}
//	cout<<ans<<endl;
	vector<int> dp(nm.size() + 1);
	dp[0] = 1;
	for (int i = 1; i <= (int) nm.size(); i++)
	{
		vector<int> newdp(dp.size());
		newdp[0] = 1;
		for (int j = 1; j < (int) dp.size(); j++)
		{
			newdp[j] = add(dp[j], mlt(dp[j - 1], nm[i - 1]));
		}
		dp = newdp;
	}
	/*for(int i=0; i<dp.size(); i++)
		cout<<dp[i]<<' ';
	cout<<endl;
	cout<<ans<<endl;*/
	for (int i = 1; i <= val; i++)
	{
		int cur = dp[i];
		cur = mlt(cur, facts[i - 1]);
		cur = mlt(cur, pows[val - i]);
		ans = add(ans, cur);
	}
//	cout<<ans<<endl;
	for (int i = 0; i < val; i++)
	{
		ans = sub(ans, pows[val - 1]);
	}
//	cout<<ans<<endl;
	ans = sub(pows[val + 1], ans);
	ans = add(ans, pows[val]);
	cout << ans << endl;
}


Measured memory_bytes: 3848
A=int(input())
B=int(input())
C=int(input())
X=int(input())

ans=0

for i in range(A+1):
    Xi = X-500*i
    if Xi >= 0:
        for j in range(B+1):
            Xj = Xi - 100*j
            if Xj >= 0 and (Xj / 50) <= C:
                ans +=1
print(ans)


Measured memory_bytes: 3060
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func main() {
	sc.Split(bufio.ScanWords)
	N, M := getInt(), getInt()

	total := (N-M)*100 + 1900*M
	num := 1 << uint(M)

	out(total * num)
}


Measured memory_bytes: 640
import math,heapq,collections,sys,numpy
sys.setrecursionlimit(10**7)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

H,W = LI()
LS = []
LS.append("@"*(W+2))
for _ in range(H):
    LS.append("@" + S() + "@")
LS.append("@"*(W+2))

def count(i,j):
    c = 0
    for k in range(-1,2):
        for l in range(-1,2):
            if LS[i+k][j+l] == "#":
                c +=1
    return c

for i in range(1,H+1):
    for j in range(1,W+1):
        if LS[i][j] == ".":
            LS[i] = LS[i][0:j] + str(count(i,j)) +  LS[i][j+1:W+2]

for i in range(1,H+1):
    print(LS[i][1:W+1])



Measured memory_bytes: 15872
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

struct SegmentTree {
private:
    ll n;
    vector<ll> node;

public:

    SegmentTree(vector<ll> v) {
        ll sz = v.size();
        n = 1;
        while(n < sz) {
            n *= 2;
        }
        node.resize(2*n - 1, 0);
        rep(i, sz) {
            node[i+n-1] = v[i];
        }
        for(ll i = n-2; i >= 0; i--) {
            node[i] = node[2*i + 1] + node[2*i + 2];
        }
    }

    // i番目のノードの値にxを足す
    void add(ll i, ll x) {
        i += n-1;  // i番目の葉のノード番号
        node[i] += x;
        while(i > 0) {
            i = (i - 1)/2;  // ノードiの親ノードの番号に変える
            node[i] = node[2*i + 1] + node[2*i + 2];  // 左右の子の和を計算する
        }
    }
    
    // 区間[a,b)の総和を返す
    ll getsum(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
        // 区間[a,b)に対するクエリについてノードk(区間[l, r)担当)が答える
        if(r < 0) {
            r = n;  // 最初に呼び出されたときの対象区間は[0,n)
        }
        if(b <= l || r <= a) {
            return 0;  // 区間が被らない場合は0を返す
        }
        if(a <= l && r <= b) {
            return node[k];  // ノードkの担当範囲が区間[a,b)に完全に含まれる
        }
        // 一部だけ範囲が被る場合は左右の子に委託する
        ll c1 = getsum(a, b, 2*k + 1, l, (l + r)/2);
        ll c2 = getsum(a, b, 2*k + 2, (l + r)/2, r);
        return c1 + c2;  // 左右の子の値の和をとる
    }

};

int main() {
    ll n, q;
    cin >> n >> q;
    
    SegmentTree seg(vector<ll>(n, 0));
    rep(i, q) {
        ll c, x, y;
        cin >> c >> x >> y;
        x--;  y--;  // 0-indexにする
        if(c == 0) {
            seg.add(x, y+1);
        }
        else {
            out(seg.getsum(x, y+1));
        }
    }
    
    re0;
}


Measured memory_bytes: 5720
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include<ext/pb_ds/assoc_container.hpp>
//#nclude<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 1000005


int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("in.txt","r",stdin);
//   freopen("out.txt","w",stdout);
    int t,n,m,k,a,b,c;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0&&i%15!=0) sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

vector<pair<string, int> > res;
vector<int> id;

void swap(int i, int j){
  string f = res[i].first;
  int s = res[i].second;
  res[i].first = res[j].first;
  res[i].second = res[j].second;
  res[j].first = f;
  res[j].second = s;
  int ide = id[i];
  id[i] = id[j];
  id[j] = ide;
  return;
}

signed main(){
  int n;
  cin >> n;
  LOOP(i,n){
    string s;
    int p;
    cin >> s >> p;
    res.push_back(pair<string,int>(s,p));
    id.push_back(i+1);
  }
  LOOP(i,n){
    FOR(j,i+1,n){
      if(res[i].first > res[j].first){
        cerr << res[i].first << "is bigger than " << res[j].first << ":" << i << ":" << j << endl;
        swap(i,j);
      }
      if(res[i].first == res[j].first){
        if(res[i].second < res[j].second){
          swap(i,j);
        }
      }
    }
  }
  LOOP(i,n){
    cout << id[i] << endl;
  }
}


Measured memory_bytes: 256
# D - Integer Cards
# https://atcoder.jp/contests/abc127/tasks/abc127_d

import sys

n, m = list(map(int, sys.stdin.readline().split()))
cards = list(map(int, sys.stdin.readline().split()))

combinations = [list(map(int, sys.stdin.readline().split())) for _ in range(m)]

cards.sort()
combinations.sort(key=lambda x: x[1], reverse=True)

i = 0
for b, c in combinations:
    for k in range(i, min(n, i + b)):
        if cards[k] < c:
            cards[k] = c
            i += 1
        else:
            break

print(sum(cards))


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

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

    long long N,K;
    cin >> N >> K;
    if(K<N) N=(N%K);
    long long int prevN = N+1;
    while(prevN>N){
        prevN = N;
        N = abs(N-K);
    }
    cout << prevN;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P) {
	int i = 0;
	for (int j = 0; j < k; j++) {
		llong s = 0;
		while (s + T[i] <= P) {
			s += T[i];
			i++;
			if (i == n) return n;
		}
	}
	return i;
}

int solve() {
	llong left = 0;
	llong right = 100000 * 10000;
	llong mid;
	while (right - left > 1) {
		mid = (left + right) / 2;
		int v = check(mid);
		if (v >= n) right = mid;
		else left = mid;
	}
	return right;
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> T[i];
	llong ans = solve();
	cout << ans << endl;
}


Measured memory_bytes: 3888
import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
    public static boolean slove(String c){
        char m[]=c.toCharArray();
        for(int i=0;i<m.length;i++){
            if(m[i]!=m[m.length-1-i])
                return false;
        }
        return true;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedInputStream(System.in));
        String s=sc.next();
        String x=s.substring(0,(s.length()-1)/2);
        String y=s.substring((s.length()+2)/2);
        //System.out.println(x+"  "+y);
        if(Main.slove(s)&&Main.slove(x)&&Main.slove(y))
            System.out.println("Yes");
        else
            System.out.println("No");

    }
}

Measured memory_bytes: 23764
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<list>
using namespace std;

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

	int n;
	cin >> n;
	int mx = 0;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		mx = max(mx, v[i]);
	}
	sort(v.begin(), v.end());

	int q;
	cin >> q;
	int key;
	int cnt = 0;
	for (int i = 0; i < q; i++) {
		cin >> key;
		if (key > mx)continue;
		else {
			auto it = lower_bound(v.begin(), v.end(), key);
			if (*it == key)cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m;
	cin >> n >> m;
	vector<pii> v, range(n);
	REP(i, n) range[i] = pii(i, i);
	REP(i, m)
	{
		int a, b; cin >> a >> b;
		v.emplace_back(a, b-1);
	}
	sort(ALL(v));
	for (auto p : v)
	{
		int t = p.second;
		range[t] = range[t + 1] = pii(range[t].first, range[t + 1].second);
	}
	REP(i, range.size())
	{
		cout << range[i].second - range[i].first + 1 << (i == range.size() - 1 ? "\n" : " ");
	}
	return 0;
}


Measured memory_bytes: 5472
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y << endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
 
using namespace std;
 
bool compare(ll &x, ll &y){
    return x>=y;
}
 
ll mode=pow(10,9)+7;

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

	ll dp[100005]={0};
	for(int i=0;i<100005;i++){
		if (i>=1 && i<=9){
			dp[i]++;
		}
		else if (i>=100 && i<=999){
			dp[i]++;
		}
		else if (i>=10000 && i<=99999){
			dp[i]++;
		}
	}
	
	ll n;
	cin>>n;
	ll ans=0;
	for (int i=0;i<=n;i++){
		ans=ans+dp[i];
	}
	cout<<ans<<endl;
		
    return 0; 
}
	

Measured memory_bytes: 1152
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))


n, m = load_list()

ac = dict()
pena = defaultdict(int)
a, b = 0, 0
for _ in range(m):
    p, r = input().split(" ")
    p = int(p)
    r = r.strip()
    if r == 'AC' and p not in ac:
        a += 1
        ac[p] = 1
        b += pena[p]
    elif r == 'WA' and p not in ac:
        pena[p] += 1

print(a,b)



Measured memory_bytes: 21576
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
ll n,v[maxn],s,a[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
	cin>>n;
    map<ll,ll>m;
    for(int i=1;i<=n;i++){
        cin>>v[i];
        m[v[i]]++;
    }
    for(auto it=m.begin();it!=m.end();it++)
        s=s+it->second*(it->second-1)/2;

    for(int i=1;i<=n;i++){
        cout<<s-(m[v[i]]*(m[v[i]]-1)/2)+((m[v[i]]-1)*(m[v[i]]-2)/2)<<endl;
    }
    return 0;
}

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

using namespace std;

const int N=100005;
vector<int> g[N];
int dp[N],n,m,deg[N],to[N],nn=0;
void topo_sort()
{
    queue<int> q;
    for(int u=1;u<=n;u++)
        if (!deg[u])
        {
            q.push(u);
        }
    while (!q.empty())
    {
        int u=q.front();q.pop();
        to[++nn]=u;
        for(auto v:g[u])
        {
            deg[v]--;
            if (!deg[v]) q.push(v);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
        deg[v]++;
    }

    topo_sort();
    //for(int u=1;u<=n;u++) cout<<deg[u]<<' ';
    for(int i=1;i<=n;i++)
    {
        int u=to[i];
        for(auto v:g[u])
            dp[v]=max(dp[v],dp[u]+1);
    }
     int ans=0;
     for(int i=1;i<=n;i++)
        ans=max(ans,dp[i]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6912
MOD = 10 ** 9 + 7
N, K = map(int, input().split())
As = sorted(list(map(int, input().split())))

def getInvs(n, MOD):
    invs = [0] * (n+1)
    invs[1] = 1
    for x in range(2, n+1):
        invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
    return invs
invs = getInvs(N, MOD)

combiK = []
for i in range(K-1):
    combiK.append(0)
combiK.append(1)
for i in range(K, N+1):
    c = combiK[-1]
    combiK.append((c * i * invs[i-K+1]) % MOD)

ans = 0
for i, a in enumerate(As):
    ans -= a * combiK[N-i-1]
    ans += a * combiK[i]
    ans %= MOD
print(ans)

Measured memory_bytes: 14416
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979323846;

int main() {
  string S;
  cin >> S;
  for (int i=0; i<S.size(); i++) {
    if (S[i]=='?') S[i] = 'D';
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 3756
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL n,m;
	cin>>n>>m;
	if(n==1&&m==1)cout<<1<<endl;
	else if(n==1||m==1){
		LL t=max(n,m);
		cout<<t-2<<endl;
	}else{
		cout<<(n-2)*(m-2)<<endl;
	}

    return 0;
}


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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int N;
	cin >> N;
	long long int sum = 0;
	vector<int> c;
	long long int pulus = 0;
	long long int check = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		c.push_back(abs(a));
		sum = sum + abs(a);
		if (a == 0) {
			check = 1;
		}
		if (a < 0) {
			pulus++;
		}
	}
	sort(c.begin(), c.end());
	if (check == 1) {
		cout << sum;
	}
	else {
		if (pulus % 2 == 0) {
			cout << sum;
		}
		else {
			int d = c[0] * 2;
			cout << sum - d;
		}
	}
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define ll long long
#define maxn (1000+10)
#define mod 10000003
#define lnode node*2,start,mid
#define rnode node*2+1,mid+1,end
using namespace std;
int main()
{   ios::sync_with_stdio(false);
	#define int ll
	string s;
	int a;
	cin>>a>>s;
	if(a<3200) cout<<"red";
	else cout<<s;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s, t;
int ls, lt, sum, ans, i, j;
int main() {
	cin >> s >> t;
	ls = s.size(); lt = t.size();
	for (i = 0, ans = 0x3f3f3f3f; i <= ls - lt; i++) {
		for (j = 0, sum = 0; j < lt; j++) if (s[i + j] != t[j]) sum++;
		ans = min (ans, sum);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3616
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int K; cin >> K;

    int ans;
    if (K%2==0) {
        ans = (K/2) * (K/2);
    } else {
        ans = ((K + 1)/2) * (K / 2);
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
    int x,y,i,p=0;
    cin>>x>>y;
    for(i=0;i<=100;i++)
    {
        p=x-i;
        if(p>=0)
        {
            if((i*2+p*4)==y)
            {
                cout<<"Yes"<<endl;
            return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}





Measured memory_bytes: 3612
#include <stdio.h>

int main(void) {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  printf("%d %d %d %d", c + b - d, d - a + c, a + b - d, b - a + c);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>



int n,cost;
int A[1001],B[1001];
int L[501],R[502];


void merge(int left,int mid,int right){
  int i,j,n1=mid-left,n2=right-mid;
  for(i=0;i<n1;i++) L[i]=A[left+i];
  L[n1]=INT_MAX;
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  R[n2]=INT_MAX;
  int l=0,r=0;
  for(i=left;i<right;i++){
    if(L[l]<=R[r]){
      A[i]=L[l];
      l++;
    }
    else{
      A[i]=R[r];
      r++;
    }
  }
}


void m_sort(int left,int right){
  int mid;
  if( left+1 >= right) return;
  mid=(left+right)/2;
  m_sort(left,mid);
  m_sort(mid,right);
  merge(left,mid,right);
}


void swap(int a,int b,int *C){
  int swap;
  swap=C[a];
  C[a]=C[b];
  C[b]=swap;
}






  
 
  

int main(){
  scanf("%d",&n);
  int i,j;
  int cnt,sum,min,start,x;
  int C[1001]={};
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    B[i]=A[i];
  }
  m_sort(0,n);
  for(i=0;i<n;i++){
    if(A[i]==B[i]) C[i]=1;
  }
  cost=0;
  for(i=0;i<n;i++){
    if(C[i]!=1){
      C[i]=1;
      cnt=0;
      sum=0;
      min=B[i];
      x=i;
      while(1){
        for(j=0;j<n;j++){
          if(B[x]==A[j]){
            C[j]=1;
            cnt++;
            sum+=B[j];
            if(min > B[j]) min=B[j];
            x=j;
            break;
          }
        }
        if(x==i) break;
      }
      sum-=min;
      if( (cnt -1)*min > (cnt -1)*A[0]+2*(min +A[0])) cost+=sum+(cnt-1)*A[0]+2*(min +A[0]);
      else cost+=sum+(cnt-1)*min;
    }
  }
  printf("%d\n",cost);
  return 0;
}

          
          
    

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int maxn = 2e5 + 5;

int n;
string b[maxn];
ll a[maxn];
ll cnt2[maxn], cnt5[maxn];
ll ans;
map<pll, ll> mp;

int main(){
	cin >> n;
	FOR(i, 0, n){
		cin >> b[i];
		ll pre = 0, suf = 0;
		int it = 0;
		while(it < b[i].size() && b[i][it] != '.')
			(pre *= 10) += b[i][it++] - '0';
		if(it < b[i].size()){
			++it; int len = 0;
			while(it < b[i].size())
				(suf *= 10) += b[i][it++] - '0', ++len;
			while(len < 9)
				suf *= 10, ++len;
		}
		a[i] = pre * 1000000000 + suf;
		while(!(a[i] % 2))
			++cnt2[i], a[i] /= 2;
		while(!(a[i] % 5))
			++cnt5[i], a[i] /= 5;
		cnt2[i] -= 9;
		cnt5[i] -= 9;
		++mp[MP(cnt2[i], cnt5[i])];
	}
	for(map<pll, ll>::iterator i = mp.begin(); i != mp.end(); ++i){
		for(map<pll, ll>::iterator j = mp.begin(); j != mp.end(); ++j){
			pll p = i -> fst, q = j -> fst;
			if(p.fst + q.fst >= 0 && p.snd + q.snd >= 0){
				if(i != j)
					ans += i -> snd * j -> snd;
				else
					ans += i -> snd * (j -> snd - 1);
			}
		}
	}
	cout << ans / 2 << endl; 
	return 0;
}


Measured memory_bytes: 14496
#include <stdio.h>
int linear(int[], int, int);
int main()
{
    int i, j, s[10001], t, n, q, sum = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &s[i]);
    scanf("%d", &q);
    for (j = 0; j < q; j++)
    {
        scanf("%d", &t);
        if (linear(s, n, t))
            sum++;
    }
    printf("%d\n", sum);
    return 0;
}
int linear(int s[], int n, int t)
{
    int i = 0;
    s[n] = t;
    while (s[i] != t)
        i++;
    return i != n;
}


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

int main()
{
    string s;
    cin >> s;
    string front, rear;
    int len = (s.length() - 1) / 2;
    front = s.substr(0, len);
    rear = s.substr((s.length() + 2) / 2, len);
    rep(i, len)
    {
        if (front[i] != front[len - i - 1] || rear[i] != rear[len - i - 1])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i, s.length())
    {
        if (s[i] != s[s.length() - i - 1])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int l = A+B;
  int r = C+D;
  if (l > r) cout << "Left" << endl;
  else if (l == r) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}


Measured memory_bytes: 256
def solve(n, A):
    total = sum(A)
    x = A[0]
    ret = abs(2 * x - total)
    for i in range(1, n - 1):
        x += A[i]
        y = total - x
        if abs(x - y) < ret:
            ret = abs(x - y)
    return ret

_n = int(input())
_A = list(map(int, input().split()))
print(solve(_n, _A))


Measured memory_bytes: 24816
#include<stdio.h>
int main (void)
{
	int n,s,m;
	int i;

	for(i=0;i<4;i++){
		scanf("%d %d",&n,&s);
		if(n==1){
			m=6000*s;
		}
		else if(n==2){
			m=4000*s;
		}
		else if(n==3){
			m=3000*s;
		}
		else if(n==4){
			m=2000*s;
		}
		printf("%d\n",m);
	}
	return 0;
}

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

int main(){
  int N,M;
  cin >>N >>M;
  vector<int> a(M);
  vector<int> b(M);
  for(int i=0; i<M; i++)
    cin >>a.at(i) >>b.at(i);
  for(int i=0; i<N; i++){
    int x=0;
    for(int j=0; j<M; j++){
      if(a.at(j)==(i+1)||b.at(j)==(i+1))
        x++;
    }
    cout <<x <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
////////////////////////////////////////////////////////////

signed main() {
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  vector<int>bit(34);
  rep(i,n){
    int t=a[i];
    int b=0;
    while(t>0){
      if(t&1)bit[b]++;
      t/=2;
      b++;
    }
  }
  rep(i,n){
    int t=a[i];
    int b=0;
    int ans=0;
    while(b<34){
      int others1=bit[b];
      if(t&1){others1--;}
      if(others1%2==1)ans+=pow(2,b);
      t/=2;
      b++;
    }
    cout<<ans<<' ';
  }
  }


Measured memory_bytes: 4720
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, L;
    cin >> N >> L;
    vector<string> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];
    sort(v.begin(), v.end());
    for (string s : v) cout << s;
    cout << '\n';
}


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

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin >> n >> m;
	vector<int> penal(n+1);
	vector<bool> vu(n+1);
	for (int i=0; i<m; ++i){
		int a;
		string s;
		cin >> a >> s;
		if (vu[a]) continue;
		else{
			if (s == "WA" and !vu[a]) penal[a]++;
			else vu[a] = true;
		}
	}
	int penalty = 0, acs = 0;
	for (int i=1; i<=n; ++i){
		if (vu[i]){
			acs++;
			penalty += penal[i];
		}
	}
	cout << acs << ' ' << penalty << '\n';
	return 0;
}


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

int main() {
  int N,M;
  cin>>N>>M;
  string A[50],B[50];
  for (int i(0);i<N;i++)cin>>A[i];
  for (int i(0);i<M;i++)cin>>B[i];
  for (int i(0);i<N;i++){
    for (int j(0);j<N;j++){
      bool flag=true;
      for (int im(0);im<M;im++){
        for (int jm(0);jm<M;jm++){
          if (A[i+im][j+jm]!=B[im][jm]) flag=false;
        }
      }
      if (flag==true){
        cout << "Yes" <<endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int main(void) {
    char c;
    cin>>c;

    if(c == 'A') {
        cout<<"T"<<endl;
    } else if(c == 'T') {
        cout<<"A"<<endl;
    } else if(c == 'C') {
        cout<<"G"<<endl;
    } else {
        cout<<"C"<<endl;
    }

    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    int N;cin>>N;
    int x[N];
    REP(i,N)cin>>x[i];
    LL L;cin>>L;
    int logN = (int)log2(N) + 1;

    int doub[N][logN+1];
    fill(doub[0],doub[N],x[N-1]+1);
    REP(i,N-1)doub[i][0]=upper_bound(x,x+N,x[i]+L)-x-1;
    REP(k,logN)REP(i,N)doub[i][k+1]=doub[min(N-1,doub[i][k])][k];

    int q;cin>>q;
    REP(i,q){
        int a,b;cin>>a>>b;
        if(a>b)swap(a,b);
        a--;b--;

        int ans=0;
        for(int i=logN-1;i>=0;i--){
            if(doub[a][i]<b){
                ans+= 1<<i;
                a = doub[a][i];
            }
        }

        cout<<(a==b ? ans:ans+1)<<endl;
    }
    return 0;
}

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

using namespace std;

typedef long long int64;
const int64 mod = 1e9 + 7;

int main()
{
  int H, W, N, A[10000];

  cin >> H >> W;
  cin >> N;
  for(int i = 0; i < N; i++) cin >> A[i];

  int tail = 0;
  for(int i = 0; i < H; i++) {
    vector< int > vec;
    for(int j = 0; j < W; j++) {
      vec.push_back(tail + 1);
      --A[tail];
      if(A[tail] == 0) ++tail;
    }
    if(i & 1) reverse(begin(vec), end(vec));
    for(auto& p : vec) cout << p << " ";
    cout << endl;
  }
}


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

int main() {
  int N, M;
  cin >> N;
  vector<int> T(N);
  for (int i = 0; i < N; i++) {
    cin >> T[i];
  }
  cin >> M;
  vector<int> P(M);
  vector<int> X(M);
  for (int i = 0; i < M; i++) {
    cin >> P[i] >> X[i];
  }
  int sum = accumulate(T.begin(), T.end(), 0);
  for (int i = 0; i < M; i++) {
    cout << sum - T[P[i] - 1] + X[i] << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;



int main(){
  ll N;
  cin >> N;
  ll M;
  cin >> M;
  vector<ll> H(N,0);
  for(ll i=0;i<N;i++){
    cin>>H[i]
  ;}
  vector<ll> A(M,0);
  vector<ll> B(M,0);
  for(ll i=0;i<M;i++){
    cin>>A[i]>>B[i];
    A[i]--;B[i]--;
  ;}
  vector<vector<ll>> cango(N, vector<ll>(0));
  for(ll i=0;i<M;i++){
    cango[A[i]].emplace_back(B[i]);
    cango[B[i]].emplace_back(A[i]);
  ;}
  ll ans=0;
  for(ll i=0;i<N;i++){
    ll Max=H[i];
    bool ok=1;
    for(ll j=0;j<cango[i].size();j++){
      ll k=cango[i][j];
      if(H[k]>=Max){ok=0;break;}
    ;}
    if(ok)ans++;

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


Measured memory_bytes: 11444
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    double sum = 0;
    rep (i, 0, N) {
        double a; cin >> a;
        sum += 1/a;
    }
    double ans = 1/sum;
    printf("%.14f", 1/sum);
}

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


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int               long long
#define endl              '\n'
#define ff                first
#define ss                second
#define mp                make_pair
#define pb                push_back
#define vii               vector<int> 
#define pii               pair<int,int>
#define vpii              vector< pii >
#define all(v)            v.begin(),v.end()
#define loop(i,s,e)       for(int i=s;i<e;i++)
#define rloop(i,e,s)      for(int i=e;i>=s;i--)
#define mset(a,f)              memset(a,f,sizeof(a))
#define M                 1000000007
#define fastio            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define prvec(v)          loop(i_u_j,0,v.size())cout << v[i_u_j] <<" "; cout << endl;
#define prarr(arr,n)      loop(i_u_j,0,n)cout << arr[i_u_j] << " "; cout << endl;
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)


template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //
const int N = 3e5 + 7;
int n, k;
int arr[N];
int dp[N];
int getans(int id)
{     
      if( dp[id] != -1 ) return dp[id];
      if( id  == n - 1  ) return 0;

      int ans = 1e18;
      loop(i,1,k+1)
      {
           if( id + i < n) ans = min(ans, abs(arr[id] - arr[id+i]) + getans(id+i));
      }

      return dp[id] = ans;
}
void solve()
{
      cin >> n >> k;
      loop(i,0,n) cin >> arr[i];
      mset(dp,-1);
      cout << getans(0);
}

int32_t main() {
    fastio;

  
  int t = 1; 
  //cin>>t;
  
  while(t--) solve();
  
  


}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //















Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define print(n) cout << n << endl
#define YN(c) (c)?(print("YES")):(print("NO"))
#define Yn(c) (c)?(print("Yes")):(print("No"))
#define yn(c) (c)?(print("yes")):(print("no"))
#define in(v) int v; cin >> v
#define vint vector<int>
#define pb push_back
typedef long long int ll;

int main(){
  double r;cin>>r;
  print(2*3.1415*r);
  return 0;
}


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

int main() {
	char S[10];
	int X = 0, i , min, len;

	scanf("%s", S);
	len = strlen(S);

	X = X + (S[0] - '0') * 100;
	X = X + (S[1] - '0') * 10;
	X = X + (S[2] - '0');
	min = abs(753 - X);
	for (i = 3; i < len; i++) {
		X = (X % 100) * 10 + (S[i] - '0');
		if (abs(753 - X) < min) min = abs(753 - X);
	}

	printf("%d", min);

	return 0;
}

Measured memory_bytes: 128