akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long quickpow(long long b, long long e)
{
	return e ? ((e & 1 ? b : 1)*quickpow((b*b) % MOD, e >> 1)) % MOD : 1;
}

long long n, a[500009], b[500009], dp1[500009][2], cnt0, dat0[500009], cur, dp2[500009][2];
set<int> st;
map<int, int> mp;
vector<pair<int, pair<bool, int> > > vec[500009];
vector<pair<int, int> > vec_dat;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i] = b[i - 1] ^ a[i];
		if (b[i] == 0) cnt0++;
	}
	if (b[n] != 0) {
		dp1[0][0] = 1;
		dp1[0][1] = 0;
		for (int i = 1; i <= n; i++) {
			if (b[i] == 0)
				dp1[i][0] = dp1[i - 1][0] + dp1[i - 1][1];
			else
				dp1[i][0] = dp1[i - 1][0];
			dp1[i][0] = dp1[i][0] % MOD;
			if (b[i] == b[n])
				dp1[i][1] = dp1[i - 1][0] + dp1[i - 1][1];
			else
				dp1[i][1] = dp1[i - 1][1];
			dp1[i][1] = dp1[i][1] % MOD;
		}
		cout << (dp1[n][1] - dp1[n - 1][1] + MOD) % MOD << "\n";
	}
	else {
		long long ans = 0;
		ans += quickpow(2, cnt0 - 1);
		for (int i = 1; i <= n; i++) {
			dat0[i] = dat0[i - 1];
			if (b[i] == 0) dat0[i]++;
		}
		for (int i = 1; i <= n; i++) {
			if (b[i] == 0) continue;
			if (st.count(b[i]) == 0) {
				st.insert(b[i]);
				mp[b[i]] = cur;
				cur++;
			}
			int tmp = mp[b[i]];
			if (vec[tmp].empty()) {
				if (i > 1) {
					if (dat0[i] > 0) {
						vec[tmp].pb(make_pair(dat0[i], make_pair(false, i - 1)));
					}
				}
				vec[tmp].pb(make_pair(1, make_pair(true, i)));
			}
			else {
				int sz = (int)vec[tmp].size();
				int pre = vec[tmp][sz - 1].se.se;
				if (dat0[i] - dat0[pre] > 0) {
					vec[tmp].pb(make_pair(dat0[i] - dat0[pre], make_pair(false, i - 1)));
					vec[tmp].pb(make_pair(1, make_pair(true, i)));
				}
				else {
					vec[tmp][sz - 1].fi++;
					vec[tmp][sz - 1].se.se = i;
				}
			}
		}
		for (auto x : st) {
			int ix = mp[x], sz = (int)vec[ix].size();
			vec[ix].pb(make_pair(dat0[n] - dat0[vec[ix][sz - 1].se.se], make_pair(false, n)));
			dp2[0][0] = 1;
			dp2[0][1] = 0;
			int pre = 0;
			for (int j = 0; j < (int)vec[ix].size(); j++) {
				int curr = vec[ix][j].se.se;
				int cnt = vec[ix][j].fi;
				if (vec[ix][j].se.fi == false) {
					dp2[curr][0] = dp2[pre][0] + dp2[pre][1] * cnt;
					dp2[curr][0] = dp2[curr][0] % MOD;
					dp2[curr][1] = dp2[pre][1];
					if (curr == n) {
						dp2[curr - 1][0] = dp2[pre][0] + dp2[pre][1] * (cnt - 1);
						dp2[curr - 1][0] = dp2[curr - 1][0] % MOD;
					}
				}
				else {
					dp2[curr][1] = dp2[pre][0] * cnt + dp2[pre][1];
					dp2[curr][1] = dp2[curr][1] % MOD;
					dp2[curr][0] = dp2[pre][0];
				}
				pre = curr;
			}
			ans += (dp2[n][0] - dp2[n - 1][0] + MOD) % MOD;
			ans = ans % MOD;
		}
		cout << ans << "\n";
	}
	//system("pause");
	return 0;
}

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

using namespace std;

int main() {

	int a,b,k;
	cin >> a >> b >> k;
	if (a > b) swap(a, b);
	for (int i = a; i >=1; i--) {
		if (a%i == 0 && b%i == 0) {
			k--;
			if (k == 0) {
				cout << i << endl;
				return 0;
			}
		}

	}

	
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans='APPROVED'
    for i in range(n):
        if a[i]%2==0:
            if a[i]%3==0 or a[i]%5==0:
                continue
            else:
                ans='DENIED'
                break
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll 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(ret);
  return (ret);
}

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

