akhauriyash/Code-Regression huggingface dataset:
#include <deque>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

int food[50];
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		for (int j = 0; j < x; j++) {
			int f;
			cin >> f;
			food[f]++;
		}
	
	}
	int cnt = 0;
	for (int i = 1; i <= 30; i++)
		if (food[i] == n)cnt++;
	cout << cnt;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
r = [0]*n
r[0] = 1
c = [1]*n
for _ in range(m):
  x, y = map(int, input().split())
  x -= 1
  y -= 1
  if r[x]:
    if c[x] == 1:
      r[x] = 0
    r[y] = 1
  c[x] -= 1
  c[y] += 1
print(r.count(1))

Measured memory_bytes: 4596
import sys

input = sys.stdin.readline

def main():
    ans = [0]* 10010
    n = int(input())
    for x in range(1,101):
        for y in range(1,101):
            for z in range(1,101):
                v = (x+y+z)**2 - x*y - y*z - z*x
                if v <= n:
                    ans[v] += 1
    for i in range(1,n+1):
        print(ans[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
#include <chrono>
#include <iostream>

using namespace std;
using namespace std::chrono;

int main() {
  auto start = high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string s;
  cin >> s;
  for (size_t i = 0; i < s.size(); i += 2)
    cout << s[i];
  cout << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


Measured memory_bytes: 592
def solve():
    N, M = map(int, input().split())
    S = list(map(int, input().split()))
    T = list(map(int, input().split()))
    MOD = 10 ** 9 + 7
    
    dp = [[1] * (M + 1) for _ in range(N + 1)]
    for i in range(N):
        for j in range(M):
            if S[i] == T[j]:
                dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1]) % MOD
            else:
                dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1] - dp[i][j]) % MOD
    print(dp[N][M])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 72028
