akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-4;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int n, m;
vector<int> G[1 << 10];
bool used[1 << 10][2];
int main() {
	while (cin >> n >> m, n) {
		rep(i, n) {
			G[i].clear();
			rep(j, 2) {
				used[i][j] = false;
			}
		}
		rep(i, m) {
			int u, v; cin >> u >> v; u--; v--;
			G[u].push_back(v);
			G[v].push_back(u);
		}
		queue<P> q; q.push({ 0,0 }); used[0][0] = true;
		while (!q.empty()) {
			P x = q.front(); q.pop();
			int id = x.first; int c = x.second;
			rep(j, (int)G[id].size()) {
				int to = G[id][j];
				if (!used[to][c ^ 1]) {
					used[to][c ^ 1] = true;
					q.push({ to,c ^ 1 });
				}
			}
		}
		int c = 0;
		rep(i, n) {
			if (used[i][0]) {
				c++;
			}
		}
		vector<int> ans;
		if (c != n && c % 2 == 0) {
			ans.push_back(c / 2);
		}
		if (c != n && (n - c) % 2 == 0&&n!=2*c) {
			ans.push_back((n - c) / 2);
		}
		sort(ans.begin(), ans.end());
		cout << ans.size() << endl;
		rep(i, (int)ans.size()) {
			cout << ans[i] << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3232
#include <stdio.h>
#include <string.h>

#define ARRAY_SIZE 10
int main()
{
	char inputN[ARRAY_SIZE];

	scanf("%s", &inputN);

	if (inputN[2] == inputN[3] && inputN[4] == inputN[5])
	{
		printf("Yes \n");
	}
	else
	{
		printf("No \n");
	}

	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a+b > c+d){
  cout << "Left" << endl;
  }
  else if (a+b==c+d){
  cout << "Balanced" << endl;
  }
  else{
  cout << "Right" << endl; 
  }
}



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

using namespace std;

int main(){

    int a,b;
    scanf("%d", &a);
    scanf("%d", &b);
    if(a < 10 && b < 10){
        printf("%d\n", a * b);
    }else{
        printf("-1");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
using namespace std;
char m[105][105];
int main()
{
    int h, w;
    while(~scanf("%d%d", &h, &w))
    {
        for(int i = 0; i < h; i++)
            for(int j = 0; j < w; j++)
                cin >> m[i][j];
        bool H[105], W[105];
        memset(H, 0, sizeof(H));
        memset(W, 0, sizeof(W));
        for(int i = 0; i < h; i++)
        {
            bool f = 1;
            for(int j = 0; j < w && f; j++)
            {
                if(m[i][j] == '#')
                    f = 0;
            }
            H[i] = f;
        }
        for(int j = 0; j < w; j++)
        {
            bool f = 1;
            for(int i = 0; i < h; i++)
            {
                if(m[i][j] == '#')
                    f = 0;
            }
            W[j] = f;
        }
        for(int i = 0; i < h; i++)
        {
            if(H[i])
                continue;
            for(int j = 0; j < w; j++)
            {
                if(W[j])
                    continue;
                cout<<m[i][j];
            }
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long k = scanner.nextLong();
        long i = n%k;
        if (i<=k-i){
            System.out.println(i);
        }else{
            System.out.println(k-i);
        }
    }

}

Measured memory_bytes: 35584
from fractions import gcd
a = list(map(int,input().split()))

def fun(x,c,d):
    return x - div(x,c) - div(x,d) + div(x,c*d//gcd(c,d))

def div(a,b):
    return a // b

print(fun(a[1],a[2],a[3])-fun(a[0]-1,a[2],a[3]))

Measured memory_bytes: 5048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;


class game{
public:
	int N, M;
	vector< vector<int> > Ss;
	vector<int> Ps;
	int ans = 0;

	void Input(){
		cin >> N >> M;
		int k;
		int s;
		for(int mi = 0; mi < M; mi++){
			cin >> k;
			vector<int> ls;
			for(int ki = 0 ; ki < k; ki++){
				cin >> s;
				ls.push_back(s-1);
			}
			Ss.push_back(ls);
		}

		int p;
		for(int ni = 0; ni < M; ni++){
			cin >> p;
			Ps.push_back(p);
		}
	}

	int TryS(int ni, vector<int> ls)
	{
		if (ni == N){
			int si;
			int sum;
			int flag = 1;
			for (int mi = 0; mi < M; mi++){
				sum = 0;
				for (int ssi = 0; ssi < Ss[mi].size(); ssi++){
					si = Ss[mi][ssi];
					sum += ls[si];
				}
				if (sum % 2 != Ps[mi]){
					flag = 0;
					break;
				}
			}
			if (flag) {
				ans++;
			}
			return 0;
		}

		vector<int> new_ls = ls;
		new_ls[ni] = 0;
		TryS(ni+1, new_ls);
		new_ls[ni] = 1;
		TryS(ni+1, new_ls);

		return 1;
	}

};


int main()
{

	game g;

	g.Input();
	g.TryS(0, vector<int>(g.N,0));

	printf("%d",g.ans);


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

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

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int x, t;
  int ans = 0;

  cin >> x >> t;
  // vi v(n);
  // REP(i, n) {
  //   cin >> v[i];
  // }

  cout << max(0ll, x - t) << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 256
#include <iostream>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    string s;
    string t;
    bool ans=true;
    cin >> s;
    cin >> t;
    if(s.size()+1!=t.size()){
        ans=false;
    }
    for(int i=0; i<s.size(); i++){
        if(s[i]!=t[i]){
            ans=false;
        }
    }

    if(ans==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
 
int main() {

    int n;
    cin>>n;
    vector <int> x(n);
    vector <int> l(n);
    rep(i,n)    cin>>x[i]>>l[i];

    vector <tuple<int,int>> p(n);
    rep(i,n)    p.at(i)=make_tuple(x[i],l[i]);
    sort(all(p));

    int ans=0;
    int memo=get<0>(p.at(0))+get<1>(p.at(0));
    rep(i,n-1) {
        if(memo>get<0>(p.at(i+1))-get<1>(p.at(i+1))) {
            ans++;
            memo=min(memo,get<0>(p.at(i+1))+get<1>(p.at(i+1)));
        }
        else {
            memo=get<0>(p.at(i+1))+get<1>(p.at(i+1));
        }
    }

    ans=n-ans;
    cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int selectionSort(int A[], int N){
    int i, j, t, sw =0, minj;
    for(i=0;i<N-1;i++){
        minj = i;
        for(j=i;j<N;j++){
            if(A[j]<A[minj]) minj = j;
        }
        t=A[i]; A[i]=A[minj]; A[minj]=t;
        if(i!=minj) sw++;
    }
    return sw;
}

int main(void) {
    int A[100], N, i, sw;

    scanf("%d", &N);
    for(i=0;i<N;i++) scanf("%d", &A[i]);

    sw = selectionSort(A,N);

    for(i=0;i<N;i++){
        if(i>0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", sw);

    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(x) cout << x << endl
const int INF = 1e+8+7;
ll n,m;
int a,b,c = 1;
string s,t;
int d[100],dp1[500][500],dp2[500][500];
vi vec;

int main(){
  bitset<3> bt;
  cin >> bt;
  print(bt.count());
  return 0;
}


Measured memory_bytes: 256
N, Ma, Mb = map(int,input().split())
C = [map(int,input().split()) for i in range(N)]
INF = 40000
dp = [[[INF]*401 for i in range(401)] for i in range(N+1)]
dp[0][0][0] = 0
for i in range(1,N+1):
  a,b,c = C[i-1]
  for j in range(401):
      for k in range(401):
        dp[i][j][k] = dp[i-1][j][k]
        if j >= a and k >= b and dp[i-1][j-a][k-b] != INF:
            dp[i][j][k] = min(dp[i][j][k],dp[i-1][j-a][k-b]+c)
ans = INF
Ma2,Mb2 = Ma,Mb
while max(Ma2,Mb2) < 401:
  ans = min(ans,dp[-1][Ma2][Mb2])
  Ma2 += Ma
  Mb2 += Mb    

print(ans if ans != INF else -1)


Measured memory_bytes: 96988
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vi >
#define vvl vector< vl >
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vpii vector< pii >
#define vpll vector< pll >
#define rep(i, a, b) for(int i = a; i < b; i++) 
#define repll(i, a, b) for(ll i = a; i < b; i++) 
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define F first
#define S second
#define string_to_int(s) stoi(s)
#define string_to_ll(s) stoll(s)
#define int_to_string(n) to_string(n)
#define ll_to_string(n) to_string(n)
#define char_to_int(c) c-'0'
#define int_to_char(c) c+'0'
int main() {
	ll k, x;
	cin >> k >> x;
	if(x-k-1 < -2000000) {
		for(ll i = -2000000; i <= x; i++) {
			cout << i << " ";
		}	
		if(x+k-1 > 2000000) {
			for(ll j = x+1; j <= 2000000; j++)
				cout << j << " ";
		}
		else {
			for(ll j = x+1; j <= x+k-1; j++) 
				cout << j << " ";
		}
	}
	else {
		for(ll i = x-k+1; i <= x; i++) {
			cout << i << " ";
		}
		if(x+k-1 > 2000000) {
			for(ll j = x+1; j <= 2000000; j++)
				cout << j << " ";
		}
		else {
			for(ll j = x+1; j <= x+k-1; j++) 
				cout << j << " ";
		}
	}
	
	cout << "\n";


	return 0;
}


Measured memory_bytes: 256
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()

cnt = 0
for i in range(1,n+1):
	if len(str(i))%2 != 0:
		cnt += 1
print(cnt)

Measured memory_bytes: 9036
#include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>
#include<algorithm>
#include<math.h>
#include<queue>
#include <forward_list>

#define mod 1000000007

using namespace std;

int main() {

	string S;

	cin >> S;

	int before;

	before = S[0];

	for (int i = 1; i < 4; i++) {
		if (before == S[i]) {
			cout << "Bad" << endl;
			return 0;
		}
		else
		{
			before = S[i];
		}
	}

	cout << "Good" << endl;

}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

ll dp[405][405];

void solve(){
    int n;
    cin>>n;
    vector<ll>a(n);
    vector<ll>sum(n+5);
    rep(i,n){
        cin>>a[i];
        sum[i+1]=sum[i]+a[i];
    }
    rep(i,405)rep(j,405){
        if(j==i+1)continue;
        dp[i][j]=INF;
    }
    for(int i=n-1;i>=0;--i){//[i,j)のスライムをまとめる最小コスト
        for(int j=i+1;j<=n;++j){
            for(int k=i+1;k<j;++k){//[i,j)で区切る場所を全部試す
                chmin(dp[i][j],dp[i][k]+dp[k][j]+sum[j]-sum[i]);
            }
        }
    }
    cout<<dp[0][n]<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int,int>;
const int Max_A = 1e6;
const int INF = 1e8;

bool prime[Max_A];

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	vector<int> p;
	rep(i,Max_A) prime[i]=true;
	for(int i=2; i*i<=Max_A; i++){
		if(prime[i]){
			p.emplace_back(i);
			for(int j=2; j*i<=Max_A; j++) prime[j*i]=false;
		}
	}
	map<int,int> mp;
	rep(i,N){
		int a=A[i];
		rep(j,p.size()){
			if(a%p[j]==0) mp[p[j]]++;
			while(a%p[j]==0) a/=p[j];
		}
		if(a!=1) mp[a]++;
	}
	bool pairwise=true, setwise=true;
	for(auto itr:mp){
		int num=itr.second;
		if(num>=2) pairwise=false;
		if(num==N) setwise=false;
	}
	rep(i,N) if(A[i]==1) setwise=true;
	if(pairwise) cout << "pairwise coprime" << endl;
	else if(setwise) cout << "setwise coprime" << endl;
	else cout << "not coprime" << endl;

	return 0;
}

Measured memory_bytes: 11432
import numpy as np
N = int(input())
h = list(map(int, input().split()))
dp = [9999] * N
dp[0] = 0
for i in range(1,N):
  if i<2:
    dp[i] = dp[i-1] + np.abs(h[i] - h[i-1])
  else:
    min1 = dp[i-2] + np.abs(h[i] - h[i-2])
    min2 = dp[i-1] + np.abs(h[i] - h[i-1])
    dp[i] = min(min1, min2)
print(dp[N-1])
  

Measured memory_bytes: 22728
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstdlib>
#include <typeinfo>

using namespace std;

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


int i,j;

int main(void){
    
    string a,b,c;
    cin >> a >> b >> c;
    
    if(a.back()==b[0]&&b.back()==c[0])cout<<"YES";
    else cout<<"NO";
    
    
    return 0;
    
}


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

int main() {
  int N, K, min = 1;
  int A, B;
  cin >> N >> K;
  for ( int i = 0; i < N; i++ ) {
    A = min * 2;
    B = min + K;
    if( A <= B ) 
      min = A;
    else 
      min = B;
  }
  cout << min << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int N; cin >> N;
	vi A(N);
	rep(i, N) cin >> A[i];
	int sum = 0;
	rep(i, N) {
		sum += A[i];
	}
	int avg = sum / N;
	int res_1 = 0;
	int res_2 = 0;
	rep(i, N) {
		res_1 += pow((avg - A[i]), 2);
		res_2 += pow((avg + 1 - A[i]), 2);
	}
	cout << min(res_1, res_2) << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int r, d, x;
  cin >> r >> d >> x;

  int x200[11];
  x200[0] = x;
  for(int i = 1; i <= 10; i++){
    x200[i] = r * x200[i - 1] - d;
  }

  string buf;
  for(int i = 1; i <= 10; i++){
    buf += to_string(x200[i]) + "\n";
  }

  cout << buf;

  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<pair<string, ll>> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;
    string X;
    cin >> X;
    ll ans = 0;
    bool ok = false;
    rep(i, N) {
        string s = items[i].first;
        ll t = items[i].second;
        if (ok) ans += t;
        if (s == X) {
            ok = true;
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[222];
int main()
{
    int n;
    scanf("%d",&n);
    n*=2;
    for(int i=0;i<n;++i)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<n;i+=2)
    {
        ans+=a[i];
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
int main(){
    string s;cin >> s;
    vector<int> length;
    char start='R';
    length.push_back(0);
    for(int i=0; i<s.size(); i++){
        if(s[i]==start){
            length.back()++;
        }
        else{
            start=s[i];
            length.push_back(1);
        }
    }
    vector<int> ans(s.size());
    int ss=0;
    for(int i=0; i<s.size()-1; i++){
        if(s[i]=='R'&&s[i+1]=='L'){
            if((length[ss]+length[ss+1])%2==0){
                ans[i]=ans[i+1]=(length[ss]+length[ss+1])/2;
                ss+=2;
            }
            else{
                if(length[ss]>length[ss+1]){
                    if((max(length[ss]-1,length[ss+1]-1))%2==1){
                        ans[i]=(length[ss]+length[ss+1])/2;
                        ans[i+1]=ans[i]+1;
                        ss+=2;
                    }
                    else{
                        ans[i]=(length[ss]+length[ss+1])/2+1;
                        ans[i+1]=ans[i]-1;
                        ss+=2;
                    }
                }
                else{
                    if((max(length[ss]-1,length[ss+1]-1))%2==1){
                        ans[i]=(length[ss]+length[ss+1])/2+1;
                        ans[i+1]=ans[i]-1;
                        ss+=2;
                    }
                    else{
                        ans[i]=(length[ss]+length[ss+1])/2;
                        ans[i+1]=ans[i]+1;
                        ss+=2; 
                    }
                }
            }
        }
    }
    for(int i=0; i<s.size(); i++) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1528
#require 'pp'

n, k = gets.split.map(&:to_i)
p_n = gets.split.map(&:to_i)

p_n2 = Array.new(0, n)
p_n.each_with_index do |x, i|
    p_n2[i] = (x * (x + 1) / 2) / x.to_f
end

x = p_n2[0, k]
max = x.inject {|sum, x| sum += x }
t = max
k.upto(n-1) do |i|
    t -= x.shift
    x.push(p_n2[i])
    t += p_n2[i]

    if t >= max
        max = t
    end    
end

puts max


Measured memory_bytes: 18124
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
a = LIST()

if max(a) - min(a) == 0 and (a[0] == N-1 or a[0] <= N//2):
	print("Yes")
elif max(a) - min(a) == 1 and a.count(min(a))+1 <= max(a) <= a.count(min(a)) + a.count(max(a))//2:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 21556
import sys

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, W = map(int, readline().split())
things = []
vsum = 0
for i in range(N):
    weight, value = map(int, readline().split())
    things.append((weight, value))
    vsum += value


INF = 1 << 62


def solve():
    dp = [INF] * (vsum + 1)
    w0, v0 = things[0]
    dp[0] = 0
    dp[v0] = w0
    for i in range(1, N):
        dn = list(dp)
        w, v = things[i]
        for j in range(vsum - v + 1):
            w2 = dp[j] + w
            if j + v <= vsum and w2 <= W:
                dn[j + v] = min(dn[j + v], w2)
        dp = dn
    for i in range(vsum, -1, -1):
        w = dp[i]
        if w <= W:
            return i
    return 0  # nothing is available


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 112064
n = int(input())
a = map(int, input().split())

ans = 0
isEven = True

while isEven:
  list_tmp = []
  for an in a:
    q, mod = divmod(an, 2)
    if mod ==0:
      list_tmp.append(q)
    else:
      isEven = False
      break;
  a = list_tmp
  ans += 1

print(ans - 1)


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

int main(int argc, char *argv[]) {
  int n;
  cin >> n;

  if (n == 1) {
    cout << "Hello World" << endl;
  } else {
    int a, b;
    cin >> a >> b;
    cout << a+b << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,odd=0,even=0;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%2==0)even++;
    else odd++;
  }
  if(odd%2==1)cout << "NO" << endl;
  else cout << "YES" << endl;
}

Measured memory_bytes: 3956
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;
typedef pair<ll,int> P;


int main(){
  int n,w[110],ans=10000;
  w[0]=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    int temp;
    cin>>temp;
    w[i]=w[i-1]+temp;
  }
  for(int i=1;i<n;i++){
    ans=min(ans,abs(w[n]-w[i]*2));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);


int main(){
    ll s;cin >> s;
    const ll mod = 1000000007;
    vec A(s+1);
    A[0] = 1;
    for(int i = 3;i <= s;i++){
        for(int j = i - 3;j >= 0;j--){
            A[i] += A[j];
            A[i] %= mod;
        }
        A[i] = (A[i] + mod)%mod;
    }
    cout << A[s] << endl;

}


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

int main(){
    long double N,M,D;
    cin >> N >> M >> D;
    if(D==0){
        cout << setprecision(10) << (1/N)*(M-1) << endl;
    }else{
        // 1組の隣り合った項の差がDである確率は
        // 2(N-D)通り / N*N通り
        cout << setprecision(10) << 2*(M-1)*(N-D)/N/N << endl;
    }
    return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define fill(a,val) memset(a,val,sizeof(a))
#define REP(i,a,b) for (auto i = a; i < b; i++)
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 998244353
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define pb push_back
#define SQ(a) (a)*(a)
#define M 315
using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    
    ll n;
    cin>>n;
    cout<<n + 3*n*(n-1) + n*(n-1)*(n-2)<<endl;
    return 0;
}




Measured memory_bytes: 3628
from collections import deque
n=int(input())
edges=[[] for _ in range(n)]
visited=[-1 for _ in range(n)]
for i in range(n-1):
  u,v,w=map(int,input().split())
  edges[u-1].append((v-1,w))
  edges[v-1].append((u-1,w))
def dfs(edges,visited):
  stack=deque([0])
  visited[0]=0
  while stack:
    x=stack.pop()
    for newx,w in edges[x]:
      if visited[newx]==-1:
        if w%2:
          visited[newx]=1-visited[x]
        else:
          visited[newx]=visited[x]
        stack.append(newx)
  return visited
for i in dfs(edges,visited):
  print(i)

Measured memory_bytes: 39144
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int dice1[6], dice2[6], tmp;
    for(int i=0; i<6; i++){
        scanf("%d", &dice1[i]);
    }
    for(int i=0; i<6; i++){
        scanf("%d", &dice2[i]);
    }
    for(int i=0; i<4; i++){
        for(int j=0; j<4; j++){
            for(int k=0; k<4; k++){
                if(dice1[0] == dice2[0] && dice1[1] == dice2[1] && dice1[2] == dice2[2] && dice1[3] == dice2[3] &&
                   dice1[4] == dice2[4] && dice1[5] == dice2[5]){
                    printf("Yes\n");
                    return 0;
                }
                tmp = dice2[0];
                dice2[0] = dice2[3];
                dice2[3] = dice2[5];
                dice2[5] = dice2[2];
                dice2[2] = tmp;
            }
            tmp = dice2[1];
            dice2[1] = dice2[2];
            dice2[2] = dice2[4];
            dice2[4] = dice2[3];
            dice2[3] = tmp;
        }
        tmp = dice2[0];
        dice2[0] = dice2[1];
        dice2[1] = dice2[5];
        dice2[5] = dice2[4];
        dice2[4] = tmp;
    }
    printf("No\n");
    return 0;
}



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

//const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

const int n = 26;
string s, ans;
set<char> st;
char a[200010];
char c;

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

    cin >> s;
    REP(i,sz(s)+1) a[i] = 'a';
    for (int i = sz(s) - 1; i >= 0; i--) {
            st.insert(s[i]);
            REP(j,n) {
                if (!st.count((char)('a' + j))) {
                    a[i] = (char)('a' + j);
                    break;
                }
            }
            if (sz(st) == n) {
                st.clear();
                a[i] = 'a';
            }
    }
//    REP(i,sz(s)) cout << a[i];
//    cout << endl;
    REP(i,sz(s)) {
        if (!sz(ans)) {
            ans = a[i];
            c = a[i];
            if (c == s[i]) i--;
            continue;
        }
        if (s[i] != c) {}
        else {
            ans += a[i+1];
            c = a[i+1];
        }
    }

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


Measured memory_bytes: 788
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <string>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <vector>
#include <cstdlib>
#include <stack>
#include <time.h>
using namespace std;
typedef long long LL;
const int MOD = int(1e9)+7;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1.0); //M_PI;
const int maxn = 1001;
char g[maxn][maxn];
int vis[maxn][maxn];
int row , col , n;
int d[4][2] = {0 , 1 , 1 , 0 , 0 , -1 , -1 , 0};

struct factory{
    int x , y , index;
}fac[11];

bool cmp(struct factory tp1 , struct factory tp2)
{
    return tp1.index <= tp2.index;
}
struct node{
    int x , y;
    int sum;
};

int bfs(int si , int sj , int ei , int ej)
{
    queue<struct node> q;
    while(!q.empty()) q.pop();
    memset(vis , 0 , sizeof(vis));
    struct node tp1 , tp2 , tp3;
    tp1.x = si;
    tp1.y = sj;
    tp1.sum = 0;
    q.push(tp1);
    vis[si][sj] = 1;
    //cout << si << " " << sj << endl;
    while(!q.empty())
    {
        tp2 = q.front();
        q.pop();
        int curx = tp2.x;
        int cury = tp2.y;
        if(curx == ei && cury == ej){
            return tp2.sum;
        }
        for(int i = 0 ; i < 4 ; i ++){
            int xx = curx + d[i][0];
            int yy = cury + d[i][1];
//cout << xx << " " << yy << endl;
            if(xx < 0 || xx >= row || yy < 0 || yy >= col || g[xx][yy] == 'X' || vis[xx][yy]) continue;
            tp3.x = xx;
            tp3.y = yy;
            tp3.sum = tp2.sum + 1;
            vis[xx][yy] = 1;
            q.push(tp3);
        }
        //cout << endl;
    }
    return -1;
}

int main()
{

    #ifdef DoubleQ
    freopen("in.txt" , "r" , stdin);
    #endif
    while(cin >> row >> col >> n){
        string s;
        int len = 0;
        for(int i = 0 ; i < row ; i ++){
            cin >> s;
            for(int j = 0 ; j < col ; j ++){
                g[i][j] = s[j];
                if(s[j] == 'S'){
                    fac[len].x = i;
                    fac[len].y = j;
                    fac[len++].index = 0;
                }
                else if(s[j] >= '0' && s[j] <= '9'){
                    fac[len].x = i;
                    fac[len].y = j;
                    fac[len++].index = (int)(s[j] - '0');
                }
            }
        }
        sort(fac , fac + len , cmp);
        int res = 0;
        for(int i = 1 ; i < len ; i ++){
            g[fac[i-1].x][fac[i-1].y] = '.';
            char tp = g[fac[i].x][fac[i].y];
            g[fac[i].x][fac[i].y] = '.';

            int mid = bfs(fac[i-1].x , fac[i-1].y , fac[i].x , fac[i].y);
            res += mid;
            g[fac[i].x][fac[i].y] = tp;
        }
        cout << res  << endl;
    }
}

Measured memory_bytes: 6128
a, b, k = map(int, input().split())
list_1 = [i for i in range(a, a+k) if i<=b]
list_2 = [i for i in range(b-k+1, b+1) if a<=i]
list_1.extend(list_2)
print(*sorted(set(list_1)), sep = '\n')

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


int main() {
 int N;
  cin >> N;
 vector<float> A(N);
 vector<string> B(N);
 for(int i = 0; i < N; i++){
 cin >> A.at(i) >> B.at(i);
 }
  float ans = 0;
 for(int i = 0; i < N; i++){
 if(B.at(i) == "JPY"){
 ans += A.at(i);
 }else{
 ans += A.at(i) * 380000.0;
 }
 }
  cout << ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();
            if (C >= A && C <= B) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  int N;
  cin >> N;
  vector<int> h(N+1,0);
  for(int i = 1;i <= N;i++)cin >> h[i];
  vector<int> dp(N+1,0);
  dp[2] = abs(h[2]-h[1]);

  for(int i = 3;i <= N;i++){
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }

  cout << dp[N] << endl;
}


Measured memory_bytes: 1024
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias pred)(int n) {
    foreach(i; 0..n) pred();
}
auto rep(alias pred, T = typeof(pred()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = pred();
    return res;
}

long INF = long.max/3;
void main() {
    int N, M;
    readf("%d %d\n", &N, &M);

    Vertex[] vs1 = N.iota.map!(i => new Vertex(i, -1)).array;
    Vertex[] vs2 = M.rep!(
        () => readln.split.to!(int[]).map!"a-1".array
    ).sort!(
        (a, b) => a[2]<b[2]
    ).chunkBy!(
        (a, b) => a[2]==b[2]
    ).map!((inputs) {
        Vertex[int] aa;
        inputs.each!((input) {
            int p=input[0], q=input[1], c=input[2];
            if (p !in aa) aa[p] = new Vertex(p, c);
            if (q !in aa) aa[q] = new Vertex(q, c);
            aa[p].edges ~= Edge(aa[p], aa[q], 0);
            aa[q].edges ~= Edge(aa[q], aa[p], 0);
        });
        foreach(i, v1; aa) {
            vs1[i].pipe!((v2) {
                v1.edges ~= Edge(v1, v2, 1);
                v2.edges ~= Edge(v2, v1, 0);
            });
        }
        return aa.byValue;
    }).join.array;

    vs1.front.d = 0;
    auto rbtree = redBlackTree!"a.d!=b.d ? a.d<b.d : a.c!=b.c ? a.c<b.c : a.index<b.index"(vs1.front);
    while (!rbtree.empty) {
        Vertex v = rbtree.front;
        rbtree.removeFront;
        v.edges.each!((e) {
            if (e.end.d > e.start.d + e.d) {
                rbtree.removeKey(e.end);
                e.end.d = e.start.d + e.d;
                rbtree.insert(e.end);
            }
        });
    }

    vs1.back.d.pipe!(a => a==INF ? -1:a).writeln;

}

class Vertex {
    long index;
    int c;
    long d;
    Edge[] edges;
    this(size_t index, int c) {
        this.index = index;
        this.c = c;
        d = INF;
    }
    override string toString() const {return "";}
}

struct Edge {
    Vertex start, end;
    long d;
}


Measured memory_bytes: 145468
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()



int main() {
	string s;
	cin >> s;
	ll arr[26] = {0};
	rep(i, s.size()) ++arr[s[i] - 'a'];

	rep(i, 27) {
		if (i == 26) cout << "yes" << endl;
		else {
			if (2 <= arr[i]) {
				cout << "no" << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n));
	for(auto i = 0; i < n; ++ i){
		for(auto j = 0; j < n; ++ j){
			cin >> a[i][j];
		}
	}
	const long long minf = numeric_limits<long long>::min() / 8;
	const int mx = 1 << n;
	vector<long long> dp(mx, minf), sum(mx);
	dp[0] = 0;
	for(auto mask = 1; mask < mx; ++ mask){
		for(auto i = 0; i < n; ++ i){
			if(mask & 1 << i){
				for(auto j = i + 1; j < n; ++ j){
					if(mask & 1 << j){
						sum[mask] += a[i][j];
					}
				}
			}
		}
		for(auto submask = mask; submask; submask = (submask - 1) & mask){
			ctmax(dp[mask], dp[mask ^ submask] + sum[submask]);
		}
	}
	cout << dp.back();
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <limits.h>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<lint> vl;
typedef pair<lint,lint> pll;

#define mpr make_pair


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

    int n, m; cin>>n>>m;
    vi h(n);
    for (int&v: h) cin>>v;
    vector<vi> mp(n);
    for (int i=0; i<m; ++i){
        int a, b; cin>>a>>b;
        a--; b--;
        mp[a].push_back(b);
        mp[b].push_back(a);
    }

    int cnt = 0;
    for (int i=0; i<n; ++i){
        bool ok = true;
        for (int neib : mp[i]){
            if (h[neib] >= h[i]){
                ok = false;
                break;
            }
        }
        if (ok) cnt++;
    }
    cout<<cnt;


}


Measured memory_bytes: 8744
using System;

namespace ConsoleApplication1
{
    class Program
    {
            static void Main(string[] args)
            {
                int counter = 1;
                while (true)
                {
                    long input = getInputs(1)[0];
                    if (input == 0)
                        break;
                    Console.WriteLine("Case {0}: {1}", counter++, input);
                }
            }

            private static long[] getInputs(long length)
            {
                var sab = Console.ReadLine();
                long[] a = new long[length];
                for (int i = 0; i < length; i++)
                {
                    a[i] = long.Parse(sab.Split(' ')[i]);
                }
                return a;
            }
        }
    }

Measured memory_bytes: 9340
#include <bits/stdc++.h>
#define MOD 1000000007
#define int long long
#define pb push_back
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> edge;
const int N=100005;
int n,par[N],sz[N],ans[N],lazy[N]; vector<edge> e; vector<int> child[100001];
int getp(int u) {
	if (u==par[u]) return u;
	return par[u]=getp(par[u]);
}
void joint(int u,int v,int val) {
	if (sz[u]>sz[v]) swap(u,v);
	//Now we only have to merge u into v
	while (child[u].size()) {
		child[v].pb(child[u].back());
		int temp=child[u].back();
		if (lazy[u]) ans[temp]+=lazy[u];
		ans[temp]+=val*sz[v];
		ans[temp]-=val*sz[u];
		ans[temp]-=lazy[v];
		child[u].pop_back();
	}
	lazy[v]+=sz[u]*val;
	sz[v]+=sz[u];
	par[u]=v;
}
signed main() {
	//freopen("aome.inp","r",stdin);
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n;
	fw (i,1,n) {
		int a,b,c; cin>>a>>b>>c; a--; b--;
		e.pb(edge(c,ii(a,b)));
	}
	sort(e.begin(),e.end());
	reverse(e.begin(),e.end());
	/*
	Idea: Sort all edges based on their c values. Then if a and b doesn't belong to the same group,
	every item in b will connect to every item in a with a cost ofc.
	Merge the smaller group into the bigger one, so each item will be merged exactly log(N) times.
	To update the smaller group, just do it manually. To update the bigger group, we keep a lazy value
	for it, so if we need to update it later when merging we will also perform the lazy update.
	Call the larger group u, smaller one v. Every item in v is added c * sz[u], and otherwise.
	To successfully use lazy, erase all the elements in v by the supposed lazy value we will add.
	*/
	fw (i,0,n) {
		child[i].pb(i);
		sz[i]=1;
		par[i]=i;
		ans[i]=0;
		lazy[i]=0;
	}
	fw (i,0,e.size()) {
		int c=e[i].first,u=e[i].second.first,v=e[i].second.second;
		int pu=getp(u),pv=getp(v);
		if (pu==pv) continue;
		joint(pu,pv,c);
	}
	fw (i,0,n) ans[i]+=lazy[getp(i)];
	fw (i,0,n) cout<<ans[i]<<"\n";
}

Measured memory_bytes: 20464
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

int n,q;
vector<int> tree[200005];
int cnt[200005];
ll sum[200005];
int seen[200005];

void dfs(int n) {
    for(int i = 0;i<int(tree[n].size());i++) {
        if(!seen[tree[n][i]]) {
            seen[tree[n][i]] = 1;
            sum[tree[n][i]] = cnt[tree[n][i]] + sum[n];
            dfs(tree[n][i]);
        }
    }
}

int main() {
    cin>>n>>q;
    rep(i,n-1) {
        int a,b;cin>>a>>b;
        tree[a-1].push_back(b-1);
        tree[b-1].push_back(a-1);
    } 
    rep(i,q) {
        int p,x;cin>>p>>x;
        cnt[p-1]+=x;
    }
    seen[0]=1;
    sum[0]=cnt[0];
    dfs(0);
    rep(i,n) {
        cout<<sum[i]<<" ";
        if(i==n-1) cout<<endl;
    }
}

Measured memory_bytes: 30164
import java.util.Scanner;

public class Main {

    private static final int MOD = 1_000_000_007;

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

        int N = sc.nextInt();
        int[] A = new int[N];

        int[] X = new int[N];

        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }


        int x = A[N - 1];
        int i;

        for (i = 0; i < N / 2; i++) {
            x = A[i] + A[N - 2 - i] - x;
        }
        X[N / 2] = x / 2;

        for (int j = N / 2; j < N - 1; j++) {
            X[j + 1] = A[j] - X[j];
        }
        for (int j = N / 2; j > 0; j--) {
            X[j - 1] = A[j - 1] - X[j];
        }

        for (int j = 0; j < N; j++) {
            System.out.print((X[j] * 2) + " ");
        }
    }
}


Measured memory_bytes: 62280
n,k = map(int,input().split())
a = list(map(int,input().split()))

if n == k:
    print(1)
    exit()
    
n -= k
if n % (k-1) == 0:
    n //= k-1
else:
    n //= k-1
    n += 1
print(n+1)

Measured memory_bytes: 14008
#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>;
using G = vector<vector<int>>;
    
int main(){
    int n;
    vector<int> ans(10001);
    cin >> n;
    for(int x=1; x<=100; x++){
        for(int y=1; y<=100; y++){
            for(int z=1; z<=100; z++){
               ll f;
               f = x*x + y*y + z*z + x*y + y*z + z*x;
               if(f<=n) ans[f] += 1;
            }
        }
    }

    rep(i,n) cout << ans[i+1] << endl;
    return 0;
}

Measured memory_bytes: 3632
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}


int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && b == c)cout << "Yes" << endl;
  else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256