signed main() {
  init();
  ll A, B, C;
  cin >> A >> B >> C;
  ll m = max(A, max(B, C));
  ll sum = A + B + C;
  sum -= m;
  m *= 10;
  sum += m;
  COUT(sum);
  return 0;
}

Measured memory_bytes: 256
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <deque>
#include <memory.h>
#include <queue>

#pragma comment(linker, "/STACK:64000000")
typedef long long ll;

using namespace std;

const int MAXN = 1 << 18;
const int MOD = 1; // 1000 * 1000 * 1000 + 7;
const int INF = 2e9;
const double PI = acos(-1.0);

int main() {
#ifdef _MSC_VER
	freopen("input.txt", "r", stdin);
#endif

	ll x, y;
	while (cin >> x >> y) {
		/*if (x <= y) cout << y - x << endl;
		else {*/
			ll ans = (ll)(1e18);
			if (x <= y) ans = min(ans, y - x);
			if (-x <= y) ans = min(ans, y - (-x) + 1);
			if (x <= -y) ans = min(ans, -y - x + 1);
			if (-x <= -y) ans = min(ans, x - y + 2);
			cout << ans << endl;
		//}
	}

	return 0;
}

Measured memory_bytes: 256
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    int n;
    cin>>n;
 
    vi v(n-1);
 
    for(int &x:v) cin>>x;
 
    int ans = v[0];
    if(n == 2) {cout<<2*ans; return 0;}
 
    for(int i=0;i<n-2;i++){
        ans += min(v[i], v[i+1]);
    }
    ans += v[n-2];
 
    cout<<ans;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<algorithm>
#include<vector>
using namespace std;
  int main(){
      int n;
      cin>>n;
      if(n<=111){cout<<111<<endl;}
      else if(n<=222){cout<<222<<endl;}
      else if(n<=333){cout<<333<<endl;}
      else if(n<=444){cout<<444<<endl;}
      else if(n<=555){cout<<555<<endl;}
      else if(n<=666){cout<<666<<endl;}
      else if(n<=777){cout<<777<<endl;}
      else if(n<=888){cout<<888<<endl;}
      else {cout<<999<<endl;}
  }

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

class ruiseki2D
{
private:
  vector< vector< int > > data;
public:
  ruiseki2D(int W, int H)
  {
      data = vector<vector<int>>(W+1,std::vector<int>(H + 1,0));
  };

  void add(int x, int y, int z)
  {
    ++x, ++y;
    if(x >= data.size() || y >= data[0].size()) return;
    data[x][y] += z;
  }

  void build()
  {
    for(int i = 1; i < data.size(); i++) {
      for(int j = 1; j < data[i].size(); j++) {
        data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
      }
    }
  }

  int query(int sx, int sy, int gx, int gy)
  {
    return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
  }
};

int main()
{
    int N,M,Q;cin >> N >> M >> Q;
    ruiseki2D rui(N,N);
    for(int a = 0;a < M;a++){
        int b,c;cin >> b >> c;
        rui.add(b-1,c-1,1);
    }
    rui.build();
    for(int a = 0;a < Q;a++){
        int b,c;cin >> b >> c;
        cout<<rui.query(b-1,b-1,c,c)<<endl;;
    }
    return 0;
}

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

#define int long long
#define form2(i, a, b) for (int i = (a); i < (b); ++i)
#define ford2(i, a, b) for (int i = (a-1); i >= (b); --i)
#define form(i, n) form2(i, 0, n)
#define ford(i, n) ford2(i, n, 0)

#define chmax(x, v) x = max(x, (v))
#define chmin(x, v) x = min(x, (v))
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define vsz(v) (int)(v.size())

const long long BIG = 1000000000000000000LL;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

void solve();
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

