akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <iostream>
using namespace std;

int main(void){
	int i,j;

	for(i=1;i<10;i++){
		for(j=1;j<10;j++){
			std::cout << i << "x" << j << "=" << i*j << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 0
animalNum,footNum = map(int,input().split())
kameFoot = 2
turuFoot = 4
totalFoot = 0
ansList = ["Yes","No"]
isYes = False
for i in range(animalNum + 1):
    totalFoot = (kameFoot * i + (turuFoot * (animalNum - i)))
    if(totalFoot == footNum):
        isYes = True
        
if(isYes):
    print(ansList[0])
else:
    print(ansList[1])

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

int main()
{
	int a, b, c, d; cin >> a >> b >> c >> d;
		
	string ans;

	if (a + b > c + d) ans = "Left";
	else if(a + b < c + d) ans = "Right";
	else ans = "Balanced";

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

Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int n, a[100009]; pair<int, int> x[100009];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]), x[i] = make_pair(a[i], i);
	sort(x, x + n);
	for (int i = 0; i < n; i++) a[x[i].second] = i;
	long long ret = 0;
	for (int i = 0; i < n; i++) {
		if (i & 1) ret += 1 - (a[i] & 1);
		else ret += (a[i] & 1);
	}
	printf("%lld\n", ret / 2);
	return 0;
}

Measured memory_bytes: 1408
def root(x):
    if x == parent[x]:
        return x
    parent[x] = root(parent[x])
    return parent[x]
def unite(x, y):
    px = root(x); py = root(y)
    if px < py:
        parent[py] = px
    else:
        parent[px] = py
while 1:
    A = []; B = []
    n, m, k = map(int, raw_input().split())
    if n == m == k == 0:
        break
    parent = range(n)
    for i in xrange(m):
        u, v, w, l = raw_input().split()
        u = int(u)-1; v = int(v)-1; w = int(w)
        if l is 'A':
            A.append((w, u, v))
        else:
            B.append((w, u, v))
    A.sort(); B.sort()
    E = [[] for i in xrange(n)]
    ans = 0
    cnt = 0
    for w, u, v in A:
        if root(u) != root(v):
            unite(u, v)
            ans += w
            p = [1]
            E[u].append((v, w, p))
            E[v].append((u, w, p))
            cnt += 1
    if cnt < k:
        print -1
        continue
    used = [0]*len(B)
    rest = n-k-1
    for i, (w, u, v) in enumerate(B):
        if root(u) != root(v):
            unite(u, v)
            ans += w
            used[i] = 1
            p = [2]
            E[u].append((v, w, p))
            E[v].append((u, w, p))
            rest -= 1
            cnt += 1
    if cnt != n-1:
        print -1
        continue

    def dfs(v, s, prev):
        if v == s:
            return (-1, None)
        for i, (to, w, can) in enumerate(E[v]):
            if to == prev or can[0] == 0:
                continue
            res = dfs(to, s, v)
            if res is not None:
                if can[0] == 1:
                    return max(res, (w, can))
                else:
                    return res
        return None

    for t in xrange(rest):
        res = (10**18, None, None)
        for i, (w, u, v) in enumerate(B):
            if used[i]:
                continue
            rr = dfs(u, v, -1)
            cost, can = rr
            if cost != -1:
                res = min(res, (w - cost, i, can))
        co, i, can = res
        if i is None:
            print -1
            break
        ans += co
        can[0] = 0

        w, u, v = B[i]
        used[i] = 1
        p = [2]
        E[u].append((v, w, p))
        E[v].append((u, w, p))
    else:
        print ans
        if ans == 272:
            print A, B

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

//	LLONG_MAX 9.2*1e18	9223372036854775807LL = (2^63)-1
//	INT_MAX 2.1*1e9 2147483647 = (2^31)-1
//	O(1e8) 1.2sec

void Main()
{
	int N;
	cin>>N;
	int cnt=0;
	bool flag=0;
	rep(i,N){
		int D,E;
		cin>>D>>E;
		if(D==E)cnt++;
		else cnt=0;
		if(cnt>=3){flag=true;}
	}
	if(flag) cout<<"Yes"<<_n;
	else cout<<"No"<<_n;
}


void Test();
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	if (S == "KIHBR" ||
		S == "AKIHBR" ||
		S == "KIHABR" ||
		S == "KIHBAR" ||
		S == "KIHBRA" ||
		S == "AKIHABR" ||
		S == "AKIHBRA" ||
		S == "AKIHBAR" ||
		S == "KIHABAR" ||
		S == "KIHABRA" ||
		S == "KIHBARA" ||
		S == "AKIHABAR" ||
		S == "AKIHABRA" ||
		S == "AKIHBARA" ||
		S == "KIHABARA" ||
		S == "AKIHABARA"
		)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back





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







}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f,N=1e6;
int n,m,a[N],nxt[N],pre[N];
char c[N];
void pt(int x)
{
	if(x==0)return;
	pt(pre[x]);printf("%d ",x-pre[x]);
}
int main()
{
	scanf("%s",c+1);long long ans=0,la=0;
	for(int i=1;i<=strlen(c+1);i++)
	{
		if(c[i]=='W')ans+=la;else la++;
	}cout<<ans;return 0;
	scanf("%s",c);
	for(int i=n;i;i--)
	{
		if(c[i]=='0')nxt[i]=i;
		else nxt[i]=nxt[i+1];
	}
	for(int i=1;i<=n;i++)
	{
		int j=max(0,i-m);
		j=nxt[j];
		if(j>=i)return puts("-1"),0;
		pre[i]=j;
	}
	pt(n);
	return 0;
}


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