n=int(input())
for i in range(n):
    a,b,c=map(int,input().split())
    if a**2+b**2==c**2:
        print("YES")
    elif b**2+c**2==a**2:
        print("YES")
    elif a**2+c**2==b**2:
        print("YES")
    else:
        print("NO")
           



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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<vector<T>> m) {
    repall (v, m)
        init(v);
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------

map<int, int> mp;

int num(int x) {
    int cnt = 0;
    repall (e, mp)
        if (e.second >= x) cnt++;
    return cnt;
}

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int n;
    cin >> n;

    For(i, 2, n) {
        int cpy = i;
        while (cpy != 1) {
            For(j, 2, cpy) {
                if (cpy % j == 0) {
                    cpy /= j;
                    mp[j]++;
                    break;
                }
            }
        }
    }

    print(num(4) * (num(4) - 1) * (num(2) - 2) / 2 + num(14) * (num(4) - 1) +
          num(24) * (num(2) - 1) + num(74));

    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
from operator import mul
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * (10 ** 5 * 2 + 1)
for a in A:
    B[a] += 1
C = list(accumulate(B[::-1]))[::-1]
l, r = 1, 10 ** 5 * 2 + 1
while r - l > 1:
    m = l + (r - l + 1) // 2
    if sum(C[max(0, m - a)] for a in A) >= M:
        l = m
    else:
        r = m
D = list(accumulate(map(mul, range(10 ** 5 * 2, -1, -1), B[::-1])))[::-1]
ans = sum(D[max(0, l - a)] - (l - a) * C[max(0, l - a)] for a in A) + l * M
print(ans)

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

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, m;
  scanf("%d %d", &n, &m);

  map<int, int> mp;
  REP(i,m){
    int t1, t2;
    scanf("%d %d", &t1, &t2);
    t1--; t2--;
    mp[t1]++; mp[t2]++;
  }

  REP(i,n){
    printf("%d\n", mp[i]);
  }

  return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
void vok()
{
    FAST
    FO
    FI
//    #ifndef ONLINE_JUDGE
//        freopen("input.txt","r",stdin);
//        freopen("output.txt","w",stdout);
//    #endif
}
int main()
{
    vok();
    int n;
    IN n;
    vector<string> v(n);
    map<string,int> m;
    int mx=0;
    loop(i,0,n)
    {
        IN v[i];
        m[v[i]]++;
        mx= max(mx,m[v[i]]);
    }
    set<string> s;
    for(auto x:m)
    {
        if(x.second==mx)
        {
            s.insert(x.first);
        }
    }
    for(auto x:s)
    {
        OUT x<<endl
    }
    return 0;
}


Measured memory_bytes: 34816
#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#define inf 1000000002
using namespace std;

int main()
{
  int ma,mi,N;
  vector<string> S;
  string s;
  while(1){
    cin>>N;
    if(N==0)break;
    S.clear();
    S.push_back("1000000002");
    for(int i=0;i<N;i++){
      cin>>s;
      S.push_back(s);
    }

    ma=inf;mi=(-1)*inf;
    for(int i=1;i<N+1;i++){
      if(S[i]=="x"){
       	if(S[i-1]=="x"){
	  ma=(-1)*inf;mi=inf;
	  break;
	  }
	if(i%2==0){
	  mi=max(mi,atoi(S[i-1].c_str())+1);
	}
	if(i%2==1){
	  ma=min(ma,atoi(S[i-1].c_str())-1);
	}
      }
      else {
	if(S[i-1]=="x"){
	  if(i%2==0){
	    ma=min(ma,atoi(S[i].c_str())-1);
	  }
	  if(i%2==1){
	    mi=max(mi,atoi(S[i].c_str())+1);
	  }
	}
	else {
	  if(i%2==0){
            if(atoi(S[i].c_str())<atoi(S[i-1].c_str())){
	      ma=(-1)*inf;mi=inf;
	      break;
	    }
	  }
	  if(i%2==1){
	    if(atoi(S[i].c_str())>atoi(S[i-1].c_str())){
	      ma=(-1)*inf;mi=inf;
	      break;
	    }
	  }
	}
      }
    }
    if(ma==mi)cout<<ma<<endl;
    else if(ma<mi)cout<<"none"<<endl;
    else cout<<"ambiguous"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1328
#include<cstdio>
#include<cstring>
#define LL long long
using namespace std;
const LL N=2e5+10;
struct jgt{
	LL x,y,next,w;
}bian[N];
LL n,m,black,white,co[N],h[N],cnt[10],tot,head[N];
bool vis[N],flag=true;
void add_edge(LL a,LL b)
{
	tot++;
	bian[tot].x=a;
	bian[tot].y=b;
	bian[tot].next=head[a];
	head[a]=tot;
}
void dfs(LL now,LL pre)
{
	LL i;
	vis[now]=true;
	for (i=head[now];i!=-1;i=bian[i].next)
	{
		LL v=bian[i].y;
		if (!vis[v])
		{
			co[v]=pre^1;
			cnt[co[v]]++;
			dfs(v,co[v]);
			if (!flag)
			  return;
		}
		else
		if (co[v]!=pre^1)
		{
		  flag=false;
		  return ;
	    }
	}
}
int main()
{
	LL i,a,b; 
	memset(head,-1,sizeof(head));
	scanf("%lld%lld",&n,&m);
	for (i=1;i<=m;i++)
	  scanf("%lld%lld",&a,&b),add_edge(a,b),add_edge(b,a);
	cnt[co[1]]++;
	dfs(1,0);
	if (!flag)
		printf("%lld",n*(n-1)/2-m);
	else
		printf("%lld",cnt[0]*cnt[1]-m);
} 

Measured memory_bytes: 11392
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int digit_len(int n)
{
    int res = 0;
    while (n > 0)
    {
        res++;
        n /= 10;
    }
    return res;
}

int main()
{
    int a, b;
    cin >> a >> b;

    int x = b;
    int len = digit_len(b);
    for (int i = 0; i < len; i++)
    {
        a *= 10;
    }

    x += a;

    bool ok = false;
    for (int i = 1; i * i <= x; i++)
    {
        if (i * i == x)
        {
            ok = true;
            break;
        }
    }

    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  int k = in();
  int pop_count = 0;
  int even_pop_count = 0;
  for(int i = 1; i < n+1; ++i) {
    if(i%k == 0) ++pop_count;
    if(k%2 == 0 && i%k == k/2) ++even_pop_count;
  }
  int ans = pop_count * pop_count * pop_count + even_pop_count * even_pop_count * even_pop_count;
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

const int N=2e5+5;
int val[2][N*2],tag[2][N*2];
int lson[N*2],rson[N*2];
int n,q,m;
long long ans;

void chmin(int &x,int y){
	x=min(x,y);
}

int cmin(int tp,int pos){
	return min(tag[tp][pos],val[tp][pos]);
}

void update(int tp,int pos){
	val[tp][pos]=min(cmin(tp,lson[pos]),cmin(tp,rson[pos]));
}

int query(int tp,int pos,int x,int y,int l,int r){
	if(x>=l&&y<=r) return cmin(tp,pos);
	if(x>r||y<l) return n;
	int mid=(x+y)>>1;
	int q=min(query(tp,lson[pos],x,mid,l,r),query(tp,rson[pos],mid+1,y,l,r));
	update(tp,pos);
	return min(q,tag[tp][pos]);
}

void modify(int tp,int pos,int x,int y,int l,int r,int v){
	if(x>=l&&y<=r){
		chmin(tag[tp][pos],v);
		return;
	}
	if(x>r||y<l) return;
	int mid=(x+y)>>1;
	modify(tp,lson[pos],x,mid,l,r,v);
	modify(tp,rson[pos],mid+1,y,l,r,v);
	update(tp,pos);
}

void build(int pos,int x,int y){
	if(x==y) return;
	int mid=(x+y)>>1;
	lson[pos]=++m;
	rson[pos]=++m;
	build(lson[pos],x,mid);
	build(rson[pos],mid+1,y);
}

int main(){
	scanf("%d%d",&n,&q);
	ans=1ll*(n-2)*(n-2);
	for(int i=0;i<2;i++) for(int j=0;j<N*2;j++) val[i][j]=tag[i][j]=n;
	m=1;build(1,1,n);
	for(int i=1;i<=q;i++){
		int o,x;
		scanf("%d%d",&o,&x);
		o--;
		int res=query(o,1,1,n,x,x);
		ans-=res-2;
//		printf("%d:%d\n",i,res);
		modify(o^1,1,1,n,1,res,x);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 13184
#include <stdio.h>
#include <math.h>

#define INFTY 1000000000
int count, n, A[500000];

void merge(int, int, int);
void mergeSort(int, int);

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

  mergeSort(0,n);
  
  for(i = 0; i < n-1; i++) printf("%d ",A[i]);
  printf("%d\n%d\n",A[n-1],count);
 
  return 0;
}

void merge(int left, int mid, int right){
  int i = 0, j = 0, k;
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1], R[n2+1];

  for(i = 0; i < n1; i++){
    L[i] = A[left + i];
  }
  
  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }
  
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{
      A[k] = R[j];
      j = j + 1;
    }
    count++;
  }
}

void mergeSort(int left, int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
}



Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
vector<string> maze(20);
typedef pair<int,int> P;

int h,w,sx,sy,gx,gy;
int bfs(){
    vector<vector<int>> checked(20,vector<int>(20,(int)(1e9 + 7)));
    queue<P> que;
    que.push(P(sy,sx));
    checked[sy][sx] = 0;
    while(que.size()){
        P p = que.front();
        que.pop();
       if(p.first == gy && p.second == gx)
        break;
        for(int i = 0; i < 4; i++){
            int ny = dy[i] + p.first, nx = dx[i] + p.second;
            if(0 <= ny && ny < h && 0 <= nx && nx < w && maze[ny][nx] == '.' && checked[ny][nx] == (int)(1e9 + 7)){
                que.push(P(ny,nx));
                checked[ny][nx] = checked[p.first][p.second] + 1;
            }
        }
    }
    return checked[gy][gx];
}
int main(){
    cin >> h >> w;
    for(int i = 0; i < h; i++)
    cin >> maze[i];

    vector<pair<int,int>> grids;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(maze[i][j] == '.')
            grids.push_back(make_pair(i,j));
        }
    }
    int ans = 0;
    for(int i = 0; i < grids.size(); i++){
        for(int j = 0; j < grids.size(); j++){
            sy = grids[i].first,sx = grids[i].second;
            gy = grids[j].first,gx = grids[j].second;
            ans = max(bfs(),ans);
        }
    }
    cout << ans << endl;
}

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