void solve()
{
	int n, a, b;
	cin >> n >> a >> b;
	int d = (b-a);
	if (d % 2 == 0) {
		cout << d/2 << "\n";
	} else {
		int rep1 = a + (d-1)/2;
		int rep2 = (n-b+1) + (d-1)/2;
		cout << min(rep1, rep2) << "\n";
	}
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;


int calc2(int n) {
	if(n <= 1000) {
		return n+1;
	} else {
		return 2000-n+1;
	}
}

void main() {
	while(!stdin.eof()){
		auto s = readln().strip();
		if(s.empty())
			break;
		int n = to!int(s);
		int sum;
		for(int i = max(0, n-2000); i <= min(n, 2000); ++i) {
			sum += calc2(i)*calc2(n-i);
		}
		writeln(sum);
	}
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;
 
 
int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int N;
  cin >> N;
  cout << N * (N+1) / 2 << endl;
  
  return 0;
}


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

using namespace std;

#define MAX 100
#define NIL -1

struct node {
	int prnt, left, right;
};

node tr[MAX];
int n, sb[MAX], dg[MAX], dp[MAX], ht[MAX];

vector<int> preord;
vector<int> inord;
vector<int> pstord;


void setDp(int me, int d) {
	dp[me] = d;
	if (tr[me].left != NIL) setDp(tr[me].left, d + 1);
	if (tr[me].right != NIL) setDp(tr[me].right, d + 1);

	return;
}

void setPre(int me) {

	preord.push_back(me);

	if (tr[me].left == NIL && tr[me].right == NIL) {
		return;
	}
	else {
		if (tr[me].left != NIL) setPre(tr[me].left);
		if (tr[me].right != NIL) setPre(tr[me].right);

		return;
	}
}

void setIn(int me) {


	if (tr[me].left == NIL && tr[me].right == NIL) {
		inord.push_back(me);
		return;
	}
	else {
		if (tr[me].left != NIL) setIn(tr[me].left);
		inord.push_back(me);
		if (tr[me].right != NIL) setIn(tr[me].right);

		return;
	}
}

void setPst(int me) {


	if (tr[me].left == NIL && tr[me].right == NIL) {
		pstord.push_back(me);
		return;
	}
	else {
		if (tr[me].left != NIL) setPst(tr[me].left);
		if (tr[me].right != NIL) setPst(tr[me].right);
		pstord.push_back(me);

		return;
	}
}

int main() {


	int i, j, chdCnt, me, c, l, r, left, right;
	cin >> n;
	for (i = 0; i < n; i++) tr[i].prnt = tr[i].left = tr[i].right = sb[i] = NIL;

	for (i = 0; i < n; i++) {
		cin >> me >> left >> right;

		tr[me].left = left;
		tr[me].right = right;

		int dgr = 0;

		if (left != NIL) {
			tr[left].prnt = me;
		}
		if (right != NIL) {
			tr[right].prnt = me;
		}
	}

	r = tr[0].prnt;
	while (tr[r].prnt != NIL)
	{
		r = tr[r].prnt;
	}

	setPre(r);
	setIn(r);
	setPst(r);

	printf("Preorder\n");
	for (int i = 0;i < n;i++) {
		printf(" %d", preord[i]);
	}
	printf("\n");

	printf("Inorder\n");
	for (int i = 0;i < n;i++) {
		printf(" %d", inord[i]);
	}
	printf("\n");

	printf("Postorder\n");
	for (int i = 0;i < n;i++) {
		printf(" %d", pstord[i]);
	}
	printf("\n");

	return 0;
}



Measured memory_bytes: 3256
/* author:hellojim */
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
ll dp[2020][2020];
ll sum[2020][2020];
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n;
	cin>>n;
	if(n<=2)
	{
		cout<<0<<endl;
		return 0;
	}
	ll ans=0;
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	rep(i,n+1)sum[0][i]=1;
	for(int i=1;i<=1000;i++)
	{
		if(i*3>n)break;
		forn(j,3,n)dp[i][j]=sum[i-1][j-3];
		sum[i][0]=dp[i][0];
		forn(j,1,n)sum[i][j]=(sum[i][j-1]+dp[i][j])%mod;
	}
	for(int i=1;i<=1000;i++)ans=(ans+dp[i][n])%mod;
	cout<<ans<<endl; 
	return 0;
}



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