#define MAX 100000
int n, k;
long long T[MAX];

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


long long solve(){
  long long left = 0;
  long long right = 100000 * 10000;
  long long mid;

  while (right - left > 1) {
    mid = (right + left) / 2;
    int v = check(mid);
    if (v >= n) {
      right = mid;
    }else{
      left = mid;
    }
  }

  return right;
}


int main(int argc, char const *argv[]) {
  cin >> n >> k;
  for(int i = 0; i < n; i++)  cin >> T[i];
  long long ans = solve();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll a[3];
ll ans = 0;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> a[0] >> a[1] >> a[2];
    while (1) {
        if (a[0] == a[1] && a[1] == a[2] && a[0] % 2 == 0) {
            cout << -1 << endl;
            return 0;
        }
        if (a[0]%2 || a[1]%2 || a[2]%2) break;
        ll pa = a[0], pb = a[1], pc = a[2];
        a[0] = (pb+pc)/2;
        a[1] = (pa+pc)/2;
        a[2] = (pa+pb)/2;
        ans++;
    }   
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[100001];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int mine=0;
	int kuboti=0;
	for(int i=1;i+1<n;i++){
		if(a[i-1]>a[i] && a[i]<a[i+1]){
			kuboti++;
		}
		if(a[i-1]<a[i] && a[i]>a[i+1]){
			mine++;
		}
	}
	vector<P> vec;
	vec.push_back(P(a[0],1));
	for(int i=1;i<n;i++){
		if(a[i]==vec.back().first){
			vec.back().second++;
		}else{
			vec.push_back(P(a[i],1));
		}
	}
	int kogen=0,bonti=0,sanpuku=0;
	for(int i=1;i+1<vec.size();i++){
		if(vec[i-1].first<vec[i].first && vec[i].first>vec[i+1].first){
			if(vec[i].second>=2)kogen++;
		}else if(vec[i-1].first>vec[i].first && vec[i].first<vec[i+1].first){
			if(vec[i].second>=2)bonti++;
		}else{
			if(vec[i].second>=2){
				sanpuku++;
			}
		}
	}
	printf("%d %d %d %d %d\n",kogen,bonti,sanpuku,mine,kuboti);
	return 0;
}



Measured memory_bytes: 4252
#include <bits/stdc++.h>
using namespace std;
#define AC 0
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++) cin>>a[i];
	long long sum=0;
	for(int i=1;i<=n;i++) {
		if(a[i-1]>a[i]) {
			sum+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	cout<<sum;
	return AC;
}


Measured memory_bytes: 3984
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		int a=cin.nextInt();
		int b=cin.nextInt();
		int c=cin.nextInt();
		int d=cin.nextInt();
		System.out.println(Math.min(a,b)+Math.min(c, d));
	}
}


Measured memory_bytes: 21972
import numpy as np
N=int(input())
W=list(map(int,input().split()))
ΔS=np.zeros(N)
for i in range(N):
  S1=0
  S2=0
  for j in range(0,i+1):
    S1+=W[j]
  for j in range(i+1,N):
    S2+=W[j]
  ΔS[i]=abs(S1-S2)
print(int(min(ΔS)))

Measured memory_bytes: 12240
#include <bits/stdc++.h>
using namespace std;
long long v[300005], w[300005], dp[520][100005];
int n;
long long solve(int x, int y){
	if(x<=512) return dp[x][y];
	if(y<w[x]) return solve(x/2, y);
	return max(solve(x/2, y), solve(x/2, y-w[x])+v[x]);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>v[i]>>w[i];
	}
	memset(dp, 0, sizeof dp);
	for(int i=1;i<=min(512, n);i++){
		for(int j=0;j<=100000;j++){
			if(j<w[i]) dp[i][j]=dp[i/2][j];
			else dp[i][j]=max(dp[i/2][j], dp[i/2][j-w[i]]+v[i]);
		}
	}
	int q;
	cin>>q;
	while(q--){
		int v, w;
		cin>>v>>w;
		cout<<solve(v, w)<<"\n";
	}
}


