akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;    

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    
const long DIVIDE = 1e9+7;

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
long gcd(long a, long b);    
long lcm(long a, long b);
// ****** print functions ****** //
template <class T, class U>
void print_pairs(const vector<pair<T, U>> pairs);
template <class K, class V>
void print_map(const map<K, V> m);


int main() {    
    string s;
    cin >> s;
    sort(s.begin(), s.end());

    string ans = ""; 
    if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) {
        ans = "Yes";
    } else {
        ans = "No";
    }
    cout << ans << endl;

    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

long gcd(long a, long b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}

long lcm(long a, long b) {
    long gcd_ = gcd(a, b);
    return (a * b) / gcd_;
}

template <class T, class U>
void print_pairs(const vector<pair<T, U>> &pairs) {
    for(int i=0; i<pairs.size(); i++) { 
        cout << "(" << pairs[i].first << ", " << pairs[i].second << ")" << " "; 
    } 
    cout << endl;
}

template <class K, class V>
void print_map(const map<K, V> &m) {
    for(auto it=m.cbegin(); it!=m.cend(); it++) {
        cout << it->first << ": " << it->second << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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



int main()
{
    ll r, D, x;
    cin >> r >> D>>x;
    for (int i = 2000; i < 2010;i++)
    {
        x = r * x - D;
        cout << x << endl;
    }
}


Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

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

int main(void) {
    int H, A;
    cin >> H >> A;

    cout << (H + A - 1) / A << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>

using namespace std;

typedef long long ll;

ll dp[1<<16], a[16][16];

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

    for(int i=0;i<(1<<n);++i) {
        for(int j=0;j<n;++j) {
            if(!(i & (1<<j))) continue;
            for(int k=j+1;k<n;++k) {
                if(!(i & (1<<k))) continue;
                dp[i] += a[j][k];
            }
        }
    }

    for(int i=0;i<(1<<n);++i) {
        for(int mask=0;mask<=i/2;++mask) {
            dp[i] = max(
                dp[i], 
                dp[i&mask]+dp[i&~mask]
            );
        }
    }

    cout << dp[(1<<n)-1] << "\n";
}

Measured memory_bytes: 768
// Median Pyramid Hard
// * frank_c1
// * 2017 / 11 / 09

#include <bits/stdc++.h>
using namespace std;

const int maxn = (int)(2e5) + 5;
int a[maxn], b[maxn];
int n;

bool chk(int x) {
	for (int i = 1; i <= 2 * n - 1; ++i) b[i] = (a[i] >= x);
	if (b[n] == b[n - 1] || b[n] == b[n + 1]) return b[n]; 
	int l = n, r = n;
	while (l > 1 && b[l] != b[l - 1]) --l; 
	while (r < 2 * n - 1 && b[r] != b[r + 1]) ++r;
	if (b[l] == b[r]) return b[l]; 
	return n - l < r - n ? b[l] : b[r];
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= 2 * n - 1; ++i) scanf("%d", &a[i]);
	int l = 1, r = 2 * n - 1; 
	while (l < r) {
		int mid = (l + r) >> 1;
		if (chk(mid + 1)) l = mid + 1; else r = mid;
	} 
	return printf("%d\n", l), 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  repr(i, n, 0) {
    cin >> p[i];
  }

  int ans = 1000000;
  int c;
  for (int i = -1; i <= 101; ++i) {
    bool flag = true;
    for (auto itr : p) {
      if (i == itr) {
        flag = false;
        break;
      }
    }
    if (!flag) continue;
    if (abs(i - x) < ans) {
      c = i;
      ans = abs(i - x);
    }
  }

  cout << c << endl;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

const int MOD = int(1e9) + 7;

int main()
{
    int N; scanf("%d", &N);
    int ans = 0;

    int pa = -1;
    int j = 0;
    for(int i = 1; i <= N; i++) {
      int a; scanf("%d", &a);
      if(pa != a) {
        ans += (i - j) / 2;
        pa = a;
        j = i;
      }
    }
    ans += (N+1-j) / 2;

    printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
    int n,a[200000],next;

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

    next=a[0]-1;
    if(a[0]==2){
        printf("1\n");
        return 0;
    }
    int bef=0,cnt=1;
    while(1){
        if(a[next]==2){
            printf("%d\n",cnt+1);
            return 0;
        }else{
            next=a[next]-1;
            cnt++;
        }
        if(cnt>=2*n)break;
    }
    printf("-1\n");
    return 0;
}

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

int main()
{
	int n;
	while (cin >> n, n) {
		string ga, de;
		vector<string> al(n), be(n);
		for (int i = 0; i < n; i++) {
			cin >> al[i] >> be[i];
		}
		cin >> ga >> de;
		map<string, int> re;
		queue<string> q;
		re[ga] = 1;
		q.push(ga);
		while (!q.empty()) {
			auto p = q.front(); q.pop();
			int sz = p.size();
			for (int j = 0; j < n; j++) {
				string t;
				for (int i = 0; i < sz; i++) {
					if (i + (int)al[j].size() <= sz && p.compare(i, al[j].size(), al[j]) == 0) {
						t += be[j];
						i += al[j].size() - 1;
					}
					else {
						t.push_back(p[i]);
					}
				}
				if (t.size() <= de.size() && re[t] == 0) {
					q.push(t);
					re[t] = re[p] + 1;
				}
			}
		}
		cout << re[de] - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3336
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_V 10001
#define MAX_E 100001

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int parent[MAX_V];
int myrank[MAX_V];

void init(int n) {
    for (int i = 0; i < n; ++i) {
        parent[i] = i;
        myrank[i] = 0;
    }
}

int get_root(int i) {
    if (parent[i] == i)
        return i;
    else
        return parent[i] = get_root(parent[i]);
}

void unite(int x, int y) {
    int root_x = get_root(x);
    int root_y = get_root(y);
    if (root_x == root_y)
        return;
    if (myrank[root_x] > myrank[root_y]) {
        parent[root_y] = root_x;
    } else {
        parent[root_x] = root_y;
        if (myrank[root_x] == myrank[root_y])
            myrank[root_y]++;
    }
}

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

struct edge { int from, to, cost; };
edge es[MAX_E];

bool comp(edge e1, edge e2) {
    return e1.cost < e2.cost;
}

int main() {
    int V, E;
    cin >> V >> E;
    for (int i = 0; i < E; ++i) {
        int s, t, w;
        cin >> s >> t >> w;
        es[i] = edge{ s, t, w };
    }
    
    sort(es, es + E, comp); // cost が小さい順にソート
    init(V);
    int res = 0;
    for (int i = 0; i < E; ++i) {
        edge e = es[i];
        if (!same(e.from, e.to)) {
            unite(e.from, e.to);
            res += e.cost;
        }
    }
    
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 4332
#include<bits/stdc++.h>
// Begin Header {{{
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<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int x, n;
	cin >> x >> n;
	vector<int> a(102);
	rep(i,102) a[i] = i;
	rep(i,n){
		int p;
		cin >> p;
		auto itr = remove(all(a), p);
		a.erase(itr, a.end());
	}
	pair<int, int> ans(9999, -1);
	rep(i,a.size()){
		int dif = abs(x-a[i]);
		ans = min(ans, pair<int, int>(dif, a[i]));
	}
	cout << ans.second << endl;
	return 0;
}

Measured memory_bytes: 3636
N, K = map(int, input().split())
from itertools import accumulate
As = [0] + list(map(int, input().split()))
As = list(accumulate(As))
L = 40
xs = []
for i in range(N+1):
    for j in range(i+1, N+1):
        xs.append(As[j] - As[i])
xs.sort()
ts = set(range(N*(N+1)//2))
for j in range(L-1,-1,-1):
    nts = set()
    for i in ts:
        if (xs[i]>>j)%2:
            nts.add(i)
    if len(nts) >= K:
        ts = nts
c = 0
r = 0
for i in ts:
    c += 1
    if r == 0:
        r = xs[i]
    else:
        r = r&xs[i]
    if c == K:
        break
print(r)


Measured memory_bytes: 91872
import sys
import math
def I(): return int(sys.stdin.readline().rstrip())

def Main():
    n,a,b,c,d,e = I(),I(),I(),I(),I(),I()
    mini = min(a,b,c,d,e)
    tn = math.ceil(n/mini)
    print(tn+4)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC131D - Megalomania
  // 現在時刻は0で、1からNまでの番号が振られたN件の仕事がある
  // 仕事を終えるにはA時間、締め切りはB時、二つの仕事を同時にすることはできない
  // 全ての仕事を終えることができるか
  // ソートして、締め切りが近い順に仕事をしていく
  ll N, sumA = 0, maxB = 0;
  cin >> N;
  vector<vector<ll> > AB(N, vector<ll>(2, 0));
  REP(i, N){
    cin >> AB.at(i).at(1) >> AB.at(i).at(0);
    sumA += AB.at(i).at(1);
    maxB = max(maxB, AB.at(i).at(0));
  }
  if(sumA > maxB){
    cout << "No" << endl;
    return 0;
  }
  sort(AB.begin(), AB.end());
  ll now = 0;
  REP(i, N){
    if(AB.at(i).at(0) < now + AB.at(i).at(1)){
      cout << "No" << endl;
      return 0;
    }
    now += AB.at(i).at(1);
  }
  if(now > maxB){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 11264
#include<stdio.h>

#define N 101

int main(){

int A[N][N];
int B[N]={},C[N];
int i,j,c,n;
int m1,m2,min;
int sum=0;

for(i=1;i<101;i++)
    C[i]=100000;
    C[1]=0;
scanf("%d",&n);

for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
        scanf("%d",&A[i][j]);

B[1]=1;
m2=1;

while(1){
c=0;
   for(i=1;i<=n;i++)
    if(B[i]==1)c++;
   if(c==n)break;

m1=20000000;

for(i=1;i<=n;i++){
if(C[i]>A[m2][i]&& B[i]!=1&&A[m2][i]!=-1)
C[i]=A[m2][i];
if(B[i]!=1 && m1>C[i]){
min=i;
m1=C[i];
}
}
sum=sum+m1;
B[min]=1;
C[min]=m1;
m2=min;
}
printf("%d\n",sum);

return 0;
}

Measured memory_bytes: 1872
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
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;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N;cin>>N;
	int ans=0;
	REP(i,N){
		ans+=(N-1)/i;
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 3616
X, N = map(int, input().split())
lst = [int(x) for x in input().split()]
if N == 0 or X not in lst:
    print(X)
else:
    i = 1
    while True:
        if X - i not in lst:
            print(X - i)
            exit()
        elif X + i not in lst:
            print(X + i)
            exit()
        i += 1

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
int n,a[100010],minn=0X7FFFFFFF;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=n;i>=1;i--){
		if(a[i]-minn>=2){
			cout<<"No"<<endl;
			return 0;
		}
		minn=min(minn,a[i]);
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(var) (var).begin(), (var).end()
#define sz(x) (int)x.size()
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> > 
#define vvpi vector<vector<pair<int,int> > >

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int n,i,j,x,y,a[200005],ans=0,b[200005];
	cin >> n;
	b[0]=0;
	for(i=0;i<n;i++)
	{
		cin >> a[i];
		if(i)
		{
			b[i] = b[i-1] + a[i-1];
			b[i] %= MOD;
		}
	}

	for(i=0;i<n;i++)
	{
		ans += (a[i] * b[i]);
		ans %= MOD;
	}

	cout << ans;
	
	return 0;
}

Measured memory_bytes: 6776
#include<stdio.h>

int gcd(long long int a,long long int b)
{
	if(a%b==0)
	return b;
	else
	return gcd(b,a%b);
}

int main()
{
	long long int a,b,k;
	scanf("%lld%lld",&a,&b);
	k=gcd(a,b);
	printf("%lld\n",(a*b)/k);
	return 0;
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

signed main() {
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);
    string ans = "TBD";
    if (y <= 2019 && m <= 4 && d <= 30)
        ans = "Heisei";
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 10000

void CountingSort(int k);

int A[2000001],B[2000001],C[N];

int main(){
  int i,k;
  
  scanf("%d",&k);
  for(i=1;i<k+1;i++)
    scanf("%d",&A[i]);

  CountingSort(k);

  for(i=1;i<k;i++)
    printf("%d ",B[i]);
  printf("%d\n",B[i]);

  return 0;
}
void CountingSort(int k){
  int i,j;
  
  for(i=0;i<=N;i++)
    C[i] = 0;

  /* C[i] に i の出現数を記録する */
  for(j=1;j<=k;j++)
    C[A[j]]++;
  
  /* C[i] に i 以下の数の出現数を記録する*/
  for(i=1;i<=N;i++)
    C[i] = C[i] + C[i-1];
  
  for(j=k;j>0;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}



Measured memory_bytes: 17464
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.1415;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> bingo(3, vector<int>(3));
vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;

	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

ll getGcd(ll a, ll b) {
	if (a < b) {
		ll temp = b;
		b = a;
		a = temp;
	}

	ll r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}

/*int getNum(ll target) {

	int bottom = 0;
	int top = 151;
	while (1 < top - bottom) {
		int middle = (top + bottom) / 2;
		if (target < line[middle])top = middle;
		else bottom = middle;
	}
	return bottom;
}*/

int main() {

	int N; cin >> N;
	vector<ll> A(N);
	for (int i = 0; i < N; ++i) {
		ll a; cin >> a;
		A[i] = a;
	}

	map<int, int> count;
	ll ans = 0;
	for (int i = 0; i < N; ++i) {
		ans += count[i - A[i]];
		count[i + A[i]]++;
	}
	cout << ans << endl;
}




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

//マージソートの要素結合時に、大小関係を比較
//昇順に並んでいる配列同士を比較するため、左の配列の先頭要素が右の要素よりも大きい場合、反転数を計算することが出来る。
//尚、重要なポイントとして、先頭要素が3つの反転数を含むのであれば、次の要素も3つの反転数を含むため(配列が昇順に並んでいるから)、前の情報を利用できる。

void merge( int* a, int left, int mid, int right, long long& c )
{
    int L_size = mid - left;
    int R_size = right - mid;

    int L[L_size+1];
    int R[R_size+1];

    for( int i = 0; i < L_size; i++ )               //要素の代入
        L[i] = a[i+left];
    
    for( int i = 0; i < R_size; i++ )
        R[i] = a[i+mid];

    L[L_size] = 2000000000;                         //番兵
    R[R_size] = 2000000000;

    int i = 0, j = 0;
    for( int k = left; k < right; k++ )
    {
        if( L[i] >= R[j] )
        {                                           //重要ポイント
            if( i != L_size )                       //番兵との比較時はカウントしない
                c += ( L_size - 1 ) - i + 1;        //加えて、その要素以降分の反転数を加算

            a[k] = R[j];
            j++;
        }
        else
        {
            a[k] = L[i];
            i++;
        }
    }
}

void mergeSort( int* a, int left, int right, long long& c )
{
    if( right - left > 1 )                          //2つの配列に分解していく際、要素の数が1つになってしまった場合、操作を止める。
    {                                               //right-left=1となる時に、要素は一つであることが分かるが、まだ分解可能な時も当然操作を行いたいので
                                                    // > を付けることにより、分解できなくなるまで操作を行うように指定する。
        int mid = ( left + right ) / 2;
        mergeSort( a, left, mid, c );
        mergeSort( a, mid, right, c );
        merge( a, left, mid, right, c );
    }
}

int main()
{
    int n;
    long long cnt = 0;                         //cntは反転数の数

    cin >> n;

    int a[n];

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

    mergeSort( a, 0, n, cnt );

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 4608
import java.io.InputStream
import java.math.BigDecimal
import java.math.BigInteger

fun main(args: Array<String>) = input.run {
    val n = nextInt()
    val a = nextInts(3 * n)
    a.sort()
    var j = 3 * n - 1
    var ans = 0L
    repeat(n) {
        ans += a[--j]
        j--
    }
    println(ans)
}

val input = FastScanner()

fun String.toBigInteger() = BigInteger(this)
fun String.toBigDecimal() = BigDecimal(this)

class FastScanner(private val input: InputStream = System.`in`) {
    private val sb = StringBuilder()
    private val buffer = ByteArray(4096)
    private var pos = 0
    private var size = 0

    fun next(): String? {
        var c = skipWhitespace()
        if (c < 0) return null

        return sb.run {
            setLength(0)

            do {
                append(c.toChar())
                c = read()
            } while (c > ' '.toInt())

            toString()
        }
    }

    fun nextLine(): String? {
        var c = read()
        if (c < 0) return null

        return sb.run {
            setLength(0)

            while (c >= 0 && c != '\n'.toInt()) {
                append(c.toChar())
                c = read()
            }

            toString()
        }
    }

    fun nextLong(): Long {
        var c = skipWhitespace()

        val sign = if (c == '-'.toInt()) {
            c = read()
            -1
        } else 1

        var ans = 0L

        while (c > ' '.toInt()) {
            ans = ans * 10 + c - '0'.toInt()
            c = read()
        }

        return sign * ans
    }

    fun nextInt() = nextLong().toInt()
    fun nextDouble() = next()?.toDouble() ?: 0.0
    fun nextBigInteger(): BigInteger = next()?.toBigInteger() ?: BigInteger.ZERO
    fun nextBigDecimal(): BigDecimal = next()?.toBigDecimal() ?: BigDecimal.ZERO

    fun nextInts(n: Int) = IntArray(n) { nextInt() }
    fun nextLongs(n: Int) = LongArray(n) { nextLong() }
    fun nextDoubles(n: Int) = DoubleArray(n) { nextDouble() }
    fun nextBigIntegers(n: Int) = Array<BigInteger>(n) { nextBigInteger() }
    fun nextBigDecimals(n: Int) = Array<BigDecimal>(n) { nextBigDecimal() }

    fun nextInts(n: Int, m: Int) = Array(n) { nextInts(m) }
    fun nextLongs(n: Int, m: Int) = Array(n) { nextLongs(m) }
    fun nextDoubles(n: Int, m: Int) = Array(n) { nextDoubles(m) }
    fun nextBigIntegers(n: Int, m: Int) = Array(n) { nextBigIntegers(m) }
    fun nextBigDecimals(n: Int, m: Int) = Array(n) { nextBigDecimals(m) }

    private fun skipWhitespace(): Int {
        while (true) {
            val c = read()
            if (c > ' '.toInt() || c < 0) return c
        }
    }

    private fun read(): Int {
        while (pos >= size) {
            if (size < 0) return -1
            size = input.read(buffer, 0, buffer.size)
            pos = 0
        }
        return buffer[pos++].toInt()
    }
}


Measured memory_bytes: 27472
def sum(a, b)
  as = a.split("").map { |s| s.to_i }
  bs = b.split("").map { |s| s.to_i }

  alen = as.length
  blen = bs.length

  if (alen >= blen)
    bs = [0] * (alen - blen) + bs
  else
    as = [0] * (blen - alen) + as
  end

  len = as.length
  sums = []
  of = 0

  (len - 1).step(0, -1).each do |i|
    d = as[i] + bs[i] + of
    sums.unshift(d % 10)
    of = d / 10
  end

  if (of > 0)
    sums.unshift 1
  end

  return sums.join("")
end

### main

n = gets.chop.to_i

n.times do
  a = gets.chop
  b = gets.chop

  c = sum(a, b)

  if (a.length > 80 || b.length > 80 || c.length > 80)
    puts "overflow"
  else
    puts c
  end
end

Measured memory_bytes: 6144
#coding: utf-8
import math

def main():
    line_input = input()
    line_split = line_input.split()
    A = int(line_split[0])
    B = int(line_split[1])
    C = int(line_split[2])
    max_num = math.floor(B / A)
    if max_num > C:
        print(C)
    else:
        print(max_num)
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
//
// B - AtCoDeerくんとボール色塗り / Painting Balls with AtCoDeer
//

#include <iostream>

using namespace std;

int main() {

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

    int dp[1000][1000];

    fill(dp[0], dp[1000], 0);

    for (int i = 0; i < K; i++) {
        dp[0][i] = 1;
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < K; j++) {
            for (int k = 0; k < K; k++) {
                if (j != k) dp[i + 1][k] += dp[i][j];
            }
        }
    }

    int ans = 0;

    for (int i = 0; i < K; i++) {
        ans += dp[N - 1][i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define EPS 1e-8
#define DEB 0

int field[1024][1024];
int dp[1024][1024];
int h,w,n;

int main(){
  
  while(scanf("%d%d%d",&h,&w,&n),h|w|n){
    memset(dp,0,sizeof(dp));
    rep(i,h){
      rep(j,w){
	scanf("%d",&field[i+1][j+1]);
      }
    }
    dp[1][1] = n-1;
    REP(i,1,h+1){
      REP(j,1,w+1){
	int k1,k2;
	if( dp[i-1][j]%2 && field[i-1][j]==0 ){
	  k1 = 1;
	}else{
	  k1 = 0;
	}
	if( dp[i][j-1]%2 && field[i][j-1]==1 ){
	  k2 = 1;
	}else{
	  k2 = 0;
	}

	dp[i][j] += (dp[i-1][j]+k1)/2  + (dp[i][j-1]+k2)/2;
      }
    }
#if DEB
    REP(i,1,h+1){
      REP(j,1,w+1){
	printf("%2d ",dp[i][j]);
      }
      puts("");
    }
#endif
    
    // Nツ嘉アツ姪堋づ個湘ウツ妥板づーツ青カツ青ャ
    /*
    REP(i,1,h+1){
      REP(j,1,w+1){
	field[i][j] = (field[i][j]+dp[i][j])%2;
      }
    }
    */
#if DEB
    puts("field");
    REP(i,1,h+1){
      REP(j,1,w+1){
	printf("%2d ",field[i][j]);
      }
      puts("");
    }
#endif
    
    int x=1;
    int y=1;
    for(;;){
      if( x>w || y>h )break;
      if( (field[y][x]+dp[y][x])%2==1 ){
	x++;
      }else{
	y++;
      }
    }

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

Measured memory_bytes: 8992
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    L = sorted(list(map(int,input().split())))
    ans = 0
    for i in range(n-2):
        for j in range(i,n-1):
            if L[i] == L[j]: 
                continue
            for k in range(j,n):
                if L[j] == L[k]:
                    continue
                if L[i]+L[j] <= L[k]:
                    break
                ans+=1
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 69552
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef long long ll;

const ll INF=1LL<<61;

int main(){
	int n,m,L; scanf("%d%d%d",&n,&m,&L);
	int a[2002];
	rep(i,n) scanf("%d",a+i), a[i]--;
	static ll v[100001];
	rep(i,m) scanf("%lld",v+i+1), v[i+1]+=v[i];

	a[n]=*min_element(a,a+n); n++;
	a[n]=*max_element(a,a+n); n++;
	sort(a,a+n);

	static ll dp[2002][2002];
	rep(i,n) rep(j,n) dp[i][j]=INF;
	dp[0][1]=0;
	rep(i,n-1) rep(j,n-1) if(i!=j) {
		int next=max(i,j)+1;
		dp[next][j]=min(dp[next][j],dp[i][j]+llabs(v[a[next]+1]-v[a[i]])/L);
		dp[i][next]=min(dp[i][next],dp[i][j]+llabs(v[a[next]+1]-v[a[j]])/L);
	}

	printf("%lld\n",dp[n-2][n-1]);

	return 0;
}

Measured memory_bytes: 32000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  
  if (N <= K){
    cout << N*X << endl;
  }
  
  else{
    cout << K*X+(N-K)*Y << endl;
  }
}
  

Measured memory_bytes: 256
class FenwickTree:

    def __init__(self, size):
        self.size = size
        self.array = [0]*size

    def add(self, index, value):
        while index < self.size:
            self.array[index] += value
            index += index&(-index)

    def sum(self, index):
        answer = 0
        while index > 0:
            answer += self.array[index]
            index -= index&(-index)
        return answer

    def rangesum(self, start, end):
        return self.sum(end)-self.sum(start-1)


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))

def read_query():
    l, r = read_ints()
    return l-1, r-1

def solve():
    N, Q = read_ints()
    C = [c-1 for c in read_ints()]
    colour_to_index = [-1]*N
    queries = [read_query() for _ in range(Q)]
    answer = [-1]*Q
    queries_sorted_index = sorted(list(range(Q)), key=lambda i: queries[i][1])
    fenwick_tree = FenwickTree(N+1)
    last_r = -1
    for i in queries_sorted_index:
        l, r = queries[i]
        for j in range(last_r+1, r+1):
            colour = C[j]
            if colour_to_index[colour] != -1:
                fenwick_tree.add(colour_to_index[colour]+1, -1)
            colour_to_index[colour] = j
            fenwick_tree.add(colour_to_index[colour]+1, 1)
        answer[i] = fenwick_tree.rangesum(l+1, r+1)
        last_r = r
    for a in answer:
        print(a)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 220156
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <queue>
#include <list>

using namespace std;
using ll=long long;
ll N;
list<pair<ll, ll> > L;
vector<ll> A;
priority_queue<ll> pq;

int main()
{
  cin >> N;
  A.resize(N);
  for(ll i = 0;i < N;i++)
  {
    cin >> A[i];
  }
  sort(A.begin(), A.end(), greater<ll>());
  pq.push(A[0]);
  //L.insert(L.begin(), make_pair(A[0], A[0]));
  ll ans = 0;
  for(ll i = 1; i < N;i++)
  {
    ans += pq.top();
    pq.pop();
    pq.push(A[i]);
    pq.push(A[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6524
package main

import (
	"fmt"
)

type Dice struct {
	T, S, E, W, N, B int
}

func (p *Dice) roll(direction rune) {

	if direction == 'S' {
		p.S, p.B, p.N, p.T = p.T, p.S, p.B, p.N
	} else if direction == 'N' {
		p.N, p.B, p.S, p.T = p.T, p.N, p.B, p.S
	} else if direction == 'W' {
		p.W, p.B, p.E, p.T = p.T, p.W, p.B, p.E
	} else if direction == 'E' {
		p.E, p.B, p.W, p.T = p.T, p.E, p.B, p.W
	}

}

func (p *Dice) matching(d Dice) bool {

	ret := false
	//6面がそれぞれ一度top
	for i := 0; i < 6; i++ {

		for j := 0; j < 4; j++ { //側面を一周
			if (p.T == d.T) && (p.S == d.S) && (p.E == d.E) && (p.W == d.W) && (p.N == d.N) && (p.B == d.B) {
				ret = true
				break
			} else {
				p.roll('N')
				p.roll('W')
				p.roll('S')
			}
		}

		if i%2 == 0 {
			p.roll('N')
		} else {
			p.roll('W')
		}
	}
	return ret
}

func main() {

	var (
		t, s, e, w, n, b int
		num              int
	)

	fmt.Scanln(&num)

	dices := make([]Dice, num)

	for i := 0; i < num; i++ {
		fmt.Scanln(&t, &s, &e, &w, &n, &b)
		dices[i] = Dice{t, s, e, w, n, b}
	}

	ans := false
	for i := 0; i < num-1; i++ {
		for j := i + 1; j < num; j++ {
			if dices[i].matching(dices[j]) {
				ans = true
				break
			}
		}
		if ans == true {
			break
		}
	}

	if ans {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}

}



Measured memory_bytes: 1200
import java.util.*;

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

      int n = Integer.parseInt(sc.next());

      int[] b = new int[n-1];

      for(int i=0;i<n-1;i++){
        b[i] = Integer.parseInt(sc.next());
      }

      int[] a = new int[n];

      a[0] = b[0];
      for(int i=1;i<n-1;i++){
        a[i] = Math.min(b[i-1],b[i]);
      }
      a[n-1] = b[n-2];

      int ans = 0;

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

      System.out.println(ans);

    }
}


Measured memory_bytes: 21716
#define  _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
#include <math.h>
#include <time.h>
#include <fstream>
#include <list>
#include <climits>
#include <iomanip>

using namespace std;

typedef long long int lld;
typedef long double ld;
typedef vector<int> vi;
typedef vector<char> vch;
typedef vector<lld> vlld;

typedef struct node
{
	int ed;
	lld val;
} node;

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

	string s;

	cin >> s;

	if (s[s.length() - 1] == 's')
	{
		s += "es";
	}
	else
	{
		s += "s";
	}

	cout << s << '\n';

	return 0;
}


Measured memory_bytes: 3644
//Hey u r too far away to know this
//CHIRAGA196
#include <bits/stdc++.h>
using namespace std;
#define     ff                  first
#define     pb                  push_back
#define     ss                  second
#define     IOS                 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     all(v)              v.begin(), v.end()
#define     allr(v)             v.rbegin(), v.rend()
#define       int               long long
#define       endl             '\n'
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
        IOS;
        #ifndef ONLINE_JUDGE
        freopen("inputf.in", "r", stdin);
        //    freopen("outputf.in", "w", stdout);
        #endif 
        int a, b, c, d; cin >> a >> b >> c >> d;
        cout << max({a*c, a*d, b*c, b*d}) << endl;
        return 0;
}

Measured memory_bytes: 3648
N = int(input())
S = list(map(int, list(input())))

def first_idx(s,n):
    for i in range(len(s)):
        if s[i] == n:
            return i
    return -1

ans = 0
for first_pin in range(10):
    tmp = first_idx(S, first_pin)
    if tmp == -1 or tmp >= N-2:
        continue
    tmp_s = S[tmp+1:]
    for second_pin in range(10):
        tmp2 = first_idx(tmp_s, second_pin)
        if tmp2 == -1 or tmp2 == N-1:
            continue
        tmp_s_2 = tmp_s[tmp2+1:]
        ans += len(set(tmp_s_2))

print(ans)

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

int main() {
	int n;
	cin >> n;
	int arr[25];
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int ans = 0;
	for(int i = 1; i < n-1; i++) {
		int a = min(min(arr[i-1],arr[i+1]),arr[i]);
		int b = max(max(arr[i-1],arr[i+1]),arr[i]);
		int c = arr[i];
		ans += ((a!=c)&&(b!=c))?1:0;
	}
	cout << ans << endl;
}


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


int main(){
    int H , W, N;
    cin >> H >> W >> N;

    if(H >= W){
        if(N % H == 0){
            cout << N / H<< endl;  
        }else{
            cout << N / H + 1 << endl;
        }    
    } else{
        if (N % W == 0)
        {
            cout << N / W << endl;
        }
        else
        {
            cout << N / W + 1 << endl;
        }
    }


} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n,t;
  cin >> n >> t;
  vector<int> a(n),b(n);
  rep(i,n) cin >> a.at(i) >> b.at(i);
  int ans = INF;
  rep(i,n){
    if(b.at(i)<=t){
      ans = min(ans,a.at(i));
    }
  }
  if(ans==INF){
    cout << "TLE" << endl;
  }else{
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
double n;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	n/=3.0;
	double ans=n*n*n;
	printf("%.7f",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
int gcd(int a,int b) {

    if (b == 0)return a;
    else return gcd(b, a % b);
}
int lcm(int a, int  b) {
    return a * b / gcd(a, b);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    //int GCD = gcd(a[0], a[1]);
    int LCM = lcm(a[0],a[1]);
    for (int i = 2; i < n; ++i) {
        LCM = lcm(LCM, a[i]);
    }
    cout << LCM << endl;
    return 0;
}



Measured memory_bytes: 3176
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug != false) {
            return;
        }
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long[] aList;

        HashSet<Long> checkset = new HashSet<>();
        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            aList = new long[N];
            for (int i = 0; i < N; i++) {
                aList[i] = sc.nextLong();
            }
        }
        //オールゼロ
        boolean c = false;
        for (long target : aList) {
            if (target != 0) {
                c = true;
                break;
            }
        }
        if (c != true) {
            System.out.println("Yes");
            return;
        }

        if (N % 3 != 0) {
            System.out.println("No");
            return;
        }
        for (Long l : aList) {
            checkset.add(l);
        }

        if (checkset.size() != 3 && checkset.size() != 2) {
            System.out.println("No");
            return;
        }

        List<Long> list = new ArrayList<>(3);
        for (Long l : checkset) {
            list.add(l);
        }

        if (checkset.size() == 3) {
            long l1 = list.get(0);
            long l2 = list.get(1);
            long l3 = list.get(2);
            if ((l1 ^ l2) != l3) {
                System.out.println("No");
                return;
            }
            for (long l : list) {
                int count = 0;
                for (long target : aList) {
                    if (l == target) {
                        count++;
                    }
                }
                if (count * 3 != N) {
                    System.out.println("No");
                    return;
                }
            }
        } else {
            long l1 = list.get(0);
            long l2 = list.get(1);
            if ((l1 ^ l2) != l2 && (l1 ^ l2) != l1) {
                System.out.println("No");
                return;
            }

            int count1 = 0;
            int count2 = 0;

            for (long target : aList) {
                if (l1 == target) {
                    count1++;
                } else if (l2 == target) {
                    count2++;
                }
            }

            if (!((count1 * 2) == count2 || (count2 * 2) == count1)) {
                System.out.println("No");
                return;
            }

        }
        System.out.println("Yes");
        return;
    }
}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 
const int INF =100100100;
#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}

ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}

        
//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
vvl G(200001);
vb sk(200001);
vl ans(200001);
void dfs(ll v){
  if(sk[v]==true)return;
  sk[v]=true;  
  for(ll j=0; j<G[v].size();j++){
    if(!sk[G[v][j]]){
      ans[G[v][j]] +=ans[v];
      dfs(G[v][j]);
    }
  }
  return;
}
int main(){
  ll N,Q;cin>>N>>Q;
  vl a(N-1),b(N-1),p(Q),x(Q);
  rep(i,N-1){
    cin>>a[i]>>b[i];
    G[a[i]].pb(b[i]);
    G[b[i]].pb(a[i]);
  }
   
  rep(i,200001)sk[i]=false;
  rep(i,Q){
    cin>>p[i]>>x[i];
    ans[p[i]]+=x[i];
  }
  
  dfs(1);

  for(ll i=1; i<=N;i++){
    cout<< ans[i]<<" ";
  }
  
  cout<<endl;
}


Measured memory_bytes: 31380
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

int main()
{
    int n, k;
    vector<int> v;
    cin >> n >> k;
    rep (i, n) {
	int tmp;
	cin >> tmp;
	v.push_back(tmp);
    }

    int res = 0;
    for (int i = 0; i <= min(n, k); i++) {
	for (int j = 0; j + i <= min(n, k); j++) {
	    vector<int> jewel;
	    rep (tmp, i)
		jewel.push_back(v[tmp]);
	    rep (tmp, j)
		jewel.push_back(v[n - (tmp + 1)]);
	    sort(jewel.begin(), jewel.end());
	    
	    for (int c = 0; c <= min(k - (i + j), (int)jewel.size()); c++) {
		int sum = 0;
		for (int l = c; l < (int)jewel.size(); l++)
		    sum += jewel[l];
		
		res = max(res, sum);
	    }

	}
    }
	
    cout << res << endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	vi t(5);
	repz(i, 5)cin >> t[i];
	//sort(t.begin(), t.end());

	ll total,ans = 10000000;
	do{
		total = 0;
		//repz(i,5)cout << t[i] << " ";
		//cout << endl;
		for (int i = 0; i < 5; i++) {
			//cout << "t[i]: " << t[i] << endl;
			total += t[i];
			//cout << "total += t[i]: " << total << endl;
			if (i != 4 && total % 10 != 0) total += 10 - (total % 10);
			//cout << " total += (total % 10): " << total << endl;
		}
		if(total < ans)ans = total;
		//cout << "total:" << total << endl;
	} while (next_permutation(t.begin(), t.end()));

	cout << ans << endl;

	system("pause");
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    string n;
    cin >> n;
    char a = n[n.length() - 1];
    switch (a) {
        case '3':
            cout << "bon" << endl;
            break;
        case '0':
            cout << "pon" << endl;
            break;
        case '1':
            cout << "pon" << endl;
            break;
        case '6':
            cout << "pon" << endl;
            break;
        case '8':
            cout << "pon" << endl;
            break;
        default:
            cout << "hon" << endl;
            break;
    }

    return 0;
}

Measured memory_bytes: 3572