int main() {
    int n, l;
    cin >> n >> l;
    int tmp = (l + l + n - 1) * n / 2;
    if (l < 0 && l + n - 1 > 0) {
        cout << tmp << endl;
    } else {
        if (l < 0) {
            cout << tmp - (l + n - 1) << endl;
        } else {
            cout << tmp - l << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, n, m;
  bool h = true;
  in2(n, m);
  vector<ll> c(n + 1, 0);
  rep(i, m){
    in2(a, b);
    c[a]++;
    c[b]++;
  }
  rep(i, n){
    if(c[i + 1] % 2 == 1)
      h = false;
  }
  if(h)
    out("YES");
  else
    out("NO");
  memi;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(ll, n);
  ll ans = 0;
  for (ll i = n; i >= 1; --i) ans += i * (n + 1 - i);
  rep(i, n - 1) {
    in(ll, u, v);
    if (u > v) swap(u, v);
    ll x = u * (n - (v - 1));
    ans -= x;
  }
  out(ans);
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
char s[3001];
char t[3001];
string ans;
int dp[3001][3001];
int main()
{
	scanf("%s%s",s,t);
	int n=strlen(s);
	int m=strlen(t);
	dp[0][0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(s[i-1]==t[j-1])
			{
				dp[i][j]=dp[i-1][j-1]+1;
			}else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
			
		}
	}
	//cout<<dp[n][m];
	int i=n,j=m;
	while(i>0&&j>0)
	{
		if(dp[i][j]==dp[i][j-1])
		{
			j--;
		}else if(dp[i][j]==dp[i-1][j])
		{
			i--;
		}
		else
		{
			ans+=s[i-1];
			j--;i--;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
	
}


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

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

int main() {
    string s; cin >> s;
    bool flag = false;
    if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) flag = true;
    if(s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) flag = true;
    if(s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) flag = true;
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
ll Power(ll a,ll b,ll p)
{
    ll res=1;
    while (b>0)
    {
        if (b%2!=0)
        res=((res%p)*(a%p))%p;
        a=((a%p)*(a%p))%p;
        b=b/2;
    }
    return res;
}
ll fac[10000005];
ll infac[10000005];
int main()
{
    ll x,y,mod=1000000007;
    scanf("%lld%lld",&x,&y);
    fac[0]=1;
    for (ll i=1;i<10000005;i++)
    fac[i]=((fac[i-1]%mod)*1LL*i)%mod;
    infac[10000004]=Power(fac[10000004],mod-2,mod);
    for (ll i=10000003;i>=0;i--)
    infac[i]=((infac[i+1]%mod)*1LL*(i+1)%mod)%mod;
    double m1=(2.0*x-y)/3.0;
    double n1=(2.0*y-x)/3.0;
    if (m1==(ll)m1 && n1==(ll)n1 && m1>=0 && n1>=0)
    {
        ll m=(ll)m1;
        ll n=(ll)n1;
        ll val=((((fac[m+n])*(infac[m]))%mod)*(infac[n]))%mod;
        printf("%lld\n",val);
    }
    else
    printf("0\n");
    return 0;
}

Measured memory_bytes: 160040
from collections import Counter

n = int(input())
s = []
for _ in range(n):
  s.append(input())
m = int(input())
t = []
for _ in range(m):
  t.append(input())
c_s = Counter(s)
c_t = Counter(t)

candidates = [0]

for k in c_s.keys():
  candidates.append(c_s[k]-c_t[k])
print(max(candidates))

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

using namespace std;

int main()
{
    long long  n, m, d, c, i;
    cin>>n>>m;
    d=m/n;
    c=m%n;
    for(i=d; i>0 ;i--)
    {
        if(c%i==0)
        {
            cout<<i<<endl;
            return 0;
        }
        c+=n;
    }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;

int main(){
    int n; cin>>n;
    set<pair<int,int>> a;
    set<pair<int,int>> b;
    rep(i,0,n){
        int x,y; cin>>x>>y;
        a.insert({x,y});
    }
    rep(i,0,n){
        int x,y; cin>>x>>y;
        b.insert({x,y});
    }

    int cnt=0;
    for(auto &i:b){
        int maxx=-1;
        int maxy=-1;
        for(auto &j:a){
            if(i.second>j.second and i.first>j.first){
                if(maxy<j.second){
                    maxx=j.first;
                    maxy=j.second;
                }
            }
        }
        // debug(maxx); debug(maxy);
        if(maxx!=-1 and maxy!=-1){
            a.erase({maxx,maxy});
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main(args: Array<String>) {
    val n = readInt()
    val a = readInts()

    val r = Array(n) {0}
    a.forEach { r[it - 1]++ }

    println(r.joinToString("\n"))
}


Measured memory_bytes: 69316
import sys
import math
S = str(input())
T = str(input())
 
 
d = 0
for i,o in enumerate(S):
        j = 0
        c = 0
        for l in S[i:i+len(T)]:
            if l == T[j]:
                c += 1
            j += 1
        d = max(d, c)
        if i > len(S) - len(T) - 1:
            break
print(len(T)-d)
 

Measured memory_bytes: 67544
#include <iostream>

using namespace std;

long long gcm(long long a, long long b) {
    if (a < b) {
        long long w = a;
        a = b;
        b = w;
    }

    while (b != 0) {
        long w = a % b;
        a = b;
        b = w;
    }

    return a;
}

long long lcm(long long a, long long b) {
    return a / gcm(a, b) * b;
}

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

    long long res;
    cin >> res;

    for (int i = 1; i < n; i++) {
        long long t;
        cin >> t;
        res = lcm(res, t);
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define append push_back
#define endl "\n"
#define N 1000000
#define M 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define cover(arr,val) memset(arr,val,sizeof(arr)) 
using namespace std;
int main()
{
	IOS;
	int n,a,b,c,temp1,temp2,temp3,dpc,dpa,dpb;
	cin >> n;
	cin >> a >> b >>c;
	dpa = a;dpb=b;dpc=c;
	for(int i=1;i<n;i++)
	{
		cin >> a>>b>>c;
		temp1 = max(a+dpb,a+dpc);
		temp2 = max(b+dpc,b+dpa);
		temp3 = max(c+dpa,c+dpb);
		dpa = temp1;dpc = temp3;dpb = temp2;
	}
	cout << max(dpb,max(dpc,dpa)) << endl;
	return 0;
}


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

using ll = long long;
using vi = vector<int>;
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))

int main(){
	int N,T; cin>>N>>T;
	vi start(N); rp(i,N)cin>>start[i];

	ll ans = 0;
	int s = 0, e = T;
	up(i,1,N,1){
		if(e>=start[i]){
			ans += start[i]-s;
			s = start[i];
			e = s+T;
		}
		else{
			ans += T;
			s = start[i];
			e = s+T;
		}
	}
	ans+=T;
	cout<< ans <<endl;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.Map.Entry;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemC solver = new ProblemC();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
			}
			TwoMax[] tm = new TwoMax[2];
			for (int step = 0; step < 2; step++) {
				Map<Integer, Integer> m = new HashMap<>();
				for (int i = step; i < n; i += 2) {
					int v = 0;
					if (m.containsKey(a[i])) {
						v = m.get(a[i]);
					}
					m.put(a[i], v + 1);
				}
				tm[step] = new TwoMax();
				for (Map.Entry<Integer, Integer> e : m.entrySet()) {
					tm[step].update(e.getKey(), e.getValue());
				}
			}
			int ans = 0;
			if (tm[0].key0 == tm[1].key0) {
				ans = Math.max(ans, tm[0].value0 + tm[1].value1);
				ans = Math.max(ans, tm[0].value1 + tm[1].value0);
			} else {
				ans = tm[0].value0 + tm[1].value0;
			}
			ans = n - ans;
			out.println(ans);
		}

		class TwoMax {
			int key0;
			int value0;
			int key1;
			int value1;

			void update(int key, int value) {
				if (value > value0) {
					value1 = value0;
					key1 = key0;
					value0 = value;
					key0 = key;
				} else if (value > value1) {
					value1 = value;
					key1 = key;
				}
			}

		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

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

	}
}



Measured memory_bytes: 45308
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		long[][] a = new long[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				a[i][j] = sc.nextLong();
			}
		}
		sc.close();

		int mod = 1000000007;
		long[][] b = matrixPow(a, k, mod);

		long ans = 0;
		for (int j = 0; j < n; j++) {
			for (int j2 = 0; j2 < n; j2++) {
				ans += b[j][j2];
			}
		}
		ans %= mod;
		System.out.println(ans);
	}

	static long[][] matrixPow(long[][] a, long k, int m) {
		if (k == 1) {
			return a;
		}
		long[][] ret = matrixPow(a, k / 2, m);
		ret = matrixMul(ret, ret, m);
		if (k % 2 == 1) {
			ret = matrixMul(ret, a, m);
		}
		return ret;
	}

	static long[][] matrixMul(long[][] a, long[][] b, int m) {
		int n = a.length;
		long[][] c = new long[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int x = 0; x < n; x++) {
					c[i][j] += a[i][x] * b[x][j];
					c[i][j] %= m;
				}
			}
		}
		return c;
	}
}


