akhauriyash/Code-Regression huggingface dataset:
// Standard Stuff
#include <bits/stdc++.h>
using namespace std;

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream& os, const set<T>& v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const map<T,S>& v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "Trace On! (Line: " << __LINE__ << ")\n"; d_f(string(#args), args); } while(0)
	void d_f(__attribute__((unused)) string str) {}
	template<typename Head, typename... Tails> void d_f(string str, Head H, Tails... T) { cerr << "\t" << str.substr(0, str.find(", ")) << " <=> [" << H << "]\n"; d_f(str.substr(str.find(", ") + 2), T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

void solve(){
	int n;
	cin >> n;
	cout << (n % 1000 ? 1000 - n % 1000 : 0) << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3620
length = int(input())
List = list(map(int, input().split()))

minimum = List[0]
count = 0

for i in range(length):
    minj = i
    for j in range(i,length):
        if List[j] < List[minj]:
            minj = j
    if List[minj] != List[i]:
        minimum = List[minj]
        List[minj] = List[i]
        List[i] = minimum
        count += 1

print(*List)
print(count)


Measured memory_bytes: 5600
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

#define mask (0xFF)
int cnt[mask];

int main(){
  int n;
  while(n = getInt()){
    int ans = -1;
    int i;
    const int n2 = n / 2;

    memset(cnt, 0, sizeof(cnt));

    for(i = 0; i < n; i++){
      int a = getInt();
      int m = a & mask;
      if(++cnt[m] > n2){
	ans = a;
	for(++i; i < n; i++)
	  getInt();
      }
    }

    if(ans == -1)
      puts("NO COLOR");
    else
      printf("%d\n", ans);
  }
  return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m[ohara],h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
  
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>n;
      map<pair<ll,ll>,ll> mp;
      rep(i,n){
        cin>>m[i];
        rep(j,m[i]){
          cin>>a;
          mp[{i,j}]=a;
        }
      }
      priority_queue<ll> que;
      rrrep(i,n-1,0){
        rep(j,m[i]){
          que.push(mp[{i,j}]);
        }
        ans+=que.top();
        que.pop();
      }
      Cout(ans);
    

    
       
return 0;
}



Measured memory_bytes: 25492
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
const int INF=1e+9;
const ll INFLL=1e+17;
int n;
std::string S[51];
int num[51][26];
void solve(){
  fill(num,0);
  rep(i,n){
    int ss=S[i].size();
    rep(j,ss){
      num[i][(int)(S[i][j]-'a')]++;
    }
  }
  int res[26];
  rep(j,26){
    int min=INF;
    rep(i,n){
      min=std::min(min,num[i][j]);
    }
    res[j]=min;
  }
  //  rep(i,26){
  //    std::cout<<res[i];
  //  }
  rep(i,26){
    rep(j,res[i]){
      std::cout<<(char)(i+'a');
    }
  }
  std::cout<<"\n";
}
int main(){
  cin>>n;
  rep(i,n) cin>>S[i];
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;
typedef pair<long, long> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<long> &av, vector<long> &bv)
{
        long n = av.size();
        vector<pair_t> p(n);
        vector<long> av2(n), bv2(n);
        for (long i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (long i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}

int main() {
    long n, m, mon=0;
    cin >> n >> m;
    vector<long> a(n), b(n);
    for(int i=0; i<n; i++) {
        cin >> a[i] >> b[i];
    }
    sort2vectors(a, b);
    long min_i = 0;
    while(m > 0) {
        if(m - b[min_i] > 0) {
            mon += b[min_i] * a[min_i];
        } else {
            mon += m * a[min_i];
        }
        m -= b[min_i];
        a[min_i] = LONG_MAX;
        min_i++;
    }
    cout << mon << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  vector<string> date ={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  for(int i=0; i<7; i++){
    if(S == date.at(i)){
      cout << 7 - i << endl;
    }
  }
}


Measured memory_bytes: 256
var
  a:array[1..10000] of longint;
  i,j,t,n,m,s:longint;
begin
  readln(n,m);
  for i:=1 to n do
    read(a[i]);
  for i:=1 to n-1 do
  for j:=i+1 to n do 
    if a[i]<a[j] then
    begin
      t:=a[i];
      a[i]:=a[j];
      a[j]:=t;
    end;
  for i:=1 to m do
    s:=s+a[i];
  writeln(s);
end.



Measured memory_bytes: 128
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input=lambda :sys.stdin.readline().rstrip()


X,Y,A,B,C=map(int,input().split())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
R=list(map(int,input().split()))
lst=[]
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort()

while len(P)>X:
    P.pop()
while len(Q)>Y:
    Q.pop()

flag=1
while flag:
    if not R:
        break

    flag=0
    if P and Q:
        if P[-1]<Q[-1]:
            if P[-1]<R[-1]:
                P.pop()
                lst.append(R.pop())
                flag=1
        else:
            if Q[-1]<R[-1]:
                Q.pop()
                lst.append(R.pop())
                flag=1
    else:
        if P:
            if P[-1]<R[-1]:
                P.pop()
                lst.append(R.pop())
                flag=1
        elif Q:
            if Q[-1]<R[-1]:
                Q.pop()
                lst.append(R.pop())
                flag=1

for i in range( X+Y-(len(P)+len(Q)+len(lst))):
    if R:
        lst.append(R.pop())
    else:
        break
print(sum(P)+sum(Q)+sum(lst))


Measured memory_bytes: 119848
#include<bits/stdc++.h>
using namespace std;
typedef       long long int      ll;
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);
#define       optimize           ios::sync_with_stdio(0);cin.tie(0);
#define       RESET(a, b)        memset(a, b, sizeof(a))
#define       gcd(a, b)          __gcd(a, b)
#define       MX                 300005
#define       MOD               1000000007
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }
/*bool cmp(ll x,ll y)
{
   return x>y;
}*/
bool cmp(pair<int,int>a, pair<int,int>b)
{
   if(a.first==b.first)
      return a.second<b.second;
   else
      return a.first<b.first;
}
int main(void)
{
   optimize
   ll t,n,m,k,x,y,a[200001];
   vector<ll> v,v1,v2;
   vector< pair<ll,ll> > p,p1,p2;
   set<ll> st;
   priority_queue<ll> pq;
   priority_queue< ll,vector<ll>,greater<ll> > lpq;
   priority_queue< pair<ll,ll> > phpq;
   priority_queue< pair<ll,ll>,vector< pair<ll,ll> >,greater< pair<ll,ll> > > plpq;
   string s;
   //cin>>t;
   //while(t--)
   //{
      cin>>n;
      if(n)
         cout<<0;
      else
         cout<<1;
   //}
   return 0;
}


Measured memory_bytes: 3576
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int strsortfncsj(const void *a,const void *b){return strcmp((char *)a,(char *)b);}
int strsortfnckj(const void *a,const void *b){return strcmp((char *)b,(char *)a);}

int main(void){
    int i,j,n,m,k,a[262144],b,c,w,r=0,l,t;
    double d;
    char s[262144];
    scanf("%d",&n);
    //l=strlen(s);
    //for(i=0;i<n;i++){scanf("%d",&a[i]);}
    //qsort(a,n,sizeof(int),sortfncsj);
    printf("%d\n",n/3);
    return 0;
}

Measured memory_bytes: 128
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    A, P = map(int, input().split())
    print((A*3+P)//2)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc128","a",main)

Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

// //dijkstraの負も出来る版
// //O(V*E)  V:頂点数,E:辺の数
// //close=trueの時、負の閉路に到達
// using T=tuple<int,int,int>;
// const int MAX_dist=1e9;
// vector<T> graph(0);//from,to,cost
// vector<int> d(0);
// int V,E;//V:頂点数,E:辺の数
// bool close=false;

// void init(int n){//辺をgraphに入れた後に
//     d.resize(n,MAX_dist);
//     V =n;
// }

// void Bellman(int s){//s:始点
//     E=graph.size();
//     d[s]=0;
//     int close_cnt=0;
//     close=false;
//     while(1){//V回以上のループで負閉路に到達
//         close_cnt ++;
//         bool update=0;
//         for(auto e: graph){
//             int from,to,cost;
//             tie(from,to,cost)=e;
//             if(d[from]!=MAX_dist && d[to]>d[from]+cost){
//                 update =true;
//                 d[to]=d[from]+cost;
//             }
//         }
//         if(!update) break;
//         if(close_cnt==V){ close=true;break;}
//     }
// }

//dijkstraの負も出来る版
//O(V*E)  V:頂点数,E:辺の数
//close=trueの時、負の閉路に到達
using T=tuple<int,int,int>;
const int MAX_dist=1e9;
vector<T> graph(0);//from,to,cost
vector<int> d(0);
int V,E;//V:頂点数,E:辺の数
bool close=false;

void init(int n){//辺をgraphに入れた後に
    d.resize(n,MAX_dist);
    V =n;
}

void Bellman(int s){//s:始点
    E=graph.size();
    d[s]=0;
    int close_cnt=0;
    close=false;
    while(1){//V回以上のループで負閉路に到達
        close_cnt ++;
        bool update=0;
        for(auto e: graph){
            int from,to,cost;
            tie(from,to,cost)=e;
            if(d[from]!=MAX_dist && d[to]>d[from]+cost){
                update =true;
                d[to]=d[from]+cost;
            }
        }
        if(!update) break;
        if(close_cnt==V){ close=true;break;}
    }
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int v,e,r;
    cin>>v>>e>>r;
    init(v);
    int s,t,c;
    rep(i,e){
        cin>>s>>t>>c;
        graph.emplace_back(s,t,c);
    }
    Bellman(r);
    if(close) cout<<"NEGATIVE CYCLE"<<endl;
    else{
        rep(i,v){
            if(d[i]==MAX_dist) cout<<"INF"<<endl;
            else cout<<d[i]<<endl;
        }
    }
}


Measured memory_bytes: 3216
#include <stdio.h>
#define N 100
#define M 100
#define L 100
int main(void)
{
	int n, m, l, i, j, k;
	int A[N][M];
	int B[M][L];
	long  c;
	scanf("%d%d%d", &n, &m, &l);
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			scanf("%d", &A[i][j]);
		}
	}
	for(i=0; i<m; i++){
		for(j=0; j<l; j++){
			scanf("%d", &B[i][j]);
		}
	}
	for(i=0; i<n; i++){
		for(j=0; j<l; j++){
			c=0;
			for(k=0; k<m; k++){
				c += A[i][k] * B[k][j];
			}
			printf("%ld", c);
			if(j < l-1){
				printf(" ");
			}else{
				puts("");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 696
#include<cstdio>

const int MAX_S = 19;

char s[MAX_S];

int main(){
	scanf("%s",s);
	
	for(int i = 0;s[i] != '\0';i++){
		if(s[i] == ',') s[i] = ' ';
	}
	
	printf("%s\n",s);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define maxn 55
char s[maxn][maxn];
char x[maxn][maxn];
int main(){
	int m, n, i, j, cnt;
	scanf("%d %d", &m, &n);
	getchar();
	for (i = 0; i < m; i++){	
		for (j = 0; j < n; j++){
			s[i][j] = getchar();

		}
		getchar();
	}
	for (i = 0; i < m; i++)
		for (j = 0; j < n; j++){
			if (s[i][j] != '#'){
				if (i >= 1 && j >= 1){	
					if (s[i - 1][j - 1] == '#')
						cnt++;
				}
				if (i >= 1){	
					if (s[i - 1][j] == '#')
						cnt++;
				}
				if (i >= 1 && j <= (n - 2)){	
					if (s[i - 1][j + 1] == '#')
						cnt++;
				}
				if (j >= 1){	
					if (s[i][j - 1] == '#')
						cnt++;
				}
				if (j <= (n - 2)){	
					if (s[i][j + 1] == '#')
						cnt++;
				}
				if (i <= (m - 2) && j >= 1){	
					if (s[i + 1][j - 1] == '#')
						cnt++;
				}
				if (i <= (m - 2)){	
					if (s[i + 1][j] == '#')
						cnt++;
				}
				if (i <= (m - 2) && j <= (n - 2)){	
					if (s[i + 1][j + 1] == '#')
						cnt++;
				}
				x[i][j] = cnt + '0';
				cnt = 0;
			}
			if (s[i][j] == '#'){
				x[i][j] = '#';
			}
		}
	for (i = 0; i < m; i++){	
		for (j = 0; j < n; j++){
			putchar(x[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

ll pub_count[60];
ll patty_count[60];

void init_count(ll N) {
    for (int i = 0; i <= N; ++i) {
        pub_count[i] = -3 + 4 * pow(2, i);
        patty_count[i + 1] = patty_count[i] * 2 + 1;
    }
}

ll solve(ll N, ll X) {
    if (N == 0)
        return (X <= 0 ? 0 : 1);
    else if (X <= 1 + pub_count[N - 1]) return solve(N - 1, X - 1);
    else return 1 + patty_count[N - 1] + solve(N - 1, X - 2 - pub_count[N - 1]);
}

int main() {
    ll N, X; cin >> N >> X;
    patty_count[0] = 1;
    init_count(N);
    cout << solve(N, X) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;
int N,L;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin >> N;
    vector<vector<int>> g(N);
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<int> q;
    q.push(0);
    vector<int> v(N),dist(N);
    v[0] = 1;
    while(!q.empty()){
        int now = q.front();q.pop();
        for(auto x:g[now]){
            int next = x;
            if(v[next])continue;
            v[next] = 1;
            dist[next] = dist[now] + 1;
            q.push(next);
        }
    }
    int mx = 0;
    int p = 0;
    rep(i,N){
        if(mx < dist[i]){
            mx = dist[i];
            p = i;
        }
    }
    v = vector<int>(N,0);
    dist = vector<int> (N,0);
    q.push(p);
    v[p] = 1;
    while(!q.empty()){
        int now = q.front();q.pop();
        for(auto x:g[now]){
            int next = x;
            if(v[next])continue;
            v[next] = 1;
            dist[next] = dist[now] + 1;
            q.push(next);
        }
    }
    rep(i,N) L = max(L,dist[i]);
    if(L%3!=1)cout << "First" << endl;
    else cout << "Second" << endl;
}

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

vector<int> g[100001];
int height[100001];

int main(){
    ios_base::sync_with_stdio(false),cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
        cin>>height[i];
    
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
        --a;--b;
		g[a].push_back(b);
        g[b].push_back(a);
	}
	int ans = 0;
    for(int i=0;i<n;i++){
        int f = 0;
        for(auto x:g[i]){
            //cout<<x<<" ";
            if(height[x] >= height[i]){
                f = 1;
                break;
            }
        }
        if(f == 0)
            ans++;
    }
	cout<<ans<<endl;
	
}

Measured memory_bytes: 9100
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void Yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };

void solve() {
    int N;
    ll T;
    cin >> N >> T;
    vll t(N);
    rep(i,N){
        cin >> t[i];
    }

    ll ans = T;
    ll before = 0LL;
    ll diff;
    rep(i,N){
        diff = t[i] - before;
        if(diff <= T) ans += diff;
        else ans += T;
        before = t[i];
    }

    print(ans);
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

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

int main() {
	// your code goes here
	int n,k;
	cin >> n >> k;
	int i[n];
	for(int j=0;j<n;j++){
		cin >> i[j];
		
		
	}
	sort(i,i+n);
	
	
	int anskgy=0;
	for(int j=n-k;j<n;j++){
		anskgy=anskgy+i[j];
	}
	cout << anskgy << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
// D - Semi Common Multiple
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

int main(){
	int N,M; cin>>N>>M;
	int T = -1;
	ll L = 1;
	while(N--){
		int a; cin>>a;
		int t; for(t=0; !(a&1); t++) a>>=1;
		if((T>0 && t!=T) || (L=lcm(L, a)) > M){ puts("0"); return 0; }
		T = t;
	}
	cout<< ((M>>(T-1))/L+2-1)/2 <<endl;
}

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

int main() {
  int N;
  cin >> N;
  bool possible = false;
  for (int i=0; i<26; i++) { 
    for (int j=0; j<15; j++) {
      if (4*i+7*j == N) {
        possible = true;
        break;
      }
    }
    if (possible) {
      break;
    }
  }
  if (possible) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

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

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}


ll digit(ll num){
	ll ret=0;
	string s=to_string(num);
	return s.length();
}
	
class Edge{
public:
	ll num;
	ll a;
	ll b;
	ll color=0;
	Edge(ll _num,ll _a,ll _b){
		num=_num;
		a=_a;
		b=_b;
	}
};
	
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll N;
	cin>>N;
	
	vector<ll>A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	
	vector<ll>l(N+1);
	vector<ll>r(N+1);
	
	l[0]=0;
	r[N]=0;
	for(int i=0;i<N;i++)l[i+1]=gcd(l[i],A[i]);
	for(int i=N;i>0;i--)r[i-1]=gcd(r[i],A[i-1]);
	
	/*for(int i=0;i<=N;i++)cout<<l[i]<<" ";
	cout<<endl;
	for(int i=0;i<=N;i++)cout<<r[i]<<" ";
	cout<<endl;*/
	
	ll ans=0;
	for(int i=0;i<N;i++){
		ans=max(ans,gcd(l[i],r[i+1]));
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Math;

class Pohe {
    static void Main() {
	var n = int.Parse(ReadLine());

	long x = 1;
	long y = 1;

	foreach (var i in Range(0, n)) {
	    var l = ReadLine().Split();
	    var t = long.Parse(l[0]);
	    var a = long.Parse(l[1]);

	    var m = Max((x - 1) / t, (y - 1) / a) + 1;
	    x = m * t;
	    y = m * a;
	}


	WriteLine("{0}", x + y);
    }
}


Measured memory_bytes: 2904
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,num=0;
    string a,b,c;
    cin>>n>>a>>b>>c;
    for(int i=0;i<n;i++){
        if(a[i]==b[i]){
            if(a[i]!=c[i]){
                num+=1;
            }
        }
        else{
            if(a[i]==c[i]){
                num+=1;
            }
            else{
                if(b[i]==c[i]){
                    num+=1;
                }
                else{
                    num+=2;
                }
            }
        }
    }
    cout << num<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define N_MAX 200000
#define INF 1145141919
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;

int i, j;

int n, m;
int k;

int h, w;

char str[N_MAX];

void solve(){
	return;
}

int main (void) {
	scanf("%s", str);
	str[5] = str[13] = ' ';
	puts(str);
	return 0;
}




Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a,sum=0;
	cin>>n;
	map<long,long>m;
	map<long,long>::iterator it;

	for(long long i=0;i<n;i++)
	{
		cin>>a;
		sum+=a;
		m[a]++;
	}
	//cout<<sum<<endl;
	/*for(it=m.begin();it!=m.end();it++)
	{
		cout<<it->first<<" "<<it->second<<endl;
	}
	*/
	long long Q;
	cin>>Q;
	while(Q--)
	{
		long long b,c;
		cin>>b>>c;
		sum-=m[b]*b;
		sum+=m[b]*c;
		cout<<sum<<endl;
		m[c]+=m[b];
	//	m.erase(b);
	m[b]=0;
		
	}
	
	
	
}

Measured memory_bytes: 9356
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a; cin >> a;
    string s; cin >> s;
    cout << (a>=3200 ? s : "red") << endl;
    return 0;
}

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

int main(){
	int n; cin >> n;
	int a1, a2 = 0;
	int a; cin >> a; a1 = a;
	int count1 = 1, count2 = 0, count3 = 0;
	for(int i = 0; i < n - 1; ++i){
		cin >> a;
		if(a == a1){
			++count1;
		}else if(!a2 && a != a1){
			++count2;
			a2 = a;
		}else if(a2 == a){
			++count2;
		}else{
			++count3;
		}
	}
	if(!a2){
		cout << ((2 * a1 <= n) || (a1 + 1 == n) ? "Yes\n" : "No\n");
	}else if(count3 || !((a1 - a2 == 1) || (a1 - a2 == -1))){
		cout << "No\n";
	}else{
		if(a1 > a2){
			cout << ((a1 > count2) && (count2 + (a1 - count2) * 2 <= n) ? "Yes\n" : "No\n");
		}else if(a1 < a2){
			cout << ((a2 > count1) && (count1 + (a2 - count1) * 2 <= n) ? "Yes\n" : "No\n");
		}
	}
	return 0;
}

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

int main() {
  int H, W;
  
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  vector<vector<char>> temp(H, vector<char>(W));
  vector<vector<char>> R(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> a.at(i).at(j);
    }
  }
  
  int tempH = 0;
  for (int i = 0; i < H; i++) {
    bool flag = true;
    for(int j = 0; j < W; j++) {
      if (a.at(i).at(j) == '#') {
        flag = false;
        break;
      }
    }
    if (!flag) {
      for(int j = 0; j < W; j++) {
        temp.at(tempH).at(j) = a.at(i).at(j);
      }
      tempH++;
    }
  }
  
  int tempW = 0;
  for (int i = 0; i < W; i++) {
    bool flag = true;
    for(int j = 0; j < tempH; j++) {
      if (temp.at(j).at(i) == '#') {
        flag = false;
        break;
      }
    }
    if (!flag) {
      for(int j = 0; j < H; j++) {
        R.at(j).at(tempW) = temp.at(j).at(i);
      }
      tempW++;
    }
  }
  
  for (int i = 0; i < tempH; i++) {
    for(int j = 0; j < tempW; j++) {
      cout << R.at(i).at(j);
    }
    cout << endl;
  }

}


Measured memory_bytes: 256
N, Y = [int(i) for i in input().split()]
Y //= 1000

# 10x + 5y + z = Y

for x in range(N+1):
    for y in range(N-x+1):
        z = N - x - y
        if Y == 9*x + 4*y + N:
            print(x, y, z)
            quit()

print(-1, -1, -1)


Measured memory_bytes: 3060
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p_list = list(map(int, input().split()))

  for i in range(100):
    if (x-i) not in p_list:
      print(x-i)
      break
    elif (x+i) not in p_list:
      print(x+i)
      break

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

    using namespace std;

    int main(){
        int A,B,C;
        cin >> A >> B >> C;
        if (A==B && A!=C){
            cout << "Yes";
        }else if (A!=B && A==C){
            cout << "Yes";
        }else if (B==C && B!=A){
            cout << "Yes";
        }else{
            cout << "No";
        }
        return 0;
    }



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    string s;
    cin >> s;

    vector<int> a(n + 1);
    for (int i = 0; i < n; i++) {
        a[i + 1] = (s[i] == 'E');
    }
    for (int i = 0; i < n; i++) {
        a[i + 1] += a[i];
    }

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

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	IN(int, n);
	vector<LL> a(n + 1);
	cin >> a;
	
	const LL M = 1e18;
	vector<LL> x(n + 2);
	x[0] = 1;
	inc(i, n + 1) {
		x[i] -= a[i];
		if(x[i] < 0) { OUT(-1); exit(0); }
		x[i + 1] = min(2 * x[i], M);
	}
	x.BA = 0;
	LL ans = 0, s = 0;
	dec(i, n + 1) {
		setmin(s, x[i]);
		s += a[i];
		ans += s;
	}
	OUT(ans);
}


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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll,ll> > vpll;
typedef vector< vector<int> > matrix;

#define SET(Ar,val) memset(Ar,val,sizeof(Ar))
#define rep(i,val,n)  for(int i=val;i<n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LMAX LONG_LONG_MAX
#define LMIN LONG_LONG_MIN
#define IMAX INT_MAX
#define IMIN INT_MIN
#define M 1000000007

/*--------------------------------------------------------------------------------------------------------------------------------*/

template <class T> T modpower(T a,T b,T MOD)
{
    T ans=1;
    while(b!=0)
    {
        if(b%2==1)
        ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b/=2;
    }
    return ans;
}

void init()
{
    ll a,b,c,k;
    cin >> a >> b >> c >> k ;
    ll x = 2ll;
    if(k%x == 0ll)
    {
        cout << (a-b);
    }
    else
    {
        cout << (a-b)*(-1ll);
    }
}

int main()
{
    clock_t time1=clock();
	/*#ifndef ONLINE_JUDGE
	freopen("test.in","r",stdin);
	#else
	//ONLINE_JUDGE
	#endif*/
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    init();
    clock_t time2 = clock();
    cerr <<"Time: " <<(double)(time2-time1)/CLOCKS_PER_SEC <<" seconds" <<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  int n, i, j, a[10], b, c, x;
  while (cin >> n && n > 0) {
    memset(a, 0, sizeof(a));
    c = 0;
    for (i = 0; i < n; i++) {
      b = 0;
      for (j = 0; j < n; j++) {
        scanf("%d", &x);
        printf("%5d", x);
        a[j] += x;
        b += x;
      }
      printf("%5d\n", b);
    }
    for (i = 0; i < n; i++) {
      printf("%5d", a[i]);
      c += a[i];
    }
    printf("%5d\n", c);
  }
  return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
const int M=1e5+10;
int n,ans,a[M];
multiset<int> last;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        auto item=last.lower_bound(a[i]);
        if(item==last.begin())
            ans++,last.insert(a[i]);
        else
        {
            item--;
            last.erase(item);
            last.insert(a[i]);
        }
    }
    printf("%d\n",ans);
    return 0;
}



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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
#define vl vector<ll>
#define Mat(T) vector<vector<T>>

vector<ll> dx = {-1, 1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

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

int main()
{
	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	ll ans = 0;
	if (A >= K) {
		PRINT(K);
	} else if (A+B >= K) {
		PRINT(A);
	} else if (A+B+C >= K) {
		PRINT(A-(K-(A+B)));
	} else {
		PRINT(A-C);
	}
	return 0;
}


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

int main(){
	int N;
	int t = 0,total = 0;
	cin >> N;
	int L[N] = {};
	for(int i = 0;i < N;i++){
		cin >> L[i];
	}
	for(int i = 0;i < N;i++){
		for(int j = i+1;j < N;j++){
			if(L[i] > L[j]){t = L[i];L[i] = L[j];L[j] = t;
			}
		}
	}
	for(int i = 0;i < N-1;i++){
		total += L[i];
	}
	if(L[N-1] < total)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int N, x[301], y[301];

double get_r(double X, double Y) {
  double ret = 0;

  for (int i = 0; i < N; ++i)
    ret = max(ret, (X - x[i]) * (X - x[i]) + (Y - y[i]) * (Y - y[i]));

  return ret;
}

double searchY(double X) {
  double lo = 0, hi = 1000;

  for (int it = 0; it < 1000; ++it) {
    double a = (2 * lo + hi) / 3;
    double b = (lo + 2 * hi) / 3;

    double ra = get_r(X, a);
    double rb = get_r(X, b);

    if (ra < rb)
      hi = b;
    else
      lo = a;
  }

  return get_r(X, lo);
}

double searchX() {
  double lo = 0, hi = 1000;

  for (int it = 0; it < 1000; ++it) {
    double a = (2 * lo + hi) / 3;
    double b = (lo + 2 * hi) / 3;

    double ra = searchY(a);
    double rb = searchY(b);

    if (ra < rb)
      hi = b;
    else
      lo = a;
  }

  return searchY(lo);
}

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

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

  printf("%.10f\n", sqrt(searchX()));

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 	stack<long int>s;
  	string g;
  cin >>g;
  long int a,b;
 while(g!=""){
  if(g=="+"){
    a=s.top();
    s.pop();
    b=s.top();
    s.pop();
    b=a+b;
    s.push(b);
  }
  else if(g=="-"){
    a=s.top();
    s.pop();
    b=s.top();
    s.pop();
    b=b-a;
    s.push(b);
  }
   
  else if(g=="*"){
    a=s.top();
    s.pop();
    b=s.top();
    s.pop();
    b=b*a;
    s.push(b);
  }
  else{long int x=stoi(g);
      s.push(x);
      }
  g="";
  cin >>g;
 } 
 long int ans=s.top();
  cout <<ans<<endl;
  
  
}


Measured memory_bytes: 3176
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main(){

    input!{
        h: usize,
        a: usize,
    }

    if h%a==0{
        println!("{}", h/a);
    } else {
        println!("{}", h/a+1);
    }

}

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int X,Y;
    cin >> X >> Y;

    cout << X + Y/2 << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int a[10], dp[16][16];

bool can() {
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    rep (i, 10) {
        rep (j, 11) if (dp[i][j]) {
            const int pre = i == 0 ? 0 : a[i-1];
            if (a[i] > j) dp[i+1][pre] = 1;
            if (a[i] > pre) dp[i+1][j] = 1;
        }
    }
    rep (i, 11) if (dp[10][i]) return true;
    return false;
}

int main() {
    int T;
    scanf("%d", &T);
    while (T--) {
        rep (i, 10) scanf("%d", a+i);
        puts(can() ? "YES" : "NO");
    }
    return 0;
}

Measured memory_bytes: 0
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl                endl

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int x, int y) {                                                             //return x^y in order(log(y))
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
struct trio {
  T first{};
  T second{};
  T third{};
};
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class BMultiplication2 {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) {
      cin >> A[i];
      if (A[i] == 0) {
        cout << 0 << endl;
        return;
      }
    }
    double now = 1;
    int now2   = 1;
    rep(i, N) {
      if (now > 1e18 / A[i]) {
        cout << -1 << endl;
        return;
      }
      now *= A[i];
      now2 *= A[i];
    }
    if (now2 > (int)1e18) {
      cout << -1 << endl;
      return;
    }
    cout << now2 << endl;
  }
};


signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  BMultiplication2 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3964
<?php
$n = fgets(STDIN);
$t = [0];
$x = [0];
$y = [0];
for($i = 0; $i < $n; $i++){
  list($t[$i + 1], $x[$i + 1], $y[$i + 1]) = explode(' ', fgets(STDIN));
}
$can = true;
for($i = 0; $i < $n; $i++){
  $dt = $t[$i + 1] - $t[$i];
  $dist = abs($x[$i + 1] - $x[$i]) + abs($y[$i + 1] - $y[$i]);
  if($dt < $dist){
    $can = false;
  }
  if($dist %2 !== $dt %2){
    $can = false;
  }
}
echo $can ? 'Yes': 'No';
?>

Measured memory_bytes: 56692
#include <algorithm>
#include <cmath>
#include <chrono>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <random>
#include <string>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
/*---------------------------------------*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int h, w; cin >> h >> w;
  vector<vector<int> > a(h, vector<int>(w));
  REP(i, h) {
    REP(j, w) {
      cin >> a[i][j];
    }
  }

  vector<int> y1(0);
  vector<int> x1(0);
  vector<int> y2(0);
  vector<int> x2(0);
  REP(i, h) {
    REP(j, w) {
      if (a[i][j] % 2 != 0) {
        if (j == w-1) {
          if (i < h-1) {
            ++a[i+1][j];
            y1.push_back(i);
            x1.push_back(j);
            y2.push_back(i+1);
            x2.push_back(j);
          }
        } else if (i == h-1) {
          ++a[i][j+1];
          y1.push_back(i);
          x1.push_back(j);
          y2.push_back(i);
          x2.push_back(j+1);
        } else if (a[i][j+1] % 2 != 0) {
          ++a[i][j+1];
          y1.push_back(i);
          x1.push_back(j);
          y2.push_back(i);
          x2.push_back(j+1);
        } else if (a[i+1][j] % 2 != 0) {
          ++a[i+1][j];
          y1.push_back(i);
          x1.push_back(j);
          y2.push_back(i+1);
          x2.push_back(j);
        } else {
          ++a[i][j+1];
          y1.push_back(i);
          x1.push_back(j);
          y2.push_back(i);
          x2.push_back(j+1);
        }
      }
    }
  }

  cout << y1.size() << "\n";
  REP(i, y1.size()) cout << y1[i]+1 << " " << x1[i]+1 << " " << y2[i]+1 << " " << x2[i]+1 << "\n";
  return 0;
}


Measured memory_bytes: 5224