Measured memory_bytes: 414040
class UnionFind:
    def __init__(self, n):
        #親要素のノード番号を格納。par[x] == xのときそのノードはroot
        self.par = [i for i in range(n)]
        #木の高さ（初期状態では0）
        self.rank = [0] * n

    def find(self, x):
        #木の根を求める
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same(self, x, y):
        # xとyが同じ集合に属するかを判定
        return self.find(x) == self.find(y)

    def union(self, x, y):
        #併合する
        #まず根を探す
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
N = int(input())
towns = [[i] + list(map(int, input().split())) for i in range(N)]
roads = []
towns.sort(key = lambda x: x[1])
for i in range(N - 1):
    num1, x1, y1 = towns[i]
    num2, x2, y2 = towns[i + 1]
    dist = min(abs(x1 - x2), abs(y1 - y2))
    roads.append([dist, num1, num2])
towns.sort(key = lambda x: x[2])
for i in range(N - 1):
    num1, x1, y1 = towns[i]
    num2, x2, y2 = towns[i + 1]
    dist = min(abs(x1 - x2), abs(y1 - y2))
    roads.append([dist, num1, num2])
roads.sort()
ans = 0
tree = UnionFind(N)
for road in roads:
    d, s, t = road
    if not tree.same(s, t):
        ans += d
        tree.union(s, t)

print(ans)

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

int main(){
  int N;
  cin >> N;
  int count=0;
  
  for(int i=1; i<=N; i++){
    if(i<=9){
      count++;
    }
    else if(100<=i&&i<=999){
      count++;
    }
    else if(10000<=i&&i<=99999){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())

# bit = 1, 2, 4, 8, 16, ...
def count1(n, bit):
    r = (n+1) % (2*bit)
    cnt = (n+1-r) // 2
    if r <= bit:
        return cnt
    else:
        return cnt + r - bit

res = ''
bits = [2**i for i in range(40)][::-1]
for bit in bits:
    diff = count1(B, bit) - count1(A-1, bit)
    if diff%2 == 0:
        res += '0'
    else:
        res += '1'
print(int(res, 2))

Measured memory_bytes: 3064
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        int ans = Math.min(A*N, B);

        System.out.println(ans);

    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    string s, t;
    cin >> s >> t;
    map<char, char> mp1, mp2;
    REP(i, s.size()){
        if(mp1[s[i]]){
            if(mp1[s[i]] != t[i]){
                cout << "No" << endl;
                return 0;
            }
        }
        if(mp2[t[i]]){
            if(mp2[t[i]] != s[i]){
                cout << "No" << endl;
                return 0;
            }
        }
        mp1[s[i]] = t[i];
        mp2[t[i]] = s[i];
    }
    cout <<"Yes" << endl;
}

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


int main(){
  int n; cin >> n;
  vector<int> ans(n + 1, 0);
  for(int x = 1; x * x <= n; x++){
    for(int y = 1; y * y <= n; y++){
      for(int z = 1; ;z++){
        int f = x*x + y*y + z*z + x*y + y*z + z*x;
        if(f > n) break;
        ans[f]++;
      }
    }
  }
  rep(i, n) cout << ans[i+1] << endl;
  return 0;
}


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

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

  int N;
  cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; i++) cin >> V.at(i);

  int ans = 0;
  
  for (int i = 0; i < N; i++) {
    int C;
    cin >> C;
    ans += max(V.at(i) - C, 0);
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 string s[1010];
vector<int> g[1010];

void dfs(int x,int d){
  for(int i=0;i<d;i++)cout<<".";
  cout<<s[x]<<endl;
  for(int i=0;i<g[x].size();i++){
    dfs(g[x][i],d+1);
  }
}

int main(){
  int n;
  cin>>n;
  int k;
  for(int i=1;i<=n;i++){
    cin>>k>>s[i];
    g[k].push_back(i);
  }
  dfs(1,0);
  return 0;
}



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

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;


int main() {

    int n, k;
    ll l, r;
    cin >> n >> k >> l >> r;

    ll a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    int left = n / 2;
    int right = n - left;

    vector<ll> va[left + 1], vb[right + 1];

    for (int i = 0; i < 1 << left; i++) {
        ll sum = 0;
        int popcnt = 0;
        for (int j = 0; j < left; j++) {
            if (i >> j & 1) sum += a[j], popcnt++;
        }
        va[popcnt].push_back(sum);
    }

    for (int i = 0; i < 1 << right; i++) {
        ll sum = 0;
        int popcnt = 0;
        for (int j = 0; j < right; j++) {
            if (i >> j & 1) sum += a[left + j], popcnt++;
        }
        vb[popcnt].push_back(sum);
    }

    for (int i = 0; i <= left; i++) sort(va[i].begin(), va[i].end());
    for (int i = 0; i <= right; i++) sort(vb[i].begin(), vb[i].end());

    ll ans = 0;
    for (int i = 0; i <= left; i++) {
        if (i + right < k) continue;
        if (i > k) break;

        for (int j = 0; j < va[i].size(); j++) {
            ll tmp = va[i][j];
            ans += max(0ll, (ll) (upper_bound(vb[k - i].begin(), vb[k - i].end(), r - tmp) -
                                  lower_bound(vb[k - i].begin(), vb[k - i].end(), l - tmp)));
        }
    }

    cout << ans << endl;
}





Measured memory_bytes: 23412
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);
		long n =sc.nextLong();
		long a[] =new long[5];
		for(int i=0;i<5;i++) {
			a[i]=sc.nextLong();
		}
		Arrays.sort(a);
		
		
		
		System.out.println(4+(n+a[0]-1)/a[0]);

}
}





Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m[1006],l[1006],ans;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> m[i] >> l[i];
    }
    for(int i=0;i<n;i++){
        ans=m[i]%l[i];
        if(ans==0)ans=l[i];
        cout << ans << endl;
        ans=0;
    }