Measured memory_bytes: 42100
use std::io::Read;
fn main() {
    let (a,b,c) = {
        let inputstr = {
            let mut inputstr = String::new();
            std::io::stdin().read_to_string(&mut inputstr).unwrap();
            inputstr
        };
        let mut inputiter = inputstr.split_whitespace();
        let a =  inputiter.next().unwrap().parse::<usize>().unwrap();
        let b =  inputiter.next().unwrap().parse::<usize>().unwrap();
        let c =  inputiter.next().unwrap().parse::<usize>().unwrap();
        (a,b,c)
    };
    let ans = {
        if let Some(x) = c.checked_sub(a-b){
            x
        }else{
            0
        }
    };
    println!("{}",ans);
}


Measured memory_bytes: 4352
# https://atcoder.jp/contests/agc014/tasks/agc014_b
# 条件を満たすものが存在するかの判別問題

# クエリをグラフにして考えてみる
# a-bを結ぶすべての経路は木上のa-b間の経路を必ず通る
# つまりa-b間の経路の数が偶数である必要がある。すべてのノードに対してエッジが偶数個つながっているかを確認すればよい

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


N, M = read_ints()

n_edges = [0] * N
for _ in ra(M):
    a, b = read_ints()
    n_edges[a - 1] += 1
    n_edges[b - 1] += 1

