akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define vll vector <long long>
#define pi 2*acos(0.0)
using namespace std;
const int mod =  1000000007;


void solve(){
  ll sz;
  cin>>sz;
  string s;
  cin>>s;
  ll match = 1;
  char ss = s[0];
  for(ll i = 1;i<sz;i++){
    if(ss==s[i])continue;
    else{
        ss = s[i];
        ++match;
    }
  }
  cout<<match<<endl;
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
    return 0;
}




Measured memory_bytes: 3732
from numpy import*
M=10**9+7
m=lambda:map(int,raw_input().split())
n,k=m()
b=eye(n,n,0,'O')
a=matrix([m()for i in b],'O')
while k:b,a=[b,b*a][k&1],a*a%M;k/=2
print sum(b)%M

Measured memory_bytes: 12308
function Main(arg)
{
  var N = arg.split("\n")[0]-0;
  var A = arg.split("\n")[1].split(" ").map(v => v-0);

  var ans = new Set(A);
  console.log(ans.size == N ? "YES" : "NO");
  return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 44164
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#include <math.h>

int main() {
  string S;
  cin >> S;

  if (S == "ABC") {
    cout << "ARC" << endl;
  }
  else {
    cout << "ABC" << endl;
  }
}


Measured memory_bytes: 3568
#include <iostream>
#include <iomanip>
using namespace std;
int main(void) {
	int l;
	cin >> l;
	long double a = 0, b = 0, c = 0;
	while (l > 0) {
		a += 1.0 / 3.0;
		b += 1.0 / 3.0;
		c += 1.0 / 3.0;
		--l;
	}
	cout << fixed << setprecision(6) << a * b * c;
	return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li sum_e[300300];
li sum_w[300300];

int main() {
    string s;
    cin >> s;
    stringstream ss;
    ss << s;
    li a = 0;
    ss >> a;

    li sum = 0;
    rep(i, sz(s)) {
        sum += s[i] - '0';
    }
    cout << (a % sum == 0 ? "Yes" : "No") << endl;



    return 0;
}

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

int main()
{
    std::ios_base::sync_with_stdio (false);
    int n;
    cin >> n;
    int pre_previous_height, previous_height, height;
    cin >> pre_previous_height;
    if (n == 1){
        cout << 0;
        return 0;
    }
    
    cin >> previous_height;
    if (n == 2){
        cout << abs(previous_height - pre_previous_height);
        return 0;
    }
    int pre_previous_cost, previous_cost, cost;
    pre_previous_cost = 0;
    previous_cost = abs(previous_height - pre_previous_height);
    for (int i = 3; i<= n; ++i){
        cin >> height;
        cost = min(abs(pre_previous_height - height) + pre_previous_cost,
        abs(previous_height - height) + previous_cost);
        pre_previous_cost = previous_cost;
        previous_cost = cost;
        pre_previous_height = previous_height;
        previous_height = height;
    }
    cout << cost;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N;
    scanf("%d",&N);
    double v[N];
    for(int i=0;i<N;i++)
    scanf("%le",&v[i]);

    int a,b;
    double sum,temp;
    
    for(int i=0;i<N-1;i++){
        for(int j=N-1;j>i;j--){
            if(v[j]>v[j-1]){
                temp = v[j];
                v[j] = v[j-1];
                v[j-1] = temp;
            }
        }
    }

    for(int i=N-2;i>-1;i--){
        v[i]=(v[i]+v[i+1])/2;
    }

   // for(int i=0;i<N;i++)
   // printf("%le ",v[i]);
    //printf("\n");

    printf("%.2lf\n",v[0]);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 500030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;


int main()
{
	ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
int n,m;
cin>>n>>m;
cout<<(n*(n-1)+m*(m-1))/2;




}


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

#define FOR(i, begin, end)  \
  for (__typeof(end) i = (begin) - ((begin) > (end));  \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
  
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

int N, K, A, B;
vvi adj;

vi bfs(const vvi& al, int s) {
	queue<int> q;
	vi dist(al.size(),INT_MAX);
	dist[s]=0;
	q.push(s);
	while (!q.empty()) {
		int i=q.front();q.pop();
		for (int j:al[i]) if (dist[j]==INT_MAX) {
			dist[j]=dist[i]+1;
			q.push(j);
		}
	}
	return dist;
}

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

	cin >> N >> K;
	adj.assign(N, vi());
	FOR(i,0,N-1) {
		cin >> A >> B;
		A--; B--;
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	
	int ans = INT_MAX;
	if (K % 2 == 0) {
		FOR(u,0,N) {
			vi d = bfs(adj, u);
			int cnt = count_if(d.begin(), d.end(), [&](int l) { return (l > K/2); });
			ans = min(ans, cnt);
		}
	}
	else {
		FOR(u,0,N) {
			for (int v : adj[u]) {
				vi d1 = bfs(adj, u);
				vi d2 = bfs(adj, v);
				vi d(N);
				FOR(i,0,N) d[i] = min(d1[i], d2[i]);
				int cnt = count_if(d.begin(), d.end(), [&](int l) { return (l > (K-1)/2); });
				ans = min(ans, cnt);
			}
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

const int MXV=10000;
vl G[MXV];
ll score[MXV],seen[MXV];
queue<int> que;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    rep(i,N){
        seen[i]=0;
    }
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    vl c(N);
    ll sum=0;
    rep(i,N){
        cin >> c[i];
        sum+=c[i];
    }
    sort(c.begin(),c.end());
    cout << sum-c[N-1] << endl;
    rep(i,N){
        if(G[i].size()==1){
            seen[i]=1;
            que.push(i);
            break;
        }
    }
    ll now=N-1;
    while(!que.empty()){
        int k=que.front();
        que.pop();
        score[k]=c[now];
        now--;
        rep(i,G[k].size()){
            if(!seen[G[k][i]]){
                seen[G[k][i]]=1;
                que.push(G[k][i]);
            }
        }
    }
    rep(i,N){
        cout << score[i] << (i==N-1?'\n':' ');
    }
}

Measured memory_bytes: 4444
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<set<int>> vst(26);
  string s; cin >> s;
  rep(i, n) vst[s[i]-'a'].insert(i);
  rep(i, 26) vst[i].insert(-1), vst[i].insert(n);
  int q; cin >> q;
  while(q--) {
    int t; cin >> t;
    if(t == 1) {
      int i; char c;
      cin >> i >> c;
      i--;
      vst[s[i]-'a'].erase(i);
      s[i] = c;
      vst[s[i]-'a'].insert(i);
    } else {
      int l, r;
      cin >> l >> r;
      l--; r--;
      int cnt = 0;
      rep(i, 26) {
        if(*(--vst[i].upper_bound(r)) >= *vst[i].lower_bound(l)) cnt++;
      }
      cout << cnt << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 27204
//arc060_c.cpp
//Sat Jun 23 13:19:44 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

ll dptable[51][51][2501];
int n,a;

int main(){

	cin >> n >> a;

	int x[50];
	for (int i=0;i<n;i++){
		cin >> x[i+1];
	}


	for (int j=0;j<=n;j++){
		for (int k=0;k<=n;k++){
			for (int s=0;s<=2500;s++){
				if (j==0 && k==0 && s==0){
					dptable[j][k][s] = 1;
				}else if (j>=1 && s<x[j]){
					dptable[j][k][s] = dptable[j-1][k][s];
				}else if (j>=1 && k>=1 && s>=x[j]){
					dptable[j][k][s] = dptable[j-1][k][s] + dptable[j-1][k-1][s-x[j]];
				}else {
					dptable[j][k][s] = 0;
				}
			}
		}
	}

	ll ans = 0;

	for (int k=1;k<=n;k++){
		ans += dptable[n][k][k*a];
	}

	cout << ans << endl;
}

Measured memory_bytes: 51072
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,q=map(int,input().split())

node=[[] for _ in range(n)]
d=deque()
d.append(0)
for i in range(n-1):
    a,b = map(int,input().split())
    node[a-1].append(b-1)
    node[b-1].append(a-1)
ans=[0]*n
for i in range(q):
    p,x=map(int,input().split())
    ans[p-1]+=x
seen=[0]*n
seen[0]=1
while True:
    if not d:
        break
    i=d.pop()
    for j in node[i]:
        if seen[j]==0:
            d.append(j)
            seen[j]=1
            ans[j]+=ans[i]
print(*ans)

Measured memory_bytes: 105492
#include<stdio.h>
int main()
{
    char s[1000];
    int j=1,i=0,k;
    scanf("%s",s);
    for(i=0; s[i]!='\0';i++)
    {
        j=1;
        for(k=i+1;s[k]!='\0';k++)
        {
            if(s[i]==s[k])
            {
                j++;
                    s[k]='*';
            }
        }
        if(s[i]=='*')
        {
            j=0;
        }
        if(j%2!=0)
        {
           
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
            return 0;
}


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

int main()
{
  int r, D, x0, x1;
  cin >> r >> D >> x0;

  for(int i = 0; i < 10; i++){
    x1 = r * x0 - D;
    cout << x1 << endl;
    x0 = x1;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, k, h[110000];
void solve() {
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> h[i];
		if (h[i] >= k)++h[0];
	}
	cout << h[0] << endl;
	//cout << 1.0 * (a + 1 >> 1) / (a) << endl;
}
int main() {
	solve();

	return 0;
}

Measured memory_bytes: 640
Scanf.(Array.(scanf" %d"@@fun n->
	init n (fun _->scanf" %d"@@fun v->v)
	|> fold_left (fun (c,s,p) v->
		if p=v then (c,s+1,v)
		else (c+s/2,1,v)
	) (0,0,-1)
	|> (fun (c,s,_) -> print_int (c+s/2))))

Measured memory_bytes: 2432
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class BMinorChange {
        public void solve(int testNumber, Scanner s, PrintWriter sout) {
            String word1 = s.next(), word2 = s.next();
            int cnt = 0;
            for (int i = 0; i < word1.length(); i++) {
                if (i < word2.length()) {
                    if (word1.charAt(i) != word2.charAt(i)) cnt++;
                } else cnt++;
            }
            sout.println(cnt);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

    }
}



Measured memory_bytes: 37464
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<pair<int,ll>> ans;
	vector<ll> a(n),b(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	vector<ll> v(n);
	for(int i=0;i<n;i++){
		v[i]=(a[0]^b[(n-i)%n]);
	}
	map<ll,int> mp;
	for(int i=0;i<n;i++){
		if(mp[v[i]]==1){
			ans.push_back(make_pair(i,v[i]));
			continue;
		}
		if(mp[v[i]]==2){
			continue;
		}
		else{
			bool ok=1;
			for(int j=0;j<n;j++){
				if((b[j]^a[(j+i)%n])!=v[i]){
					ok=0;
					break;
				}
			}
			if(ok){
				mp[v[i]]=1;
				ans.push_back(make_pair(i,v[i]));
			}
			else{
				mp[v[i]]=2;
			}
		}
	}
	for(auto p:ans){
		cout << p.first << " " << p.second << endl;
	}
}

Measured memory_bytes: 16512
#include <stdio.h>

int main(){
   int n,k,x,y;scanf("%d %d %d %d",&n,&k,&x,&y);
   int ans;
   if(n>=k)
      ans = k*x+((n-k)*y);
   else 
      ans = x*n;
   printf("%d",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
double n,m,x,y;
int main(){
	cin>>n>>m>>x>>y;
	cout<<n*m/2<<' ';
	if (x==n/2&&y==m/2)
		cout<<1<<endl;
	else
		cout<<0<<endl;
	return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    N %= 10;
    switch (N)
    {
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    default:
        cout << "bon" << endl;
        break;
    }
    return 0;
}


Measured memory_bytes: 3644
def solve(i, m):
    if (i, m) in C:
        return C[(i, m)]
    
    if m == 0:
        C[(i, m)] = True
    
    elif i > n-1:
        C[(i, m)] = False
    
    elif solve(i + 1, m):
        C[(i, m)] = True
    
    elif solve(i + 1, m - A[i]):
        C[(i, m)] = True
        
    else:
        C[(i, m)] = False
    
    return C[(i, m)]
    

n = int(input())
A = list(map(int, input().split())) 
p = int(input())
B = list(map(int, input().split())) 
C = {}
for num in B:
    if solve(0, num):
        print("yes")
    else:
        print("no")
        


Measured memory_bytes: 9584
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

ll pws[maxN];

ll calc(int a, int b) {
	return (pws[a] + pws[b] + MOD - 1) % MOD;
}

ii swp(ii x) {
	swap(x.fi, x.se);
	return x;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int n;
	cin >> n;
	pws[0] = 1;
	for(int i = 1; i <= n; i++) pws[i] = pws[i - 1] * 2 % MOD;
	ll ans = 0;
	int fiz = 0, sez = 0;
	map<ii, int> pos, neg;
	for(int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		if(!a && !b) {
			ans++; continue;
		}
		if(!a) {
			fiz++;continue;
		}
		if(!b) {
			sez++;continue;
		}
		ll divi = __gcd(abs(a), abs(b));
		a /= divi, b /= divi;
		if(a < 0 && b < 0) a *= -1, b *= -1;
		if(a < 0 || b < 0) {
			a = abs(a), b = abs(b);
			neg[ii(a, b)]++;
			pos[ii(b, a)];
		} else {
			pos[ii(a, b)]++;
			neg[ii(b, a)];
		}
	}

	ll mul = calc(fiz, sez);
	assert(pos.size() == neg.size());
	for(auto el: pos)
		mul = mul * calc(el.se, neg[swp(el.fi)]) % MOD;
	mul = (MOD - 1 + mul) % MOD;
	ans = (ans + mul) % MOD;
	cout << ans << '\n';
}



Measured memory_bytes: 30108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int N, K; cin >> N >> K;
    int tmp = 1;
    while(N--){
        if(tmp * 2 < tmp + K){
            tmp *= 2;
        }else{
            tmp += K;
        }
    }
    cout << tmp << endl;

    return 0;
}

Measured memory_bytes: 256
n,x,y = map(int,input().split())
a = [0 for _ in range(n-1)]
def di(i,j):
  if i <= x:
    if j <= (x+y)//2:
      return j-i
    elif j < y:
      return y-j+1+x-i
    else:
      return j-y+1+x-i
  elif i < y:
    if j <= y:
      return min(j-i,y-j+1+i-x)
    else:
      return min(j-i,j-y+1+i-x)
  else:
    return j-i
for i in range(1,n):
  for j in range(i+1,n+1):
    a[di(i,j)-1] += 1
for i in a:
  print(i)

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

struct Sieve {
  int n;
  vector<int> f, primes;

  Sieve(int n = 1) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (long long i = 2; i <= n; ++i) {
      if (f[i] != 0) continue;
      primes.push_back(i);
      f[i] = i;
      for (long long j = i * i; j <= n; j += i) {
        if (f[j] == 0) f[j] = i;
      }
    }
  }

  bool isPrime(int x) { return f[x] == x; }

  map<int, int> factor(int x) {
    map<int, int> mp;
    while (x != 1) {
      mp[f[x]]++;
      x /= f[x];
    }
    return mp;
  }
};

int main(){
  int N; cin >> N;
  const int Amax = 1000000;
  map<int, int> mp;
  rep(i, N) {
    int A; cin >> A;
    mp[A]++;
  }
  int ans = 0;
  vector<int> vec(Amax + 1, -1);
  for (auto p : mp) {
    long long x, t; tie(x, t) = p;
    if (vec[x] != -1) continue;
    if (t == 1) ans++;
    for (long long i = x; i <= Amax; i += x) vec[i] = 1;
  }
  cout << ans << endl;
}


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

int main() {
    int n, t;
    cin >> n >> t;
    int ans = 1000000000;
    int cc, tt;
    for(int i = 0; i < n; i++){
        cin >> cc >> tt;
        if(t >= tt){
            ans = min(ans, cc);
        }
    }
    if(ans == 1000000000){
        cout << "TLE" << endl;
        return 0;
    }
    else{
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(str,input().split()))
b = a[::-1]
b = b[::2]

if n%2 == 0:
  c = a[::2]
else:
  c = a[1::2]
d = b+c

if n >= 2:
  print(' '.join(d))
else:
  print(a[0])

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

int main() {
	int N;
    cin >> N;
    vector<int> Card(N);
    for(int i = 0; i < N; i++){
    	cin >> Card.at(i);
    }
    int Alice = 0;
    int Bob = 0;
    int Max, Max_Index;
    for(int i = 0; i < N; i++){
    	Max = Card.at(i);
        Max_Index = i;
        for(int j = 0; j < N; j++){
        	if(Max < Card.at(j)){
            	Max = Card.at(j);
                Max_Index = j;
            }
        }
        if(i % 2 == 0){
        	Alice += Max;
            Card.at(Max_Index) = -1;
        }else{
        	Bob += Max;
            Card.at(Max_Index) = -1;
        }
    }
    cout << Alice - Bob << endl;
}


Measured memory_bytes: 3612
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {


	string s;

	cin >> s;

	const char* chr = s.c_str();


	string ans = "No";
	if (chr[2] == chr[3]) {
		if (chr[4] == chr[5]) {
			ans = "Yes";
		}
	}

	cout << ans << endl;
}




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

int main() {
    vector<int> N(4);
    cin >> N[0] >> N[1] >> N[2] >> N[3];
    sort(N.begin(), N.end());

    if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

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

inline bool f(int s){
  for(int x=1;x*x<=s;x++){
    if( (s-x) % (2*x+1) == 0)return true;
  }
  return false;
}

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int n;
  cin >> n;
  int ans = 0;
  while(n--){
    int s;
    cin >> s;
    if(!f(s))ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1196
import sys
#input = sys.stdin.buffer.readline

def main():
    s = str(input())
    l = len(s)
    ans = [0 for _ in range(13)]
    MOD = 10**9+7
    ans[0] = 1
    
    for st in s:
        dp = [0 for _ in range(13)]
        for i in range(13):
            dp[(10*i)%13] = ans[i]%MOD
        dp += dp
        if st != "?":
            for i in range(13):
                num = int(st)
                ans[i] = dp[i+13-num]
        else:
            for i in range(13):
                ans[i] = sum(dp[i+4:i+14])
    
    print(ans[5]%MOD)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
import java.util.Scanner;

class Main {

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

        int numberOfCity = sc.nextInt();
        int numberOfRoad = sc.nextInt();

        City[] cities = new City[numberOfCity];

        for (int i = 0; i < numberOfCity; i++) {
            cities[i] = new City();
        }

        for (int i = 0; i < numberOfRoad; i ++) {
            int from = sc.nextInt();
            int to   = sc.nextInt();

            cities[from-1].addRoad();
            cities[to-1].addRoad();
        }

        for(City city : cities) {
            System.out.println(city.getCnt());
        }
    }

    private static class City {
        private int cntRoad;

        public void addRoad() {
            cntRoad ++;
        }

        public int getCnt() {
            return this.cntRoad;
        }
    }
}




Measured memory_bytes: 21844
import sys

ans = []


def main() -> None:
    x, y = [int(next_str()) for _ in range(2)]

    for i in range(4):
        solve(i, x, y)

    print(min(ans))


def solve(i: int, x: int, y: int) -> None:
    global ans
    t = 0

    if i % 2 > 0:
        x *= -1
        t += 1

    if i < 2:
        y *= -1
        t += 1

    if x <= y:
        t += y - x
        ans.append(t)


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(20000000)


def dfs(node, distance):
    for next_node, edge_size in G[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((distance+edge_size) % 2)
            dfs(next_node, distance+edge_size)


N = int(input())

G = [[] for i in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    G[u-1].append([v-1, w])
    G[v-1].append([u-1, w])

ans = [-1]*N
dfs(0, 0)
print(*ans, sep='\n')

Measured memory_bytes: 198152
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

template<typename T>
inline void remax(T& x, T y) { x = max(x, y); }

template<typename T>
inline void remin(T& x, T y) { x = min(x, y); }

// End of template code!
int main() 
{
    buff();
    int r, g, b;
    cin >> r >> g >> b;
    int k;
    cin >> k;
    int need = 0;
    while(g <= r) {
        g *= 2;
        need++;
    }
    while(b <= g) {
        b *= 2;
        need++;
    }
    if(need <= k) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}





Measured memory_bytes: 3636
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();

    let ans = if a > 2 * b { a - 2 * b } else { 0 };

    println!("{}", ans);
}



Measured memory_bytes: 4352
#include<iostream>
#include<complex>
#include<cmath>
#include<cstdio>

#define EPS (1e-8)
using namespace std;


typedef complex<int> P;
inline int dot(P x,P y){
  //return real(conj(x)*y);
  return x.real()*y.real() + x.imag()*y.imag();
}
inline int cross(P a, P b){
  //return imag(conj(x)*y);
  return a.real()*b.imag() - b.real()*a.imag();
}
inline double mabs(P a){
  return sqrt(a.real()*a.real() + a.imag()*a.imag());
}

inline double seg_dis(P &a,P &b,P &x){
  //if(dot(b-a,x-a)<EPS)return mabs(x-a);
  //if(dot(a-b,x-b)<EPS)return mabs(x-b);
  if(dot(b-a,x-a)<0)return mabs(x-a);
  if(dot(a-b,x-b)<0)return mabs(x-b);
  return abs((double)cross(b-a,x-a))/mabs(b-a);
}

inline int ccw(P a,P b,P c){
  b -= a; c-= a;
  if(cross(b,c)>EPS)return 1;
  if(cross(b,c)<-EPS)return -1;
  if(dot(b,c)<-EPS)return 2;
  if(mabs(b)<mabs(c))return -2;
  return 0;
}

inline bool is_cp(P a1,P a2 , P b1,P b2){
  return ccw(a1,a2,b1) * ccw(a1,a2,b2) <= 0 && ccw(b1,b2,a1)*ccw(b1,b2,a2) <=0;
}

int main(){
  int n;
  int num[101][101];
  P a[100000],b[100000];

  for(int i=0;i<=100;i++)
    for(int j=0;j<=100;j++)num[i][j] = 0;

  scanf("%d",&n);

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

  for(int i=0;i<=100;i++)
    for(int j=0;j<=100;j++)
      if(num[i][j]>=2){
	printf("%.8lf\n",0.0);
	return 0;
      }

  double m = 1e+30;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(is_cp(a[i],b[i],a[j],b[j])){m = 0.0;}
      else{
	m = min(m,seg_dis(a[j],b[j],b[i]));
	m = min(m,seg_dis(a[i],b[i],b[j]));
	m = min(m,seg_dis(a[j],b[j],a[i]));
	m = min(m,seg_dis(a[i],b[i],a[j]));
      }
    }
  }

  printf("%.8lf\n",m);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define ALL(a) (a.begin()), (a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define MAXAS(x, v) x = max(x, v)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

#define PI 3.141592653589793

#define MOD 1000000007L
// #define INF 100000000000

#define MAX_V 2000
#define INF 2147483647
//to,cost
typedef pair<long, long> P;

signed main() {
	int n, m;
	cin >> n;
	map<long, int> d = {};
	for (size_t i = 0; i < n; i++) {
		long dd;
		cin >> dd;
		d[dd]++;
	}
	cin >> m;
	long t[m];
	for (size_t i = 0; i < m; i++) {
		cin >> t[i];
	}

	bool ok = true;
	for (size_t i = 0; i < m; i++) {
		if (d[t[i]] == 0) {
			ok = false;
			break;
		}
		d[t[i]]--;
	}
	cout << (ok ? "YES" : "NO") << endl;
}



Measured memory_bytes: 14336
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

//sum_{i=0 to n-1} floor((ai+b)/m)
ll floor_sum(ll n,ll m,ll a,ll b) {
  ll ans=0;
  if(a>=m) {
    ans+=(n-1)*n*(a/m)/2;
    a%=m;
  }
  if(b>=m) {
    ans+=n*(b/m);
    b%=m;
  }
  ll y_max=(a*n+b)/m,x_max=(y_max*m-b);
  if(y_max==0)return ans;
  ans+=(n-(x_max+a-1)/a)*y_max;
  ans+=floor_sum(y_max,a,m,(a-x_max%a)%a);
  return ans;
}
int main(){
  startupcpp();
int codeforces;cin>>codeforces;while(codeforces--){
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  print(floor_sum(A,B,C,D));
}
}

Measured memory_bytes: 3620
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,d[50],i,sum,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&d[i]);
	sum=0;
	for(i=0;i<n-1;i++)	{
		for(j=i+1;j<n;j++)	{
			sum+=d[i]*d[j];
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(), x.end()

ll gcd(ll a, ll b) {
  ll c;
  if (a > b) swap(a, b);
  while (b % a > 0) {
    c = b % a;
    b = a;
    a = c;
  }
  return a;
}

vector<ll> l;
void prime(ll a) {
  ll x = a;
  ll y = 1;
  for (ll i = 2; i <= sqrt(a); i++) {
    while (a % i == 0) {
      a /= i;
      y *= i;
      if (!binary_search(all(l), i)) {
        l.push_back(i);
      }
    }
  }
  if (x / y > sqrt(a)) l.push_back(x / y);
}

int main() {
  ll a, b, res;
  cin >> a >> b;
  ll x = gcd(a, b);
  prime(x);
  cout << l.size() + 1 << endl;
}

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

//constexpr int SMAX = 8010;
int main(){
    string s;
    cin >> s;
    const int SMAX = s.size();

    int x, y;
    cin >> x >> y;
    
    bool xdir = true;
    vector<int> dx;
    vector<int> dy;
    int xc = 0;
    int yc = 0;
    for(size_t i = 0; i < s.size(); ++i){
        if(s[i] == 'F'){
            if(xdir) xc++;
            else yc++;
        }
        else {
            if(xdir){
                dx.push_back(xc);
                xc = 0;
            }
            else {
                dy.push_back(yc);
                yc = 0;
            }
            xdir = !xdir;
        }
    }
    if(xdir){
        dx.push_back(xc);
        xc = 0;
    }
    else {
        dy.push_back(yc);
        yc = 0;
    }

    vector<vector<bool>> dpx(SMAX, vector<bool>(SMAX * 2));
    dpx[1][SMAX + dx[0]] = true;
    for(size_t i = 2; i <= dx.size(); ++i){
        for(int j = 0; j < SMAX * 2; ++j){
            if(dpx[i-1][j]){
                int nx = j + dx[i-1];
                if(0 <= nx && nx < SMAX * 2){
                    dpx[i][nx] = true;
                }
                nx = j - dx[i-1];
                if(0 <= nx && nx < SMAX * 2){
                    dpx[i][nx] = true;
                }
            }
        }
    }
    
    vector<vector<bool>> dpy(SMAX, vector<bool>(SMAX * 2));
    dpy[0][SMAX] = true;
    for(size_t i = 1; i <= dy.size(); ++i){
        for(int j = 0; j < SMAX * 2; ++j){
            if(dpy[i-1][j]){
                int ny = j + dy[i-1];
                if(0 <= ny && ny < SMAX * 2){
                    dpy[i][ny] = true;
                }
                ny = j - dy[i-1];
                if(0 <= ny && ny < SMAX * 2){
                    dpy[i][ny] = true;
                }
            }
        }
    }
    if(dpx[dx.size()][x+SMAX] && dpy[dy.size()][y+SMAX]){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 33920
from collections import deque

n, q = map(int, input().split())
procs = deque([name, int(time)] for name, time in [input().split() for _ in range(n)])

tot_time = 0
while procs:
  name, time = procs.popleft()
  if time <= q:
    tot_time += time
    print(name, tot_time)
  else:
    tot_time += q
    procs.append([name, time - q])


Measured memory_bytes: 21408
#include <iostream>


using namespace std;

int main() {
	int r, g, b, n;
	cin >> r >> g >> b;
	n = 100 * r + 10 * g + b;
	if (n % 4 == 0) {
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
a=[[0 for i in range(W+1)] for j in range(H+1)]
for y in range(H):
	l=list(map(int,input().split()))
	for x in range(W):
		a[y][x]=l[x]
		a[y][W]=a[y][x]+a[y][W]
		a[H][x]=a[H][x]+a[y][x]
		a[H][W]=a[H][W]+a[y][x]
for u in range(H+1):
	for i in range(W+1):
		print(a[u][i],end='')
		if	i<W:
				print(" ",end='')		
	print()


Measured memory_bytes: 6744
//コピペ
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N,Q; cin >> N>>Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21732
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    vecl A(N);
    REP(i,N) cin >> A[i];
    int ans =0;
    REP(i,N) {
        while (i+1 < N && A[i] == A[i+1]) ++i;
        if (i+1 < N && A[i] < A[i+1]) {
            while (i+1 < N && A[i] <= A[i+1]) ++i;
        }
        else if (i+1 < N && A[i] > A[i+1]) {
            while (i+1 < N && A[i] >= A[i+1]) ++i;
        }
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3936
#include <iostream>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>

using namespace std;


int main(int argc, char const* argv[])
{
    int tmp;
    vector<int> a(10);
    vector<int> b(10);
    for (int i = 0; i < 10; i++) 
    {
        cin >> tmp;
        a.push_back(tmp);
    }
    for (int i = 0; i < 10; i++) 
    {
        cin >> tmp;
        b.push_back(tmp);
    }
    sort( a.begin(),a.end(),greater<int>() );
    sort( b.begin(),b.end(),greater<int>() );
    int all_a=0;
    int all_b=0;
    for (int i = 0; i < 3; i++) 
    {
        all_a += a[i];
        all_b += b[i];
    }

    cout << all_a << " " << all_b << endl;
    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    if(n < 10)
    {
        cout << n;
    }
    else if(n < 100)
    {
        cout << "9";
    }
    else if(n < 1000)
    {
        cout << n - 90;
    }
    else if(n < 10000)
    {
        cout << "909";
    }
    else if(n < 100000)
    {
        cout << n - 9090;
    }
    else
    {
        cout << "90909";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

int main()
{
	string S;
	cin >> S;
	int X, Y;
	cin >> X >> Y;
	vector<int> fs;
	int fn = 0;
	for (auto c : S) {
		if (c == 'T') {
			fs.push_back(fn);
			fn = 0;
		} else {
			fn++;
		}
	}
	fs.push_back(fn);

	set<int> xs;
	set<int> ys;
	xs.insert(fs[0]);
	ys.insert(0);
	for (int i = 1; i < (int)fs.size(); i++) {
		set<int> ns;
		int f = fs[i];
		if ((i & 1) == 0) {
			for (auto x : xs) {
				ns.insert(x + f);
				ns.insert(x - f);
			}
			xs = move(ns);
		} else {
			for (auto y : ys) {
				ns.insert(y + f);
				ns.insert(y - f);
			}
			ys = move(ns);
		}
	}
	bool ans = xs.find(X) != xs.end() && ys.find(Y) != ys.end();
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main() {
  int a, b;
  int _500=0, _100=0, _50=0, _10=0, _5=0, _1=0;
  while(1) {
    scanf("%d", &b);
    if(b == 0) {
      break;
    }
    a = 1000 - b;
    _500=0, _100=0, _50=0, _10=0, _5=0, _1=0;
    _500 = a / 500;
    a -= 500 * _500;
    _100 = a / 100;
    a -= 100 * _100;
    _50 = a / 50;
    a -= 50 * _50;
    _10 = a / 10;
    a -= 10 * _10;
    _5 = a / 5;
    a -= 5 * _5;
    _1 = a;

    printf("%d\n", _500 + _100 + _50 + _10 + _5 + _1);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];
ll B[MAXN+5];
ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	vi vec;
	sc(n);
	f1(i,n)sc(A[i]),B[A[i]]++,mxz(ans,A[i]),vec.pb(A[i]);
	sort(all(vec));
	f1(i,n){
		if(A[i]==ans){
			if(B[ans]>1)pr(ans);
			else pr(vec[sz(vec)-2]);
		}
		else pr(ans);
	}
	re 0;
	// Hack it if you can :)
}

int main(){
//	INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

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

int main(void) {
    long long A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;
    if (abs(A - B) > (V - W) * T) {
        printf("NO\n");
    } else {
        printf("YES\n");
    }
    return 0;
}


Measured memory_bytes: 3636