struct Edge {
	int To;
	long long A, B;
	Edge(int To, long long A, long long B) : To(To), A(A), B(B) {};
};

long long INF = 1000000000000000;

int main() {
	int N, M;
	long long S;
	cin >> N >> M >> S;
	vector<vector<Edge> > V(N);
	for (int i = 0; i < M; i++) {
		int X, Y, A, B;
		cin >> X >> Y >> A >> B;
		X--, Y--;
		V[X].push_back(Edge(Y, A, B));
		V[Y].push_back(Edge(X, A, B));
	}
	vector<long long> C(N), D(N);
	for (int i = 0; i < N; i++) cin >> C[i] >> D[i];
	long long MAX = 10000;
	if (S >= MAX) {
		vector<long long> Dist(N, INF);
		priority_queue<pair<long long, long long>, vector<pair<long long, long long> >, greater<pair<long long, long long> > > PQ;
		Dist[0] = 0;
		PQ.push({ 0, 0 });
		while (!PQ.empty()) {
			pair<long long, long long> P = PQ.top();
			PQ.pop();
			if (Dist[P.second] < P.first) continue;
			for (Edge NP : V[P.second]) {
				if (Dist[NP.To] > P.first + NP.B) {
					Dist[NP.To] = P.first + NP.B;
					PQ.push({ Dist[NP.To], NP.To });
				}
			}
		}
		for (int i = 1; i < N; i++) {
			cout << Dist[i] << endl;
		}
		return 0;
	}
	vector<vector<long long> > Dist(N, vector<long long>(MAX, INF));
	priority_queue<pair<long long, pair<long long, long long> >, vector<pair<long long, pair<long long, long long> > >, greater<pair<long long, pair<long long, long long> > > > PQ;
	Dist[0][S] = 0;
	PQ.push({ 0, {0, S} });
	while (!PQ.empty()) {
		pair<long long, pair<long long, long long> > P = PQ.top();
		PQ.pop();
		if (Dist[P.second.first][P.second.second] < P.first) continue;
		for (Edge NP : V[P.second.first]) {
			if (P.second.second < NP.A) continue;
			if (Dist[NP.To][P.second.second - NP.A] > Dist[P.second.first][P.second.second] + NP.B) {
				Dist[NP.To][P.second.second - NP.A] = Dist[P.second.first][P.second.second] + NP.B;
				PQ.push({ Dist[NP.To][P.second.second - NP.A], {NP.To, P.second.second - NP.A} });
			}
		}
		if (Dist[P.second.first][min(MAX - 1, P.second.second + C[P.second.first])] > Dist[P.second.first][P.second.second] + D[P.second.first]) {
			Dist[P.second.first][min(MAX - 1, P.second.second + C[P.second.first])] = Dist[P.second.first][P.second.second] + D[P.second.first];
			PQ.push({ Dist[P.second.first][min(MAX - 1, P.second.second + C[P.second.first])], {P.second.first, min(MAX - 1, P.second.second + C[P.second.first])} });
		}
	}
	for (int i = 1; i < N; i++) {
		long long ANS = INF;
		for (int j = 0; j < MAX; j++) {
			ANS = min(ANS, Dist[i][j]);
		}
		cout << ANS << endl;
	}
}