for n in n_edges:
    if n & 1:
        print('NO')
        exit()
print('YES')


Measured memory_bytes: 3828
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

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

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

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

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

fn write(v: usize, vs: &Vec<Vec<usize>>, nums: &mut Vec<i64>, cs: &Vec<i64>, mut ci: usize) -> usize {
  nums[v] = cs[ci];
  for &u in vs[v].iter() {
    if nums[u] <= 0 {
      ci = write(u, vs, nums, cs, ci - 1);
    }
  }
  ci
}

fn main() {
  input! {
    n: usize,
    edges: [(usize1, usize1); n - 1],
    cs: [i64; n],
  }
  let mut vs = vec![vec![]; n];
  for &(a, b) in edges.iter() {
    vs[a].push(b);
    vs[b].push(a);
  }
  let mut cs = cs;
  cs.sort();
  let mut nums = vec![0; n];
  write(0, &vs, &mut nums, &cs, n - 1);
  let sum = cs.iter().sum::<i64>() - cs[n-1];

  println!("{}", sum);
  for &x in nums.iter() {
    print!("{} ", x);
  }
  println!("");
}


Measured memory_bytes: 4860
# include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
# define forn(i, n) for (ll i = 0; i < int(n); i++)
# define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
# define all(V) V.begin(), V.end()
# define rall(V) V.rbegin(), V.rend()
# define len(V) (int)V.size()
# define ll long long
# define ld long double
# define ff first
# define ss second
# define pb push_back
# define mp make_pair
# define endl '\n'
# define M_PI 3.14159265358979323846

void solve()
{
        int n; cin >> n; 
        vector<ll> a(n);
        forn(i, n) cin >> a[i];
        sort(all(a));
        ll ind = ceil((double)accumulate(a.begin(), a.end(), 0LL) / (double)n);
        ll res1 = 0, res2 = 0;
        //cout << ind << endl;
        for(int i = 0; i < n; ++i)
        {
                ll p = (a[i] - ind);
                res1 += (p * p);
        }
        ind--;
        for(int i = 0; i < n; ++i)
        {
                ll p = (a[i] - ind);
                res2 += (p * p);
        }
        cout << min(res1, res2) << endl;
}
 
int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        solve();
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
//#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)



LL inv_mod(LL a, LL m)
{
	LL b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}




signed main() {

	auto f = [](pair<int, int>x, pair<int, int>y){
		if (x.first == y.first) return x.second < y.second;
		else return x.first < y.first; };

	int H, W, N;
	vector<pair<int, int>> ab;
	cin >> H >> W >> N;
	REP(i, N) {
		int a, b;
		cin >> a >> b;
		ab.PSB(pair<int, int>(a - 1, b - 1));
	}
	sort(ALL(ab), f);

	unsigned long long anss[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

	REP(i, N) {
		vector<vector<int>> box;
		box.assign(5, vector<int>(5, -100));
		FOR(j, ab[i].first - 2, ab[i].first + 3) {
			FOR(k, ab[i].second - 2, ab[i].second + 3) {
				if (0 <= j && j < H && 0 <= k && k < W) {
					if (binary_search(ALL(ab), pair<int, int>(j, k), f)) box[j - (ab[i].first - 2)][k - (ab[i].second - 2)] = 1;
					else box[j - (ab[i].first - 2)][k - (ab[i].second - 2)] = 0;
				}
			}
		}
		REP(j, 3) {
			REP(k, 3) {
				int tmp = box[j][k] + box[j][k + 1] + box[j][k + 2] + box[j + 1][k] + box[j + 1][k + 1] +
					box[j + 1][k + 2] + box[j + 2][k] + box[j + 2][k + 1] + box[j + 2][k + 2];
				if (tmp > 0) ++anss[tmp];
			}
		}
	}

	FOR(i, 1, 10) anss[i] /= i;
	anss[0] = (unsigned long long)(H - 2) * (W - 2);
	FOR(i, 1, 10) anss[0] -= anss[i];
	REP(i, 10) cout << anss[i] << endl;




	return 0;
}

Measured memory_bytes: 1400
#include<iostream>

using namespace std;

int main()
{
   int N;
   cin>>N;
  
   float temp; 
   float sum = 0.0;
    
   for (int i = 0; i < N; i++)
   {
      cin>>temp;
      sum += 1/temp;
   }
  cout<<1/sum;
  return 0;
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
int memo[3010][3010];
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s,t; cin >> s >> t;
    rep(i,1,s.size()+1){
        rep(j,1,t.size()+1){
            if(s[i-1] == t[j-1]) memo[i][j] = memo[i-1][j-1]+1;
            else memo[i][j] = max(memo[i-1][j],memo[i][j-1]);
        }
    }
    vector<int> ans;
    int locate=0;
    
    string str;
	int i = s.size(), j = t.size();
	while(i > 0 && j > 0){
		if(s[i - 1] == t[j - 1]){
			str += s[-- i];
			-- j;
		}else if(memo[i - 1][j] < memo[i][j - 1]){
			-- j;
		}else if(memo[i - 1][j] >= memo[i][j - 1]){
			-- i;
		}
	}
    for(auto it = str.rbegin(); it != str.rend(); ++ it){
		cout << *it;
	}
    cout << endl;


}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int N, T, A, h;
    vector<int> H;
    cin >> N >> T >> A;
    while(cin >> h) H.push_back(h);

    double ans, answer = 1000000000;
    int answer_i;
    for(int i = 0; i < N; i++){         
        ans = (A - (T - 0.006 * H[i]));
        if(ans <= 0) ans = 0 - ans;     
        
        if(ans < answer){  
            answer = ans;               
            answer_i = i;               
        }
    }

    cout << answer_i + 1 << endl;        
}