return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
bool isprime(int x)
{
	for(int i=2;i<=sqrt(x);i++)
		if(x%i==0)
			return false;
	return true;
}
int main()
{
	int n,js=0,i=2;
	cin>>n;
	while(js<n)
	{
		if(isprime(i)&&i%5==1)
			cout<<i<<' ',
			js++;
		i++;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
 
using namespace std;
const long long INF = (long long) (1e18)+1;
 
int main() {
  int n;
  cin >> n;
  while (n!=0) {
    int temp = n%10;
    if (temp == 7) {
      cout << "Yes" << endl;
      return 0;
    } 
    n/=10;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define mod 1000000007
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    vector<int> a[n + 1];
    for (int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        a[u].push_back(v);
        a[v].push_back(u);
    }
    vector<int> vis(n + 1);
    vector<int> sign(n + 1);
    queue<int> q;
    q.push(1);
    vis[1] = 1;
    int k = 1;
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        for (int x : a[u])
        {
            if (vis[x] == 0)
            {
                vis[x] = 1;
                sign[x] = u;
                q.push(x);
                k++;
            }
        }
    }
    if (k < n)
    {
        cout << "No";
    }
    else
    {
        cout << "Yes\n";
        for (int i = 2; i <= n; i++)
        {
            cout << sign[i] << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 10712
import sys
sys.setrecursionlimit(10**9)
n = int(input())
pow6s = [6, 36, 216, 1296, 7776, 46656]
pow9s = [9, 81, 729, 6561, 59049]
dp = [-1] * (n+1)
def dfs(n):
    if n == 0:
        return 0
    if dp[n] != -1:
        return dp[n]
    mincount = n + 1
    for p6 in pow6s:
        if n-p6 >= 0:
            mincount = min(mincount, dfs(n-p6) + 1)
    for p9 in pow9s:
        if n-p9 >= 0:
            mincount = min(mincount, dfs(n-p9) + 1)
    
    dp[n] = min(mincount, dfs(n-1) + 1)
    return dp[n]

print(dfs(n))


Measured memory_bytes: 19548
#include<stdio.h>
#include<algorithm>
using namespace std;
const int MAX=100010;
int p[MAX],d1[MAX],d2[MAX],sum,n;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&p[i]);
    for(int i=0;i<=n;i++) d1[i]=abs(p[i+1]-p[i]),sum+=d1[i];
    for(int i=0;i<n;i++) d2[i]=abs(p[i+2]-p[i]);
    for(int i=0;i<n;i++){
        //printf("%d %d %d\n",sum,d1[i]+d1[i+1],d2[i]);
        printf("%d\n",sum-d1[i]-d1[i+1]+d2[i]);
    }
}


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

using namespace std;

int main(void) {
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int k;
  cin >> k;

  cout << a[k - 1] << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int Alice = 0;
  int Bob = 0;
  
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0)
      Alice += a.at(i);
    else
      Bob += a.at(i);
  }
  cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0100&lang=ja
=begin
---SAMPLE INPUT---
4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
2
1001 100 3
1005 1000 100
2
1001 1000000 0
1005 1 100000
0
=end

emp_list = {}

loop do
  data_line_count = gets.strip.to_i
  break if data_line_count == 0

  (1..data_line_count).each do
    emp_no, price, amount = gets.strip.split(' ')
    emp_list[emp_no.to_s] ||= 0
    emp_list[emp_no.to_s] += price.to_i * amount.to_i
  end

  emp_list.select {|_, value|
    value >= 1_000_000
  }.tap {|output_list|
    if output_list.empty?
      puts 'NA'
    else
      output_list.each_key {|key| puts key }
    end
  }
  emp_list.clear
end



Measured memory_bytes: 6924
import java.io.*;
class Main{
public static void main(String[] args)throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str=br.readLine();
int n=Integer.parseInt(str);
int[][] tramp=new int[4][13];
if(n==52)  return;
for(int i=0; i<n; i++){
String str2=br.readLine();
String[] card=str2.split(" ");
int c=Integer.parseInt(card[1])-1;
switch(card[0]){
case "S": tramp[0][c]=1; break;
case "H": tramp[1][c]=1; break;
case "C": tramp[2][c]=1; break;
case "D": tramp[3][c]=1; break;
default:  break;
}
}
for(int j=0; j<4; j++){
for(int k=0; k<13; k++){
if(tramp[j][k]==0){
switch(j){
case 0: System.out.println("S "+(k+1)); break;
case 1: System.out.println("H "+(k+1)); break; 
case 2: System.out.println("C "+(k+1)); break;
case 3: System.out.println("D "+(k+1)); break;
default: break;
}
}
}
}
br.close();
}
}

Measured memory_bytes: 24276
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


fn main() {
    let number_of_slime: i32 = read();
    let mut slime_color: String = read();
    let mut vector = Vec::new();

    for ch in slime_color.as_str().chars()
    {
        vector.push(ch);
    }
    vector.dedup();

    println!("{}", vector.len());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string b;
    cin >> b;
    
    if(b == "A") {
        cout << "T" << endl;
    }
    if(b == "T") {
        cout << "A" << endl;
    }
    if(b == "C") {
        cout << "G" << endl;
    }
    if(b == "G") {
        cout << "C" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdint.h>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int k = n / 2;
    if(k * 2 != n){
        cout<<"No"<<endl;
    }else{
        for(int i = 0; i < k; i++){
            if(s[i] != s[i + k]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
    sc.Split(bufio.ScanWords)
    N := nextInt()
	rate_list := []int{}

	for i := 0; i < N; i++ {
		rate_list = append(rate_list,nextInt())
	}

	sort.Ints(rate_list)
	val := 400
	num := rate_list[0] / val
	min := 1
	max := 0

	for i := 1; i < N; i++ {
		rate := rate_list[i] / val
		if rate >= 8 {
			max++
		}else if num < rate {
			min++
		}
		num = rate
	}
	fmt.Println(min, max+min)
}

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

bool isKomoji(char a){
  if(a >= 'a' and a <= 'z'){
    return true;
  }
  else return false;
}

int main(){
  int size;
  string s, ans = "";
  cin >> s;
  size = s.size();
  if(s.at(0) != 'A'){
    ans = "WA";
  }
  else{
    int cs = 0;
    for(int i = 2;i < size - 1;i++){
      if(s.at(i) == 'C'){
        cs++;
      }
      else if(!isKomoji(s.at(i))){
        ans = "WA";
      }
    }
    if(cs != 1){
      ans = "WA";
    }
    else if(!isKomoji(s.at(1)) or !isKomoji(s.at(size - 1))){
      ans = "WA";
    }
  }
  if(ans == "WA") cout << ans << endl;
  else cout << "AC" << endl;
  return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	int n; cin>>n;
	string s; cin>>s;
	vector<int> process(n, 0);
	forne(i, n-1){
		bitset<20> b(i);
		process[i] = process[i%(__builtin_popcount(i))] + 1;
	}

	ll cntr = 0;
	forn(i, n) cntr += s[i]=='1';
	trace(cntr);
	ll cntr1 = cntr + 1;
	ll cntr2 = cntr - 1;
	ll rep1 = 0;
	forn(i, n) if(s[i]=='1'){ rep1 += modpow(2, n-i-1, cntr+1); rep1 %= cntr+1;}
	ll rep2 = 0;
	forn(i, n) if(s[i]=='1'&&cntr2!=0){ rep2 += modpow(2, n-i-1, cntr-1); rep2 %= cntr-1;}
	trace(rep1, rep2);
	forn(i, n){
		if(s[i]=='1'){
			if(cntr2==0)
				cout<<0<<endl;
			else{
				int crr = modpow(2, n-i-1, cntr2);
				cout<<1+process[((rep2-crr)%cntr2+cntr2)%cntr2]<<endl;
			}
		}
		else{
			int crr = modpow(2, n-i-1, cntr1);
			cout<<1+process[((rep1+crr)%cntr1+cntr1)%cntr1]<<endl;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen(".inp.txt", "r", stdin);
    	freopen(".out.txt", "w", stdout);
    	freopen(".err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

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



int main(void){
	
    int p, q, r;
    cin >> p >> q >> r;
    int sum;

    if(p>q){
        if(p>r){
            sum = q + r;
        }else{
            sum = p + q;
        }
    }else{
        if(q>r){
            sum = p + r;
        }else{
            sum = p + q;
        }
    }

    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let nk = lines[0].split(/\s/).map((v) => v - 0);
    let N = nk[0] - 0, K = nk[1] - 0;
    let H = lines[1].split(/\s/).map((v) => v - 0);
    let dp = new Array(N+K).fill(Number.MAX_SAFE_INTEGER);
    dp[0] = 0;
    for (let n = 0; n <= N; n++) {
        for (let m = 1; m <= K; m++) {
            dp[n + m] = Math.min(dp[n + m], dp[n] + Math.abs(H[n] - H[n + m]));
        }
    }
    console.log(dp[N-1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 26572
def count(pre, a, x):
  cnt = 0
  val = 0
  for i in reversed(range(n)):
    if 2*a[i] < x:
      break
    lo, hi = 0, n-1
    while lo < hi:
      mid = (lo + hi)//2
      if a[mid] + a[i] < x:
        lo = mid + 1
      else:
        hi = mid
    cnt += 1 + 2*(i - lo)
    val += 2*(i-lo+1)*a[i] + (pre[i] - pre[lo])*2
  return cnt, val

n, m = map(int, input().split())
a = list(sorted(map(int, input().split())))
pre = [0]
for i in range(n):
  pre.append(a[i] + pre[-1])
lo, hi = 0, 2*a[-1]
while lo < hi:
  mid = (lo + hi + 1) // 2
  cnt, _ = count(pre, a, mid)
  if cnt < m:
    hi = mid - 1
  else:
    lo = mid
cnt, val = count(pre, a, lo)
print(val - (cnt - m)*lo)

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

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

    int a[100]={},index=0;
    for(int i=min(A,B);i>=1;i--){
        if(A%i==0&&B%i==0) a[++index]=i;
    }
    cout<<a[K]<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = sc.nextInt();
		if(n<=2*c) {
			System.out.println(0);
		}else {
			System.out.println(n-2*c);
		}
	}
}

Measured memory_bytes: 23252
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const S = args[0][0]
	const T = args[1][0]
	let cnt = 0
	if (S[0] === T[0]) cnt++
	if (S[1] === T[1]) cnt++
	if (S[2] === T[2]) cnt++
	console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 22080
#include<stdio.h>
#include<assert.h>
#include<math.h>
#include<string.h>
int stack[110];
int top = 0;

void push(int v){ stack[top] = v; top++;}
int  pop(){ top--;return stack[top]; }
int getInt(char *s)
{
  int i,ret=0;
  int size = strlen(s);
  for(i=0;i<size;i++)
    {
      ret += (s[i]-'0')*pow(10,size-i-1);
    }
  return ret;
}

int main()
{
  char s[1000];
  while(scanf("%s",s)!=EOF)
    {
      if('0' <= s[0] && s[0] <= '9')
	{
	  int v = getInt(s);
	  push(v);
	  continue;
	}
	  int a,b;
	  b = pop();
	  a = pop();
	  if(s[0] == '+')
	      push(a+b);
	  else if(s[0] == '-')
	    push(a-b);
	  else if(s[0] == '*')
	    push(a*b);
	  else{}
	    
    }
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2132
n = int(input())
s = input()

ans = 0
for i in range(10):
    if str(i) in s:
        index_i = s.index(str(i))
        for j in range(10):
            if str(j) in s[index_i + 1:]:
                index_j = s[index_i + 1:].index(str(j)) + index_i + 1
                for k in range(10):
                    if str(k) in s[index_j + 1:]:
                        ans += 1
print(ans)

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i += 2) {
        int tmp = 0;
        for (int j = 1; j <= n; ++j) {
            if (i % j == 0) tmp++;
        }
        if (tmp == 8) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N      = scanner.nextInt();
		int total  = 0;
		int totalA = 0;
		int totalB = 0;
		int temp   = 0;
		int answer = 101;
		int[]W     = new int[N];
		
		//合計を取得
		for(int i = 0; i < N; i ++){
			
			W[i] = scanner.nextInt();
			total = total + W[i];
		}
		
		//前のグループと後ろのグループの差を確認
		for(int i = 0; i < N; i ++){
			
			totalA = totalA + W[i];
			totalB = total - totalA;
			temp   = totalA - totalB;
			
			//差が最小になったとき
			if(temp < Math.abs(answer)){
				
				answer = temp;
			}
		}
		System.out.println(Math.abs(answer));
	}

}

Measured memory_bytes: 23764
n = int(input())
D = {}
ans = 0
for i in range(n):
    s = str(input())
    d = [0]*26
    for j in range(len(s)):
        c = ord(s[j])-ord('a')
        d[c] += 1
    d = tuple(d)
    if d in D:
        ans += D[d]
        D[d] += 1
    else:
        D[d] = 1
print(ans)


Measured memory_bytes: 124760
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b/a) <<   endl;
    

  
    return 0;
}



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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[200000];
bool B[200000];

bool f(int x) {
  for (int i=0; i<2*N-1; i++) B[i] = A[i] >= x;
  int m = N-1;
  bool v = B[m];
  for (int i=1; i<N; i++) {
    if (B[m-i] == (v^(i%2)) && B[m+i] == (v^(i%2))) {}
    else return v^(i%2)^true;
  }
  return v^((N-1)%2);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, 2*N-1) cin >> A[i];
  int lo = 0, hi = 2*N;
  while (hi - lo > 1) {
    int mid = (lo + hi) / 2;
    if (f(mid)) lo = mid;
    else hi = mid;
  }
  cout << lo << "\n";
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    ll n, p;
    cin >> n >> p;
    vector<int> a(n);
    for (int& i : a) cin >> i;
    ll c0 = 0, c1 = 0;
    for (int i : a) ++(i & 1 ? c1 : c0);
    c0 = 1ll << c0;
    c1 = (c1 > 0 ? (1ll << (c1 - 1)) : 0);
    cout << c0 * max(c1, p ? c1 : 1ll) << endl;
    cerr << "c0,c1:" << c0 << "," << c1 << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

arr = []
for i in range(101):
    arr.append(0)
    
maxi = 0

for e in sys.stdin:
    arr[int(e)] += 1
    maxi = max(maxi, arr[int(e)])
    
for i in range(101):
    if arr[i] == maxi:
        print(i)
    


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  int n,m;
  cin>>n>>m;
  vi a(m);
  ll sum =0;
  rep(i,m){
    cin>>a[i];
    sum+=a[i];
  }
  if(n<sum){
    cout<<-1<<endl;
    return 0;
  }
  cout<<n-sum<<endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    cin >> n;
    vector<int> t(n);
    int sum = 0;
    rep(i, n){
        cin >> t[i];
        sum += t[i];
    }

    int m;
    cin >> m;
    rep(i, m){
        int p, x;
        cin >> p >> x;

        int ans = sum - t[p-1] + x;
        cout << ans << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

long long time_data[200000] = {};

int main()
{
	long long n, t;
	long long time_lag;
	long long total_time = 0;
	scanf("%lld %lld", &n, &t);
	for (long long i = 0; i < n; i++)
	{
		scanf("%lld", &time_data[i]);
	}
	for (long long i = 0; i < n-1; i++)
	{
		time_lag = 0;
		time_lag = time_data[i + 1] - time_data[i];
		if (time_lag <= t)
		{
			total_time = total_time + time_lag;
		}
		else
		{
			total_time = total_time + t;
		}
	}
	total_time = total_time + t;

	printf("%lld", total_time);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;


int main(){
vector<int> v(26,0);
string s;cin>>s;
for(int i=0;i<s.length();i++)v[s[i]-'a']++;
for(int i=0;i<26;i++){
    if(v[i]%2){cout<<"No";return 0;}
}

cout<<"Yes";
}

Measured memory_bytes: 256
import java.util.*;

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

        int K = sc.nextInt();
        int cnt = 0;

        for (int a = 1; a <= K; a++) {
            for (int b = 1; b <= K; b++) {
                for (int c = 1; c <= K; c++) {
                    cnt += gcd(gcd(a, b), c);
                }
            }
        }

        System.out.println(cnt);
    }

    static int gcd(int m, int n) {
        if (m < n) return gcd(n, m);
        if (n == 0) return m;
        return gcd(n, m % n);
    }
}


Measured memory_bytes: 35932
#include <iostream>
#include<set>
#include<vector>
#include<string>
using namespace std;
const int mod=1000000007;
int add(int a, int b)
{
	int c=a+b;
	if(c>=mod)c-=mod;
	return c;
}
int dif(int a, int b)
{
	int c=a-b;
	if(c<0)c+=mod;
	return c;
}
int mlt(int a, int b)
{
	long long c=a*1LL*b;
	return c%mod;
}
int bp(int a, int b)
{
	if(b==0)return 1;
	if(b%2==0)
	{
		int val=bp(a, b/2);
		return mlt(val, val);
	}
	if(b%2==1)
	{
		int val=bp(a, b-1);
		return mlt(val, a);
	}
}
int inv(int a)
{
	return bp(a, mod-2);
}
void outp(vector<vector<int>>&v)
{
	for(int i=0; i<v.size(); i++)
	{
		for(int j=0; j<v[i].size(); j++)cout<<v[i][j]<<' ';
		cout<<endl;
	}
	cout<<endl;
}
bool tst(string s, int k, int a, int b)
{
	int cura=a, curb=b;
	for(int j=0; j<s.length(); j++)
	{
		if(s[j]=='0')
		{
			if(curb==k)
				curb--;
			else curb++;
			cura++;
			if(cura>curb)return false;
			if(cura<0)return false;
		}
		if(s[j]=='1')
		{
			curb--;
			cura--;
			if(cura<0)cura+=2;
			if(cura>curb)return false;
		}
		if(s[j]=='?')
		{
			cura--;
			if(cura<0)cura=1;
			curb++;
			if(curb>k)curb-=2;
			if(cura>curb)return false;
		}
	}
	return true;
}
bool check(string s, int k)
{
	if(k%2==0)
	{
		if(tst(s, k, 0, k))return true;
		if(tst(s, k, 1, k-1))return true;
		return false;
	}
	else
	{
		if(tst(s, k, 0, k-1))return true;
		if(tst(s, k, 1, k))return true;
		return false;
	}
}
int main()
{
	string s;
	cin>>s;
	int n=s.length();
	vector<int>l0(n+1), l1(n+1);
	int maxval=0;
	for(int i=1; i<=n; i++)
	{
		if(s[i-1]=='0')
		{
			l0[i]=l0[i-1]+1;
		}
		else{
			l0[i]=max(l0[i-1]-1, 0);
		}
		if(s[i-1]=='1')
		{
			l1[i]=l1[i-1]+1;
		}
		else{
			l1[i]=max(l1[i-1]-1, 0);
		}
		maxval=max(maxval, l0[i]);
		maxval=max(maxval, l1[i]);
	}
	if(check(s, maxval))cout<<max(maxval,1)<<endl;
	else cout<<maxval+1<<endl;
}

Measured memory_bytes: 14268
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<deque>
#include<set>
#define inf 1e18
#define eps 1e-6
#define N 4020
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
ll a[N],minn[N][N];
ll ans=inf;
ll n,x;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),x=read();
	for(register int i=1;i<=n;i++)a[i]=a[i+n]=read();
	for(register int i=1;i<=(n<<1);i++)
	{
		minn[i][i]=a[i];
		for(register int j=i+1;j<=(n<<1);j++)minn[i][j]=min(minn[i][j-1],a[j]);
	}
	for(register int k=0;k<n;k++)
	{
		ll sum=0;
		for(register int i=n+1;i<=2*n;i++)sum+=minn[i-k][i];
		sum+=k*x;ans=min(ans,sum);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 81312
/**********************************************************************************************
******************************AUTHOR:**********************************************************
****************************ASHISH RANJAN******************************************************
***********************************************************************************************/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<chrono>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
using namespace std::chrono;
/*
auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;
*/
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
const int M = 1e9 + 7;
#define fr(i,n) for(int i=0;i<n;i++)
#define frs(i,a,b) for(int i = a;i<b;i++)
#define meme(a,b) memset(a,b,sizeof(a)); //works only for 0 and -1
ll mod(long long x){
 return (x%M+M)%M;
}
ll add(long long a,long long  b){
return mod(mod(a)+mod(b));
}
ll mul(long long a,long long b){
return mod(mod(a)*mod(b));
}
ll minu(long long a,long long b){
return mod(mod(a)-mod(b));
}
ll modPow(ll a,ll b){
if(b==0)return 1LL;
if(b==1)return a%M;
ll res= 1;
while(b){
if(b%2==1)
res = mul(res,a);
a = mul(a,a);
b/=2;
}
return res;
}
void solve(){
ll n;
cin>>n;
ll ans = minu(add(modPow(10LL,n),modPow(8LL,n)),mul(2LL,modPow(9LL,n)));
cout<<ans;
}
int main(){
  fast();
//  int t;cin>>t;
//  while(t--){
    solve();
    cout<<endl;
//  }
 return 0;
}


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

int dummy_prime(int n,int i){return i>1 ? n%i ? dummy_prime(n,i-1) : 0 : 1;}
int isprime(int n){return n>1 ? dummy_prime(n,(int)sqrt(n)) : 0;} 

int main(){
	int n;
	while(cin >> n && n){
		while(n>4){
			if(isprime(n) && isprime(n-2)){
				cout << n-2 << " " << n << endl;
				break;
			}
			n--;
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

int main(){
    int a, B;
    cin >> a >> B;
    if(a <= 5){
        cout << 0 << endl;
    }
    else if(a <= 12){
        cout << B/2 << endl;
    }
    else{
        cout << B << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

def main(lines):
  N, M = np.fromstring(lines[0], dtype=int, sep=" ")
  a = np.fromstring(''.join(lines[1:]), dtype=int, sep=" ").reshape((2, M), order='F')
  
  lmax = a[0].max()
  rmin = a[1].min()
  if lmax > rmin:
    print(0)
  else:
    print(rmin - lmax + 1)

lines = sys.stdin.readlines()
main(lines)

Measured memory_bytes: 22832
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  long long A[100000];
  pair<int,long long> p[100000];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A,A+N);
  for(int i=0;i<M;i++){
    int B;
    long long C;
    cin>>B>>C;
    p[i]=make_pair(C,B);
  }
  sort(p,p+M);
  int j=0;
  int k=p[M-1].second;
  long long answer=0;
  for(int i=0;i<N;i++){
    if(j<M){
    if(p[M-j-1].first>A[i]){
      A[i]=p[M-j-1].first;
      k--;
      if(k==0){
        j++;
        k=p[M-j-1].second;
      }
    }
    }
    answer+=A[i];
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 2560