Measured memory_bytes: 19408
#include <bits/stdc++.h>
using namespace std;
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());
//int rnd(int x) { return mrand()%x;}
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
int main(){
	int n,r;
	scanf("%d%d",&n,&r);
	if(n>=10){
		printf("%d\n",r);
	}
	else{
		printf("%d\n",r+100*(10-n));
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e3 + 5;
using namespace std;
typedef long long ll;
int n, t[4 * N];
int sum(int v, int s, int e, int qs, int qe) {
    if (qs > e || s > qe) return 0;
    if (s >= qs && e <= qe) return t[v];
    int m = (s + e) / 2;
    return sum(v * 2, s, m, qs, qe) + sum(v * 2 + 1, m + 1, e, qs, qe);
}
void update(int v, int s, int e, int pos, int new_val) {
    if (pos < s || pos > e) return;
    if (s == e) { t[v] += new_val; return; }
    int m = (s + e) / 2;
    update(v * 2, s, m, pos, new_val);
    update(v * 2 + 1, m + 1, e, pos, new_val);
    t[v] = t[v * 2] + t[v * 2 + 1];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec[i];
        update(1, 0, 1e3, vec[i], 1);
    }
    sort(vec.begin(), vec.end());
    ll res = 0;
    for (int i = 0; i < n; i++) {
        update(1, 0, 1e3, vec[i], -1);
        for (int j = i + 1; j < n; j++) {
            update(1, 0, 1e3, vec[j], -1);
            res += sum(1, 0, 1e3, vec[j] - vec[i] + 1, vec[i] + vec[j] - 1);
        }
        for (int j = i + 1; j < n; j++) {
            update(1, 0, 1e3, vec[j], 1);
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE
void solve(void)
{
  int A,B;
  cin>>A>>B;
  if(A*2 >= B)
  {
    cout<<B/2<<endl;
  }
  else
  {
    int res = A;
    B -= A*2;
    res += B/4;
    cout<<res<<endl;

  }
  
  
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define m_p make_pair
#define p_b push_back
#define MOD 1000000007
bool check(ll x)
{
	if(x<=12 && x>=1)
	{
		return true;
	}
	return false;
	
}
int main()
{
	nfs;
	int t;
	t=1;
//	cin >> t;

	while(t--)
	{
		ll n;
		cin >> n;
		ll a = n/100;
		ll b = n%100;
		if(check(a)&&check(b))
		{
			cout << "AMBIGUOUS" << endl;
		}
		else if(check(a))
		{
			cout << "MMYY" << endl;
		}
		else if(check(b))
		{
			cout << "YYMM" << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
	return 0;

}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<map>
#include<vector>
#include<ctime>
using namespace std;
#define INF (1<<30)
typedef pair<int,int> Pa;
inline int mmin(int a,int b){ return a>b?b:a;}
inline int mmax(int a,int b){ return a>b?a:b;}
int N,M;
int P[1111];
struct Segment{
  Pa T[(1<<21)+1];
  int p[1001*1001+1];
  map<int,bool> f;
  int n;

  //節点の番号、追加する要素の区間[fi、se)
  void update(int k,int fi,int se){
    k=k+(n/2)-1;
    T[k].first=mmin(fi,T[k].first);
    T[k].second=mmax(se,T[k].second);
    while(k>0){//登りながら更新
      k=(k-1)/2;
      T[k].first=mmin(fi,T[k].first);
      T[k].second=mmax(se,T[k].second);
    }
  }

  void init(){//ツリー構築

    int ind=0;
    //P[i]+P[j]の足し算の結果を格納
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
	p[ind++]=P[i]+P[j];
      }
    }
    //最後にINFを付加
    p[N*N]=INF;

    //昇順ソート
    sort(p,p+N*N+1);
    unique(p,p+N*N+1);

    int _n;
    for(int i=0;i<N*N+1;i++){
      if(p[i]==INF){ _n=i+1; break;}
    }

    //nを2^mに
    n=1;
    while( n < _n*2 ) n*=2;
    
    //木を全て(INF~0)に初期化
    for(int i=0;i<n;i++){
      T[i]=Pa(INF,0);
    }

    //葉を追加
    for(int i=0;i<_n-1;i++){
      update(i,p[i],p[i+1]);
    }  
  }

  //値aより小さくもっと大きい数字は何か探す
  int search(int a){
    return query(0,a);
  }

  //区間[T[k].first,T[k].second)にaあるか否か
  int query(int k,int a){
    if(k>=n/2-1)
      return T[k].first;
    if(T[k].first<=a && a<T[k].second){
      int v=query(k*2+1,a);//左の葉
      if(v==-1)
	v=query(k*2+2,a);//右の葉
      return v;
    }
    return -1;
  }
  int size(){ return n;}
  void view(){
    printf("size=%d\n",this->size());
    int r=1;
    for(int i=0;i<n;i++){
      if(i==r){puts(""); r=(r+1)*2-1;}
      printf(" [%2d,%2d) ",T[i].first,T[i].second);
    }
  }

};

Segment S;

main(){

  /*   clock_t start,end;
       start=clock();//計測*/
  while(1){
    scanf("%d %d",&N,&M);
    if(!N && !M) break;
    for(int i=0;i<N;i++){
      scanf("%d",&P[i]);
    }
    P[N]=0;
    ++N;
    S.init();
    //    S.view();
    //    printf("%d=size\n",S.size());
    


    int res=0;
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
	int m=M-P[i]-P[j];
	if(m<0) continue;
	m-=S.search(m);
	res = max(res,M-m);
      }
    }
    /*   //時間を図り終える
	 end=clock();
	 printf("%.2f秒かかりました\n",(double)(end-start)/CLOCKS_PER_SEC);
    */

    printf("%d\n",res);
  }
}

Measured memory_bytes: 21344
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define PI 3.1415926535897932384626433832795
using namespace std;
 
int main(){
    string s;
    cin>>s;
    int start, end;
    start= 0;
    end=s.length()-1;
    int n = s.length();
    int ans =0;
    while (start < end){
        if(s[start]==s[end]){
            start++;
            end--;
        }
        else{
            cout<<"No";
            
            ans=-1;
            goto END;
            break;
        }
    }
    start= 0;
    end= ((n-1) /2) -1;
    while (start < end){
        if(s[start]==s[end]){
            start++;
            end--;
        }
        else{
            cout<<"No";
            
            ans=-1;
            goto END;
            break;
        }
    }
    start=((n+3)/2)-1;
    end=n-1;
    while (start < end){
        if(s[start]==s[end]){
            start++;
            end--;
        }
        else{
            cout<<"No";
            
            ans=-1;
            goto END;
            break;
        }
    }
    if(ans!=-1){
        cout<<"Yes";
    }
    END:
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#include <limits>
#include <iomanip>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int A,B,C;
    cin >> A >> B >> C;
    vector<int>  surplus;
    for(int i=1;i<B;i++){
        int num;
        num = (A*i)%B;
        if(num>0){
        surplus.push_back(num);
        }
    }
    bool frg = false;
    for(int i=0;i<surplus.size();i++){
        if(C%surplus[i]==0){
            frg = true;
            break;
        }
    }
    if(frg){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

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

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

using namespace std;

int main(){
  ll n,k;cin>>n>>k;
  ll r,s,p;cin>>r>>s>>p;
  string t;cin>>t;
  rep(i,t.size()){
    if(t[i]=='r')t[i]='p';
    else if(t[i]=='s')t[i]='r';
    else if(t[i]=='p')t[i]='s';
  }

  map<char, int>point;
  point['r']=r;
  point['s']=s;
  point['p']=p;

  int result=0;
  rep(i, k){
    char ch =t[i];
    result += point[ch];
    rep(j, t.size()/k+1){
      int index = i+(j+1)*k;
      if(index<t.size()){
        if(ch!=t[index]){
          result+=point[t[index]];
          ch=t[index];
        }else{
          ch='x';
        }
      }
//cout<<result<<endl;
    }
  }

  cout<<result;

  return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        if (x < a || a + b < x) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }
}


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

int main()
{
    int n, m, li, ri;
    cin >> n >> m;
    int l = 1, r = n;
    for(int i = 0; i < m; i++){
        cin >> li >> ri;
        if(li > l) l = li;
        if(ri < r) r = ri;
    }
    cout << (r < l ? 0 : r - l + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll n, m, l;
  cin >> n >> m >> l;
  vector<vector<ll> > foo(n, vector<ll>(m, 0));
  vector<vector<ll> > bar(m, vector<ll>(l, 0));
  vector<vector<ll> > ans(n, vector<ll>(l, 0));
  rep (i, n) rep (j, m) cin >> foo[i][j];
  rep (i, m) rep (j, l) cin >> bar[i][j];

  rep(i, n) rep(j, l) rep(k, m) ans[i][j] += foo[i][k] * bar[k][j];

  rep(i, n) {
    bool flag = false;
    rep(j, l) {
      if (flag) cout << " ";
      flag = true;
      cout << ans[i][j];
    }
    cout << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
int main()
{
	ll x,y;
	cin>>x>>y;
	int cnt=0;
	while(x<=y)
	{
		cnt++;
		x*=2;
	}
	cout<<cnt;
}


Measured memory_bytes: 3644
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n >=30) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35620
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    int n, k; cin >> n >> k;

    vi v(n);
    rep (i, 0, n-1) cin >> v[i];

    sort(v.begin(), v.end());

    int res = 0;
    rep (i, 0, k-1) res += v[i];
    cout << res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>

using namespace std;

int search(int n) {
    int right = 0;
    int ord = 1;
    int ans = 0;
    while(n > 0) {
        right += ord * (n % 10);
        ord *= 10;
        n /= 10;
        ans = max(ans, n*right);
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int Q;
    cin >> Q;
    while(Q--) {
        int N;
        cin >> N;
        int cnt = 0;
        while(N >= 10) {
            N = search(N);
            ++cnt;
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int X, Y, Z, K;
  while (cin >> X >> Y >> Z >> K) {
    vector<ll> A(X), B(Y), C(Z);
    for (int i = 0; i < X; i++) cin >> A[i];
    for (int i = 0; i < Y; i++) cin >> B[i];
    for (int i = 0; i < Z; i++) cin >> C[i];
    vector<ll> pairs;
    for (ll a : A)
      for (ll b : B) 
        pairs.push_back(a + b);
    sort(pairs.rbegin(), pairs.rend());
    if (pairs.size() > K) pairs.resize(K);
    vector<ll> cand;
    for (ll c : C) 
      for (ll p : pairs)
        cand.push_back(c + p);
    sort(cand.rbegin(), cand.rend());
    for (int i = 0; i < K; i++) cout << cand[i] << endl;
  }
  return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A+B == C+D){
    cout << "Balanced" << endl;
  }
  else if (A+B > C+D) {
    cout << "Left" << endl;
  }
  else if (A+B < C+D){
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n, m, k;
string str[1100];

int J[1100][1100], O[1100][1100], I[1100][1100];

int main() {
    while (cin >> n >> m >> k) {
        for (int i = 0; i < n; ++i) cin >> str[i];
        memset(J, 0, sizeof(J));
        memset(O, 0, sizeof(O));
        memset(I, 0, sizeof(I));
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < m; ++j) {
                if (str[i][j] == 'J') J[i+1][j+1] = 1;
                if (str[i][j] == 'O') O[i+1][j+1] = 1;
                if (str[i][j] == 'I') I[i+1][j+1] = 1;
            }
        
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < m; ++j) {
                //cout << i << ", " << j << " : " << J[i][j] << ", " << O[i][j] << ", " << I[i][j] << endl;
                J[i+1][j+1] += J[i+1][j] + J[i][j+1] - J[i][j];
                O[i+1][j+1] += O[i+1][j] + O[i][j+1] - O[i][j];
                I[i+1][j+1] += I[i+1][j] + I[i][j+1] - I[i][j];
            }
        
        for (int i = 0; i < k; ++i) {
            int a, b, c, d;
            cin >> a >> b >> c >> d;
            int x = J[c][d] - J[a-1][d] - J[c][b-1] + J[a-1][b-1];
            int y = O[c][d] - O[a-1][d] - O[c][b-1] + O[a-1][b-1];
            int z = I[c][d] - I[a-1][d] - I[c][b-1] + I[a-1][b-1];
            cout << x << " " << y << " " << z << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 16432
#include "bits/stdc++.h"
#define rep(i,N) for (int (i) = 0; (i) < (N); (i)++)

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);

	int X, A, B; std::cin >> X >> A >> B;
	std::cout << (X - A) % B;

	return 0;
}

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

using namespace std;

int main()
{
    long long r,d,x,y;
    cin>>r>>d>>x;
    for(int i=0; i<10; i++)
    {
        y=r*x-d;
        x=y;
        cout<<y<<"\n";
    }
    return 0;
}

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

int main(){

  int n, s,  min, max;
  int total;
  while(cin >> n){
    total = 0;

   if(n == 0) break;

    for(int i=0; i<n; i++){
      cin >> s;
      if(i == 0){
	min = s;
	max = s;
      }
      if(s < min) min = s;
      if(s > max) max = s;
      total += s;
    }
    cout << (total-min-max)/(n-2) << endl; 
  }
  return 0;
}

Measured memory_bytes: 0
//#include "bits/stdc++.h"

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

using uint = unsigned int;

const uint s = 1.E6;

uint ans[s];
uint ans_odd[s];

inline uint regularTetrahedronNum(uint n) {
	return n * (n + 1) * (n + 2) / 6;
}

inline void update(uint rt_num) {
	for (uint i = rt_num; i < s; i++) {
		ans[i] = min(ans[i], ans[i - rt_num] + 1);
	}
	if (rt_num % 2 == 0) {
		return;
	}
	for (uint i = rt_num; i < s; i++) {
		ans_odd[i] = min(ans_odd[i], ans_odd[i - rt_num] + 1);
	}
}

void print() {
	std::cout << "debug " << std::endl; // debug
	for (uint i = 0; i < s; i++) {
		cout << i << ": " << ans[i] << " " << ans_odd[i] << endl;
	}
}

int main() {
	for (uint i = 0; i < s; i++) {
		ans[i] = i;
		ans_odd[i] = i;
	}
	for (uint i = 2; i < s; i++ ) {
		auto num = regularTetrahedronNum(i);
		if (num > s) {
			break;
		}
		update(num);
	}

	//print();
	while (true) {
		uint tmp;
		cin >> tmp;
		if (tmp == 0) {
			break;
		}
		cout << ans[tmp] << " " << ans_odd[tmp] << endl;

	}

	//std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}

Measured memory_bytes: 10804
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 1000010
 
int main(){
	IOS;
	tihs;
	
	ll h,n;cin>>h>>n;
	ll a[n];
	rep(i,0,n)cin>>a[i];
	sort(a,a+n);
	bool ok=0;
	for(ll i=n-1;i>=0;--i){
		h-=a[i];
	}
	if(h<=0)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

const long long INF = 1LL << 60;

int main() {
    int n; cin >> n;
    map<string, int> mp;
    vector<string> S;
    rep(i, n){
        string s;
        cin >> s;
        S.push_back(s);
        mp[s]++;
    }

    int mx = 0;
    rep(i, n){
        mx = max(mp[S.at(i)], mx);
    }
    
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if(itr->second == mx) cout << itr->first << endl;
    }
    return 0;
}

Measured memory_bytes: 26736
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>

using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	string s;
	cin >> s;
	if (s == "ABC")  cout << "ARC" << endl;
	else  cout << "ABC" << endl;
}


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

int N;
char S[1000005];
int A[1000005];
void Read(){
    cin >> N;
    cin.get();
    cin.getline(S + 1, 1000005);
    for(int i = 1; i <= N; i++)
        A[i] = S[i] - '0';
}
inline int mod(int x){
    return x > 0 ? x : -x;
}
void firstStep(){
    for(int i = 1; i < N; i++){
        A[i] = mod(A[i + 1] - A[i]);
    }
    --N;
}

int combParity(int n, int k){
    if(n < k)
        return 0;
    return ((n & k) == k);
}

int resultParity(){
    int res = 0;
    for(int i = 1; i <= N; i++){
        if(A[i] & 1){
            res ^= combParity(N - 1, i - 1);
        }
    }
    return res;
}

void Solve(){
    if(resultParity()){
        cout << "1\n";
        return;
    }
    int last2 = 0;
    for(int i = N; i >= 1; i--)
        if(A[i] == 2){
            last2 = i;
            break;
        }
    if(last2 == 0){
        cout << "0\n";
        return;
    }
    for(int i = N; i > 0; i--){
        if(A[i] == 1){
            cout << "0\n";
            return;
        }
    }
    for(int i = 1; i <= N; i++){
        if(A[i] == 2)
            A[i] = 1;
    }
    if(!resultParity()){
        cout << "0\n";
    }
    else{
        cout << "2\n";
    }
}
int main()
{
    Read();
    firstStep();
    Solve();
    return 0;
}


Measured memory_bytes: 5120
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define double         long double
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
    int x = 1;
    while (b)
    {
        if (b & 1) x *= a;
        a *= a;
        b >>= 1;
    }
    return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

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

const int N = 200005;
int a[N], n, m, k;
int dp[N];

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

    for (int i = k - 1; i >= 0; i--)
    {
        int cnt = 0;
        for (int j = 0; j < n; j++)
        {
            if (!dp[i + a[j]] && i + a[j] <= k)
                cnt++;
        }
        if (cnt)
            dp[i] = 1;
    }
    if (dp[0])
        cout << "First";
    else
        cout << "Second";

}

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

    cout << setprecision(9) << fixed;
    clock_t z = clock();
    solve();
    cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

    return 0;
}

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

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

	sort(a.begin(), a.end());

	int cur = -1, cnt, ans = 0;

	for(int i=0;i<n;i++) {
		if(cur != a[i]) {
			if(cnt < cur) ans += cnt;
			cur = a[i];
			cnt = 1;
		}
		else {
			cnt++;
			if(cnt > cur) ans++;
		}
	}

	if(cnt < cur) ans += cnt;

	cout << ans << endl;
}


Measured memory_bytes: 640
n = int(input())

now_t = 0
now_xy = 0
for i in range(n):
    t, x, y = map(int, input().split())
    baf = 0
    if not abs((x+y) - now_xy) == t - baf*2 - now_t:
        while t-baf*2-now_t >= 2:
            baf += 1
            if abs((x+y) - now_xy) == t - baf*2 - now_t:
                break
        else:
            print("No")
            exit()
    now_t = t
    now_xy = x + y
print("Yes")


Measured memory_bytes: 9068