Measured memory_bytes: 256
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),
  fast;
	
	ll n , m , k ;
	cin>> n >> m >> k ;
	vector<ll> vec(n,m);
	for(ll i=0;i<k;i++){
		ll a ;cin>> a;
		--a;
		vec[a]++;
	}
	for(ll i=0;i<n;i++){
		vec[i]-=k;
	}
	for(ll i=0;i<n ;i++){
		if(vec[i]<=0)cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}

	return 0;
}

Measured memory_bytes: 1408
def main():
    N, x = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    ans = 0
    i = 0
    while x > 0:
        if i < N - 1 and x - a[i] >= 0:
            x -= a[i]
            ans += 1
        elif i == N-1 and x == a[i]:
            x -= a[i]
            ans += 1
        else:
            break
        i += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v) reverse(v.begin(),v.end())
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const ll MOD =1000000007;
#define PI 3.14159265258979

#define P pair<int,int>
#define Pll pair<ll,ll>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

struct UnionFind{
	vector<int> par; //データiが属する親の番号
	vector<int> sizes; //根ノードiの木に含まれるデータの数

	// 最初は全てのデータiがグループiに存在するものとして初期化
	UnionFind(int n):par(n),sizes(n, 1){
		REP(i,n) par[i] = i;
	}

	// 根を張り替えながら再帰的に根ノードを探す
	int find(int x){
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		sizes[y] = 0;  // sizes[y]は無意味な値となるため
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};
int gcd(int n,int m){
	if(m>n) return gcd(m,n);
	if(m==0) return n;
	else return gcd(m,n%m); 
}

int main(void){
	char S[4];
	
	REP(i,4) cin>>S[i];
	
	SORT(S,4);
	if(S[0]==S[1] && S[2]==S[3] && S[0]!=S[2])
		print("Yes");
	else
		print("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int M;
    cin >> M;
    vector<lint> d(M);
    vector<lint> c(M);
    REP(i, M) cin >> d[i] >> c[i];
    lint csum = 0;
    REP(i, M) csum += c[i];
    lint ans = csum - 1;
    lint dsum = 0;
    REP(i, M) dsum += d[i]*c[i];
    ans += (dsum-1) / 9;
    cout << ans << endl;
}

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

using std::cout;
using std::endl;
using std::cin;
using std::vector;

void printVector(vector<vector<int> > v) {
    for (int i = 0; i < v.size(); i++ ) {
        for (int j = 0; j < v.front().size(); j++) {
            cout << v[i][j]; 
            if (j != v.front().size() - 1) {
                cout << " "; 
            }
        }
        cout << endl;
    }
}

void calcElement(vector<vector<int> > &v, int r, int c) {
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            v[i][c] += v[i][j];
            v[r][j] += v[i][j];
        }
        v[r][c] += v[i][c];
    }
}

int main(void) {
    int r;
    int c;
    cin >> r >> c;
    vector<vector<int> > table(r + 1, vector<int>(c + 1, 0));
    for (int i = 0; i < r * c; i++) {
        int row = i / c;
        int column = i - row * c;
        cin >> table[row][column];
    }
    calcElement(table, r, c);
    printVector(table);
    return 0;
}

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

bool vis[100000];
int dist[100000];
vector<vector<int>> graph;
vector<int> topo;

void dfs(int u)
{
    vis[u] = 1;
    
    for (int v: graph[u])
        if (!vis[v])
            dfs(v);
    
    topo.push_back(u);
}

int main()
{
    int n, m;
    cin >> n >> m;
    graph.resize(n);
    for (int i = 0; i != m; ++i)
    {
        int u, v;
        scanf("%d %d", &u, &v);
        --u;
        --v;
        graph[u].push_back(v);
    }
    for (int i = 0; i != n; ++i)
        if (!vis[i])
            dfs(i);
    for (auto it = topo.rbegin(); it != topo.rend(); ++it)
        for (int v: graph[*it])
            dist[v] = max(dist[v], dist[*it] + 1);
    int ans = 0;
    for (int i = 0; i != n; ++i)
        ans = max(ans, dist[i]);
    cout << ans;
    return 0;
}

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

int main(){

    long long n;
    cin>>n;

    long long ans=0;

    for(int i=1; i<=n; i++)
    {
        if(i%3!=0 && i%5!=0)
            {ans=ans+i;}
    }
    cout <<ans;


return 0;
}



Measured memory_bytes: 3612
#include <stdio.h>

int main(void) {
	int N;
	int D1, D2;
	int tomatu = 0, sumipe = 0;
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &D1, &D2) != 2) return 1;
		if (D1 == D2) tomatu++; else tomatu = 0;
		if (tomatu >= 3) sumipe = 1;
	}
	puts(sumipe ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 1656
from collections import Counter
s = list(input())
d =  Counter(s)
key = d.keys()
ans = len(s)//2 + len(s)%2
for k in key:
    ck = 0
    i = 0
    while True:
        if s[i] == k:
            i += 1
            if i == len(s):
                break
        else:
            cnt = 0
            while s[i + cnt] != k:
                cnt += 1
                if i + cnt == len(s):
                    break
            ck = max(ck, cnt)
            i += cnt
            if i == len(s):
                break
    ans = min(ans, ck)
print(ans)

Measured memory_bytes: 66416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(j, m) for (int j = 0; j < (int)(m); j++)
#define rep2(i, l, n) for (int i = l; i < (int)(n); i++)


int main() {
    string S;
    cin >> S;
    vector<int> V(26,0);
    rep(i,S.size()) {
        V[S[i] - 'a']++;
    }
    int flag = 0;
    rep(j,26) {
        if (V[j] >= 2) {
            flag++;
        }
    }
    if (flag == 0) {
        cout << "yes" << endl;
    }
    else {
        cout << "no" << endl;
    }
}



Measured memory_bytes: 3564
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < k; i++)
typedef long long ll;
typedef unsigned long long ull;
char field[1024][1024];
int dp[1024][1024][3];
int main(){
    int m,n;
    scanf("%d%d",&m,&n);
    int k;
    scanf("%d",&k);
    
    rep(i,m){
        scanf("%s",field[i]);
        rep(j,n){
            if(field[i][j] == 'J'){
                dp[i][j][0] += (j==0) ? 1 : dp[i][j-1][0]+1;
                dp[i][j][1] = dp[i][j-1][1];
                dp[i][j][2] = dp[i][j-1][2];
            } 
            else if(field[i][j] == 'O'){
                dp[i][j][0] = dp[i][j-1][0];
                dp[i][j][1] += (j==0) ? 1 : dp[i][j-1][1]+1;
                dp[i][j][2] = dp[i][j-1][2];
            }
            else{
                dp[i][j][0] = dp[i][j-1][0];
                dp[i][j][1] = dp[i][j-1][1];
                dp[i][j][2] += (j==0) ? 1 : dp[i][j-1][2]+1;
            }
        }
    }
    while(k--){
        int y1,x1,y2,x2;
        int J = 0,O = 0,I = 0;
        scanf("%d%d%d%d",&y1,&x1,&y2,&x2);
        reps(i,y1-1,y2){
            J += dp[i][x2-1][0] - ((x1-2 < 0) ? 0 : dp[i][x1-2][0]);
            O += dp[i][x2-1][1] - ((x1-2 < 0) ? 0 : dp[i][x1-2][1]);
            I += dp[i][x2-1][2] - ((x1-2 < 0) ? 0 : dp[i][x1-2][2]);
        }
        printf("%d %d %d\n",J,O,I);
    }
    return 0;
}

Measured memory_bytes: 14472