akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int h, w;

    signed call_of_Cthulhu( signed datum ) {

        read h >> w;
        echo (h-1)*(w-1) fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main(void){
    long long int ans = 1;
    int n;
    long long int sep = pow(10, 9) + 7;

    cin >> n;
    for(int i = 1; i <= n; i++){
        ans = (ans * i) % sep;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
	unsigned long long int N, x;
	unsigned long long int ans=0;
	vector<unsigned long long int> v;
	cin>>N>>x;
	v.resize(N);
	for(int i=0; i<N; i++){
		cin>>v[i];
		if(v[i]>x){
			ans+=v[i]-x;
			v[i]=x;
		}
	}

	for(int i=0; i<N-1; i++){
		unsigned long long int sum=v[i]+v[i+1];
		if(sum>x){
			v[i+1]-=sum-x;
			ans+=sum-x;
		}	
	}

	cout<<ans<<endl;

	return 0;
}


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

int main(){
  string s;
  cin >> s;
  s += 'x';
  int len = s.length();
  
  int cur=0,max=0;
  rep(i,len){
    if(s[i]=='A' || s[i]=='G' || s[i]=='C' || s[i]=='T'){
      cur++;
    }else{
      if(cur>max) max = cur;
      cur = 0;
    }
  }
  
  cout << max << endl;
  
  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 212345;
using P = pair<ll, ll>;
ll dp[MAX_N][32];

int main2() {
  int N = nextInt();
  ll T = nextLong();

  vector<P>AB;
  vector<ll> a0;
  REP(i, N) {
    ll a = nextLong();
    ll b = nextLong();
    if (a == 0) {
      a0.push_back(b);
    } else {
      AB.push_back({a, b});
    }
  }
  sort(ALL(AB), [](const P&i, const P&j){
    return (i.second+1)*j.first <
           (j.second+1)*i.first;
  });

  REP(i, MAX_N) REP(j, 32) dp[i][j] = T+1;
  dp[0][0] = 0;

  REP(i, AB.size()) {
    REP(j, 32 - 1) {
      ll t = dp[i][j];
      if (t > T) continue;
      const ll a = AB[i].first;
      const ll b = AB[i].second;
      chmin(dp[i+1][j], t);
      chmin(dp[i+1][j+1], t+1+(t+1)*a + b);
    }
  }

  sort(ALL(a0));
  int ans = 0;
  REP(j, 32) {
    ll t = T - dp[AB.size()][j];
    if (t < 0) continue;
    int cur = j;
    REP(i, a0.size()) {
      if (t - (a0[i] + 1) >= 0) {
        t -= a0[i] + 1;
        cur++;
      } else break;
    }
    chmax(ans, cur);
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 57324
#include <bits/stdc++.h>
using namespace std;
int  main(){
int X;
cin>>X;
bool a=false;
while(a==false){
bool d=true;
for(int i=2; i<X;i++){
    if(X%i==0){
        d=false;
    }
}
if(d==true){
    cout<<X<<endl;
    a=true;
}
else{
    X++;
}
}
}





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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

int n,x,y;
double tot,fact=1;
vector<pair<int,pii>> a;

double Distance(pii a,pii b){
  return sqrt((a.f-b.f)*(a.f-b.f)+(a.s-b.s)*(a.s-b.s));
}

bool cmp(pair<int,pii> a,pair<int,pii> b){
 return a.f<b.f;
}

int main(){
  cin >> n;
  for(int i=0;i<n;++i){
   cin >> x >> y;
   a.push_back(make_pair(i,make_pair(x,y)));
  }
  for(int i=2;i<=n;++i){
    fact*=i;
  }
  do{
    for(int i=1;i<n;++i){tot+=Distance(a[i].s,a[i-1].s);}
  }while(next_permutation(a.begin(),a.end(),cmp));
  cout << setprecision(10) << (double)tot/(double)fact;
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n,A,B;
ll a[5001];
ll dp[5001][5002];

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

  cin>>n>>A>>B;
  rep(i,n){
    cin>>a[i];
  }

  rep(i,n+1)rep(j,n+1)dp[i][j]=INF;
  dp[0][0]=0;
  rep(i,n)rep(j,n+1){
    if(a[i]>j){
      minch(dp[i+1][a[i]],dp[i][j]);
      minch(dp[i+1][j],dp[i][j]+A);
    }else{
      minch(dp[i+1][j],dp[i][j]+B);
    }
  }
  ll res=INF;
  rep(j,n+1)minch(res,dp[n][j]);
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 195712
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int N;
	cin >> N;
	int count4 = 0;
	int count2 = 0;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		if (a % 4 == 0)count4++;
		else if (a % 2 == 0) count2++;
	}
	
	int n = N - max(0, count2 - 1);
	if (count2 % 2 == 0) {

	}
	n = n / 2;

	if (n <= count4) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3636
int main()
{
    int N,K,X,Y;
    while(~scanf("%d%d%d%d",&N,&K,&X,&Y))
    {
        if(N>K)
        printf("%d\n",K*X+(N-K)*Y);
        if(N<=K)
            printf("%d\n",N*X);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000007
using namespace std;
ll pow_mod(ll a, int n)
{
    ll ans = 1;
    while(n)
    {
        if(n&1)
        {
            ans = (ans * a) % inf;
        }
        a = (a * a) % inf;
        n >>= 1;
    }
    return ans;
}
ll Fermat(ll a) //费马求a关于b的逆元
{
    return pow_mod(a, inf-2);
}
int main()
{
    int n,a[10009];
    ll ans=0,ans2=1;
    map<int,int>ma;
    map<int,int>ma1;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
    for(int i=1; i<=n; i++)
    {
        int tmp=floor(sqrt(a[i])+0.5),tmp1=a[i],num;
        for(int j=2; j<=tmp; j++)
        {
            if(tmp1%j==0)
            {
                num=0;
                while(tmp1%j==0)
                {
                    num++;
                    tmp1/=j;
                }
                ma[j]=max(ma[j],num);
            }
        }
        if(tmp1!=1)
            ma[tmp1]=max(ma[tmp1],1);
    }
    map<int,int> :: iterator it;
    for(it=ma.begin(); it!=ma.end(); it++)
        (ans2*=pow_mod(it->first,it->second))%=inf;
    //printf("%lld\n",ans2);
    for(int i=1; i<=n; i++)
        ans=(ans+ans2*Fermat(a[i])%inf)%inf;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int maxn = 200100;
bool to1[maxn],to2[maxn];
int main(){
    int t,m;
    scanf("%d%d",&t,&m);
    memset(to1,0,sizeof(to1));
    memset(to2,0,sizeof(to2));
    for(int i=0;i<m;i++){
        int ff,tt;
        scanf("%d%d",&ff,&tt);
        if(ff==1)to1[tt]=1;
        if(tt==1)to1[ff]=1;
        if(ff==t)to2[tt]=1;
        if(tt==t)to2[ff]=1;
    }
    if(to1[t]){
        puts("POSSIBLE");
        return 0;
    }
    for(int i=0;i<maxn;i++)if(to1[i] && to2[i]){
        puts("POSSIBLE");
        return 0;
    }
    puts("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 640
def sol(h,w):
    d = (h*h) + (w*w)
    ans =(150,150)
    for dw in range(1,150):
        for dh  in range(1,dw):
            dd = (dw*dw) +  (dh*dh)
            if dd < d:continue
            if dw == w and dh == h:continue
            if dd == d and dh < h:continue
            da = (ans[0]*ans[0]) + (ans[1]*ans[1])
            if dd < da:ans = (dh,dw)
            elif dd == da:
                if dh < ans[0]: ans = (dh,dw)
    print(*ans)

if __name__ =="__main__":       
    while 1:
        h,w = list(map(int,input().split(' ')))
        if h ==0:break
        sol(h,w)


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

int H,W;
int data[51][51];
int num[51][51];
int root(int x,int y){
	int a = 25000,b = 25000;
	if(x == 1 && y == 1)
		return 0;
	if(num[y][x] >= 0)
		return num[y][x];
	if(x > 1){
		a = root(x-1,y);
	}
	if(y > 1){
		b = root(x,y-1);
	}
	if(a > b){
		num[y][x] = b+data[y][x];
	}
	else{
		num[y][x] = a+data[y][x];
	}
	return num[y][x];
}
int main(){
	int i,j,min;
	char str[53];
	cin >> H >> W;
	for(i = 1;i <= H;i++){
		cin >> str+1;
		for(j = 1;j <= W;j++){
			data[i][j] = (int)str[j]-48;
			num[i][j] = -1;
		}
	}
	min = root(W,H);
	cout << min << endl;
	return 0;
}

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

#define MOD 10000007
#define f first
#define s second
#define pb push_back
#define es " "
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main(){
    fastio;
    int h, n, x, soma=0;
    cin >> h >> n;
    for(int i=0; i<n; i++){
        cin >> x;
        soma+=x;
    }
    if(soma>=h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
  int N,M,max_sum=0;
  cin >> N;
  vector<string> b(N);
  for(int i=0;i<N;i++){
    cin >> b.at(i);
  }
  cin >> M;
  vector<string> r(M);
  for(int i=0;i<M;i++){
    cin >> r.at(i);
  }
  vector<int> ans(N,0);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(b.at(i)==b.at(j)){
        ans.at(i)++;
      }
    }
    for(int k=0;k<M;k++){
      if(b.at(i)==r.at(k)){
        ans.at(i)--;
      }
    }
  }
  sort(ans.begin(),ans.end());
  cout << max(ans.at(N-1),0) << endl;
}

Measured memory_bytes: 256
echo H,W,A,B=`tr \  ,`\;M,C=10**9+7,1 '
for I in range(1,H'{'):Z=C=C*(W+H-B+~I)*pow(I,M-2,M)%M','-A):C=C*(B-1+I)*(H-I)*pow(I*(W+H-B+~I),M-2,M)%M;Z+=C'} '
print Z%M'|pypy

Measured memory_bytes: 89848
#include<iostream>
using namespace std;
const int INF = 1e9;

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

    int h[n], ans[n+k];
    for(int i = 0; i < n; i++)  cin >> h[i], ans[i] = INF;
    
    ans[0] = 0;

    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            if(i+j >= n)    break;
            ans[i+j] = min(ans[i+j], ans[i] + abs(h[i]-h[i+j]));
        }
    }

    cout << ans[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
	double x1,x2,xp,y1,y2,yp,slope,ansx,ansy;
	int q;
	bool X_FLG = false,Y_FLG = false;

	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	scanf("%d",&q);

	if(y1 == y2){
		X_FLG = true;
	}else if(x1 == x2){
		Y_FLG = true;
	}else{
		slope = (y2-y1)/(x2-x1);
	}

	for(int i=0;i<q;i++){
		scanf("%lf %lf",&xp,&yp);
		if(X_FLG){
			ansx = xp,ansy=y1;
			printf("%.10lf %.10lf\n",2*ansx-xp,2*ansy-yp);
		}else if(Y_FLG){
			ansx = x1,ansy = yp;
			printf("%.10lf %.10lf\n",2*ansx-xp,2*ansy-yp);
		}else{
			ansx = (yp*(x2-x1)*(y2-y1)+xp*(x2-x1)*(x2-x1)-y1*(y2-y1)*(x2-x1)+x1*(y2-y1)*(y2-y1))/((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
			ansy = ((x1-x2)*ansx+yp*(y2-y1)+xp*(x2-x1))/(y2-y1);
			printf("%.10lf %.10lf\n",2*ansx-xp,2*ansy-yp);
		}

	}

	return 0;
}



Measured memory_bytes: 2752
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v) cout << i << ' ' << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vin2(v, w) for (ll i = 0; i < v.size(); ++i) cin >> v[i] >> w[i];
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; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(18);

	int N;
	cin >> N;
	cout << (10000 - N) % 1000;


}


Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys

def solve(N: str):
    n = list(map(int,list(N)))
    kuriage = 0
    LEN = len(n)
    pay_count = 0

    for i in range(LEN-1,-1,-1):
        if i != 0:
            if n[i-1] >= 5:
                if n[i]+kuriage <= 4:
                    pay_count += n[i]+kuriage
                    kuriage = 0
                else:
                    pay_count += 10-(n[i]+kuriage)
                    kuriage = 1
            else:
                if n[i]+kuriage <= 5:
                    pay_count += n[i]+kuriage
                    kuriage = 0
                else:
                    pay_count += 10-(n[i]+kuriage)
                    kuriage = 1
        else:
            if n[i]+kuriage <= 5:
                pay_count += n[i]+kuriage
                kuriage = 0
            else:
                pay_count += 10-(n[i]+kuriage)
                kuriage = 1

    if kuriage == 1:
        pay_count += 1
    print(pay_count)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = next(tokens)
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21396
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, d int
	fmt.Scan(&n, &d)

	x := make([][]int, n)
	for i := 0; i < n; i++ {
		x[i] = make([]int, d)
		for j := 0; j < d; j++ {
			fmt.Scan(&x[i][j])
		}
	}

	cnt := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			sum := 0
			for k := 0; k < d; k++ {
				sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k])
			}
			res := int(math.Sqrt(float64(sum)))
			if res*res == sum {
				cnt++
			}
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 512
import java.util.*;
import static java.lang.System.*;

class Drink implements Comparable<Drink>{
    long p;
    long n;
    
    Drink(long _p, long _n) {
        p = _p;
        n = _n;
    }
    
    public int compareTo(Drink o) {
        if(p > o.p) return 1;
        else if (p < o.p) return -1;
        else return 0;
    }
}

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(in);
        
        int n = sc.nextInt();
        long m = sc.nextLong();
        
        Drink[] d = new Drink[n];
        for(int i=0; i<n; i++) 
            d[i] = new Drink(sc.nextLong(), sc.nextLong());
        
        Arrays.sort(d);
        
        long price = 0;
        long num = 0;
        for(int i=0; i<n; i++) {
            if(num >= m) break;
            else if(num + d[i].n >= m) {
                price += (m - num) * d[i].p;
                break;
            }
            else {
                price += d[i].n * d[i].p;
                num += d[i].n;
            }
        }
        
        out.println(price);
    }
}


Measured memory_bytes: 85484
#include <iostream>
#include <cmath>
#define LL long long
using namespace std;

int main()
{
   LL a,b,v,w,t;
   cin>>a>>b>>v>>w>>t;
   LL cha=abs(v-a);
   LL chav=b-w;
   if(chav*t>=cha)
    cout<<"YES"<<endl;
   else
    cout<<"NO"<<endl;
}


Measured memory_bytes: 3636
a,b,k = map(int,input().split())
al = []
bl = []
cl = []

for i in range(1,a+1):
    if a%i == 0:
        al.append(i)
    
for i in range(1,b+1):
    if b%i == 0:
        bl.append(i)

for i in range(len(al)):
    if al[i] in bl:
        cl.append(al[i])

print(cl[-k])

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

int main() {

	int x[5];
	for(int i=0; i<5; i++) {
		cin>>x[i];
		if(x[i] == 0)
			cout<<i+1;
	}


	return 0;
}

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

const int N = 1e5 + 10;
int a[N];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int mn = a[0], mx = a[0];
    for (int i = 1; i < n; i++) {
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
    }
    if (mx - mn > 1)
        return cout << "No\n", 0;
    else if (mx - mn == 1) {
        int x = 0;
        for (int i = 0; i < n; i++)
            if (a[i] == mn)
                x++;
        return cout << (mx * 2 - x <= n && x <= mn? "Yes\n": "No\n"), 0;
    }
    else
        return cout << (mn * 2 <= n || mn == n - 1? "Yes\n": "No\n"), 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n][3];
  int dp[n][3];
  for(int i=0;i<n;i++)
  {
  	for(int j=0;j<3;j++)
  	{
  		cin>>a[i][j];
	  }
  }
  int maximum=INT_MIN;
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<3;j++)
    {
      if(i==0)
      {
        dp[i][j]=a[i][j];
      }
      if(i>0 && j==0)
      {
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
      }
       if(i>0 && j==1)
      {
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
      }
       if(i>0 && j==2)
      {
        dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
      }
      maximum=max(maximum,dp[i][j]);
    }
  }
  cout<<maximum<<"\n";
  
}


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

int main() {
    int x,a,b;
    cin >> x;
    a = x / 500;
    ll ans = 0;
    ans += a * 1000;
    x -= a * 500;
    if(x > 0) {
        b = x / 5; 
        ans += b * 5;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using ll = long long ;
using namespace std;
const ll maxn=1e5+5;
long double x,p;
int main(){
	ios::sync_with_stdio(false), cin.tie(0) , cout.tie(0);
	cin>>x;
	p=3.141592;
	cout<<fixed<<setprecision(20);
	cout<<(2*x*p);
}



Measured memory_bytes: 3824
#include <iostream>
using namespace std;
using ll = long long;

int main()
{
	int n;
	cin >> n;
	ll a = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (!(i%3 == 0 || i%5 == 0))
		{
			a = a + i;
		}
	}
	cout << a;
}

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


using namespace std;

int main() {

    int N;
    cin >> N;

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

    sort(a.begin(), a.end(), greater<int>());

    int total_alice = 0;
    int total_bob = 0;

    for (int i = 0; i < a.size(); i+=2) total_alice += a[i];
    for (int i = 1; i < a.size(); i+=2) total_bob += a[i];


    cout << total_alice - total_bob << endl;

}

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

using namespace std;

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

int gcd3(int x,int y,int z){return gcd(x,y)%z ? gcd(z,gcd(x,y)%z):z;}

int main(){
    int k;
    cin>>k;
    
    int ans=0;
    
    for(int h=1;h<=k;h++){
        for(int i=1;i<=k;i++){
            for(int j=1;j<=k;j++){
                ans +=gcd3(h,i,j);
            }
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 3572
import math
# 時針の長さ 短針の長さ H時M分
hour_hand, min_hand, hour, minutes = map(int, input().split())

hour_hand_degree = 30 * hour + 30 * minutes / 60
min_hand_degree = 360 * minutes/60

# print(hour_hand_degree)
hour_coordinate = [math.sin(math.radians(hour_hand_degree)) *
                   hour_hand, math.cos(math.radians(hour_hand_degree)) * hour_hand]
min_coordinate = [math.sin(math.radians(min_hand_degree))*min_hand,
                  math.cos(math.radians(min_hand_degree)) * min_hand]
# print(' '.join(map(str, hour_coordinate)))
# print(' '.join(map(str, min_coordinate)))
print(math.sqrt((hour_coordinate[0] - min_coordinate[0]) **
                2 + (hour_coordinate[1] - min_coordinate[1])**2))


Measured memory_bytes: 9584
#include<iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    map<string,int> a;
    vector<string> b;
    int n,num=0,max=0;
    string ho;
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> ho;
        if(a[ho]==0){
            b.push_back(ho);
        }
        a[ho]++;
        if(max<a[ho]){
            max=a[ho];
        }
    }
    sort(b.begin(),b.end());
    int e = 0;
    for (int i = 0; i < b.size(); i++){
        if(a[b[i]]==max){
            if (e) cout << endl;
            cout << b[i];
            e = 1;
        }
    }

}

Measured memory_bytes: 26736
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll long long
//#define __int64 long long
int main(void){
    // Your code here!
    int n,d;
    cin>>n>>d;
    int ans=0,tmp=0;
    while(true){
        if(tmp>=n)break;
        tmp+=1+2*d;
        ans++;
    }
    cout<<ans<<endl;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    ll n, k;
    cin >> n >> k;
    cout << min((n % k), k - (n % k)) << endl;
}

Measured memory_bytes: 256
N = int(input())
taro_point=0
hanako_point=0
for i in range(N):
  taro,hanako=input().split()
  if taro < hanako:
    hanako_point+=3
  elif taro == hanako:
    taro_point +=1
    hanako_point +=1
  else:
    taro_point +=3

print(taro_point,hanako_point)


Measured memory_bytes: 5592
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define ull unsigned long long
#define py printf("Yes\n")
#define pn printf("No\n")
#define PY printf("Yes\n")
#define PN printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;
const int MOD=1e9+7;


int main()
{
	int x, n, tmp, chk_minus = 0, chk_plus = 0, c1, c2;
	cin >> x >> n;
	vector<int> p(n);
	bool flag = true;

	rep(i,n)cin >> p[i];


	if (n == 0)
  {
		cout<<x<<endl;
		return 0;
	}

	rep(i,n+1)
  {
		chk_minus = x - i;
		flag = true;
		rep(j,n)if (chk_minus == p[j])flag = false;
		if (flag == true)goto OUT1;
	}
OUT1:

	rep(i,n+1){
		chk_plus = x + i;
		flag = true;
		rep(j,n)if (chk_plus == p[j])flag = false;
		if (flag == true)goto OUT2;
	}
OUT2:

	c1 = abs(x - chk_minus);
	c2 = abs(x - chk_plus);



	if (c1 == c2)
  {
		cout << chk_minus << endl;
		return 0;
	}
	if (c1 > c2)
  {
		cout << chk_plus << endl;
		return 0;
	}
	else
  {
		cout << chk_minus << endl;
		return 0;
	}
}


Measured memory_bytes: 3604
S = input()
while len(S) > 0:
    if S[-5:] == 'dream' or S[-5:] == 'erase':
        S = S[:-5]
    elif S[-6:] == 'eraser':
        S = S[:-6]
    elif S[-7:] == 'dreamer':
        S = S[:-7]
    else:
        print('NO')
        quit()
print('YES')

Measured memory_bytes: 3188
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()

int main() {
		int N;
		cin >> N;
		int A[N];
		for (int i = 0; i < N; i++) cin >> A[i];

		sort(A, A+N);

		vector<pair<int, int>> v;
		for (int i = 1; i < N-1; i++) {
				if (A[i] >= 0) {
						v.push_back(make_pair(A[0], A[i]));
						A[0] -= A[i];
				} else {
						v.push_back(make_pair(A[N-1], A[i]));
						A[N-1] -= A[i];
				}
		}

		v.push_back(make_pair(A[N-1], A[0]));
		A[N-1] -= A[0];

		cout << A[N-1] << endl;
		for (int i = 0; i < N-1; i++) {
				cout << v[i].first << " " << v[i].second << endl;
		}
		return 0;
}


Measured memory_bytes: 3188
N, K = map(int, input().split())

total = 0
for k in range(K, N + 1 + 1):
    # 大きいほうから k 個選ぶ
    sum_max = ((N + N - (k - 1)) * k) / 2

    # 小さいほうから k 個選ぶときに最小値をとる
    sum_min = ((0 + k - 1) * k) / 2

    # 最大値と最小値の間の値はすべてとることができる
    # 最大値 ~ 最小値 の数を数えれば良い
    total += int(sum_max - sum_min + 1)

print(total % (10**9 + 7))


Measured memory_bytes: 9192
from math import factorial
import bisect
def cmb(n,r):
  if n<0 or r<0:
    return 0
  else:
    return factorial(n)//factorial(n-r)//factorial(r)
n,a,b=map(int,input().split())
x = list(map(int,input().split()))
ans=0
x.sort(reverse=True)
print(sum(x[:a])/a)
if n==a:
  print(1)
elif x[0]==x[a]:
  for i in range(n):
    if x[0] != x[i]:
      k=i
      break
  else:
    k=n
  for i in range(a,min(k+1,b+1)):
    ans+=cmb(k,i)
  print(ans)
elif x[a-1] == x[a]:
  y=sorted(x)
  x1=bisect.bisect_left(y,x[a])
  x2=bisect.bisect_right(y,x[a])
  print(cmb(x2-x1,a-(n-x2)))
else:
  print(1)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()



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

    string a,b; 
    a =  s.substr(0,2);
    b = s.substr(2);
    bool MMYY = ("01"<=a&&a<="12");
    bool YYMM = ("01"<=b&&b<="12");
    if(YYMM&&MMYY){
        cout << "AMBIGUOUS" << endl;
    }else if(YYMM){
        cout << "YYMM" << endl;
    }else if(MMYY){
        cout << "MMYY" << endl;
    }else{
        cout << "NA" << endl;
    }
}



Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int x;
	scanf("%d", &x);
	
	int cur_ans = 1;
	for (int b = 1; b < 33; b++) {
		for (int p = 2; p < 10; p++) {
			int bp = 1;
			for (int i = 0; i < p; i++) {
				bp *= b;
			}
			
			if (x < bp) break;
			else if (bp > cur_ans) cur_ans = bp;
		}
	}
	
	printf("%d", cur_ans);
	
	return 0;
}


Measured memory_bytes: 128
import fractions
import itertools
from functools import reduce
# print(math.gcd(1000000000, 1000000000))


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

N = int(input())
monsters = list(map(int, input().split()))

result = 10 ** 9 + 1

print(gcd(*monsters))


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

int main() {
    int n;
    cin >> n;
    map<int, int> m;
    for(int i=1; i<=200; i++){
        for(int j=1; j<=200; j++){
            for(int l=1; l<=200; l++){
                m[(i*i+j*j+l*l)+(i*j+j*l+l*i)]++;
            }
        }
    }
    for(int i=1;i<=n; i++){
        if(m.count(i)){
            cout << m.at(i) << endl;
        }
        else cout << 0 << endl;

    }

}

Measured memory_bytes: 11460
#include <bits/stdc++.h>
using namespace std;
 
int main() {
      string s;
      cin >>s;
      s.pop_back();
      for(int i=0;i<200;i++){
        int n=s.size();
        if(n%2==1){
            s.pop_back();
            continue;
        }
        string a=s.substr(0,n/2) , b = s.substr(n/2,n/2);
        if(a==b){
            cout<<s.size()<<endl;
            return 0;
        }
        else{
            s.pop_back();
        }
     }   
}

Measured memory_bytes: 3636
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int solve (int n)
{
	readln;
	auto a = readln.splitter.map !(to !(int)).array;
	auto b = readln.splitter.map !(to !(int)).array;
	int res = 0;
	foreach_reverse (bit; 0..29)
	{
		int lim = 1 << bit;
		a[] &= (lim * 2 - 1);
		b[] &= (lim * 2 - 1);
		sort !(q{a < b}) (a);
		sort !(q{a > b}) (b);
		debug {writeln (a); writeln (b);}
		int cur = 0;

//		000  001  010  011  100  101  110  111
//		111  110  101  100  011  010  001  000
//		          010
//		111  110][101  100  011  010][001  000
		int lo = 0;
		int me = 0;
		int hi = 0;
		foreach (c; a)
		{
			while (lo < n && b[lo] + c >= lim * 3)
			{
				lo += 1;
			}
			while (me < n && b[me] + c >= lim * 2)
			{
				me += 1;
			}
			while (hi < n && b[hi] + c >= lim * 1)
			{
				hi += 1;
			}
			cur ^= (lo - 0);
			cur ^= (hi - me);
			cur &= 1;
			debug {writeln (lo, " ", me, " ", hi, " ", cur);}
		}
		res += cur << bit;
	}
	return res;
}

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		writeln (solve (n));
	}
}


Measured memory_bytes: 10156
#include<iostream>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<algorithm>
#include<set>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<climits>
#include<cstdlib>
#include<queue>
#include<unordered_map>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0)



const int P = 3005;

int p, u;
bool neg;
vector<int> fi = { 1 }, se = { 1 };

vector<int> operator*(vector<int> &a, vector<int> &b)
{
	int sz = min((int)a.size() + (int)b.size() - 1, p - 1);
	vector<int> ans(sz, 0);
	for (int i = 0; i < (int)a.size(); i++)
		for (int j = 0; j < (int)b.size(); j++)
			(ans[(i + j) % (p - 1)] += a[i] * b[j]) %= p;
	return ans;
}

vector<int> operator^(vector<int> cur, int p)
{
	if (p == 1)
		return cur;
	vector<int> tmp = cur ^ (p / 2);
	tmp = tmp * tmp;
	if (p & 1)
		tmp = tmp * cur;
	return tmp;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> p >> u;
	neg = (u == 1);
	for (int i = 1; i < p; i++)
	{
		cin >> u;
		vector<int> cur = { p - i, 1 };
		if (u == neg)
			fi = fi * cur;
		else
			se = se * cur;
	}
	(++se[0]) %= p;
	fi = fi ^ (p - 1);
	fi = fi * se;
	if (neg)
		for (int &v : fi)
			v = (p - v) % p;
	fi.push_back(fi[0]);
	fi[0] = neg;
	for (int &v : fi)
		cout << v << " ";
	cin >> p;
}
/*
5
0 1 0 1 0
*/

Measured memory_bytes: 488
import java.util.*;
import java.math.*;
class Main{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    String s=in.next();
    if(s.equals("ABC"))
    {
      System.out.print("ARC");
    }
    else
      System.out.print("ABC");
    
    
    
  }
}

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

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef unsigned int ui;
typedef long long ll;
/////////////////////

int const N = 2e3 + 41;
int const INF = 2e9 + 41;


int d[N][2], f[N][2];

int n, a[N];
int ans, z, w;

int rec(int x, int p){
	if(f[x][p] != 0) return d[x][p];
	f[x][p] = 1;
	int res = abs(a[n-1] - a[x-1]);
	fi(x, n-1){
		int pres = rec(i+1, 1 - p);
		if(p == 0) res = max(res, pres);
		else res = min(res, pres);
	}
	d[x][p] = res;
	return res;
}

void solve(){
	a[0] = w;
	++n;
	ans = rec(1, 0);
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%d %d %d",&n,&z,&w);
	fi(1, n+1) scanf("%d",&a[i]);

	solve();

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

	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

vector<pair<int,int>> query[SIZE];
priority_queue<pair<ll,int> > pq;

int main(){
  int N, M;

  cin >> N >> M;

  for (int i=0; i<M; i++) {
    int L, R, C;
    cin >> L >> R >> C;
    L--; R--;
    query[L].push_back({R, C});
  }

  debug(query[0]);

  ll ans = LLINF;

  for (int i=0; i<N; i++) {
    ll dp = i == 0 ? 0 : LLINF;

    while(pq.size() && pq.top().second < i)
      pq.pop();

    if (pq.size())
      dp = min(dp, -pq.top().first);

    for (auto q : query[i]) {
      debug(i);
      pq.push({-dp-q.second, q.first});
      debug(-dp-q.second);
    }

    if (i == N-1) {
      ans = min(ans, dp);
    }
  }

  if (ans == LLINF)
    puts("-1");
  else
    cout << ans << endl;


  return 0;
}


Measured memory_bytes: 8952
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#define rep(i,j,k) for(register int i = j; i <= k; i++) 
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define fi first
#define se second
//#define P pair<ull,ull>
//#define PP pair<int,pair<int,int> >
//#define mp(a,b) make_pair(a,b)
#define ll long long
#define ull unsigned long long
using namespace std;
 
inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 1e5+5;
struct edge{ int to, nxt; } e[N<<1];
int deg[N], head[N], cnt = 0, a[N], f[N];
inline void add(int x,int y) { 
	deg[x]++, deg[y]++;
	e[++cnt].to = y, e[cnt].nxt = head[x], head[x] = cnt;
	e[++cnt].to = x, e[cnt].nxt = head[y], head[y] = cnt;
}

#define ez(i,j) for(register int i = head[j]; i; i=e[i].nxt)
#define to e[i].to
inline void out() { puts("NO"), exit(0); }
inline void dfs(int x,int fa) { 
	if( deg[x] == 1 ) { f[x] = a[x]; return; }
	ll sum = 0, t, y; int maxl = 0;
	ez(i,x) if( to != fa ) { 
		dfs(to,x);
		sum += f[to];
		maxl = max(maxl,f[to]);
	}
	if( sum < a[x] ) out(); 
	if( sum > a[x] ) { 
		t = sum - a[x];
		if( maxl > sum / 2 ) y = sum - maxl;
		else y = sum / 2;
		
		if( t > y ) out();
		f[x] = sum - t * 2;
	} else f[x] = sum;
}

int main() {
	int n = read(), rt = 0;
	if( n == 2 ) { 
		if( read() == read() ) puts("YES");
		else puts("NO");
		return 0;
	}
	rep(i,1,n) a[i] = read();
	rep(i,1,n-1) add(read(),read());
	rep(i,1,n) if( deg[i] > 1 ) { rt = i; break; }
	
	dfs(rt,0);
	if( !f[rt] ) puts("YES");
	else puts("NO");
	return 0; 
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int a, b; scanf("%d%d", &a, &b);
	if(!(a < b)) std::swap(a, b);
	
	if((a + b) % 2) printf("IMPOSSIBLE\n");
	else printf("%d\n", (a + b) >> 1);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
ll n,a,ans=1,k=1,d=0;
int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>a;
		k=min(a,k);
		if(a==0) re(0)
		if(1000000000000000000/a<ans)
		{
			ans=-1;
			d=1;
		}
		elif(d==0) ans*=a;
	}
	re(ans)
	return 0;}

Measured memory_bytes: 3636
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <cmath>		// circle math ( sin, con, sinh
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

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

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






int main() {
  int N; // 変数の宣言
  cin >> N; // 標準入力
  
  int D1[N],D2[N];
  rep(i,N) cin >> D1[i] >> D2[i];
  
  int count = 0;
  
  rep(i,N){
    if(D1[i] == D2[i]){
      count ++;
    }else{
      count = 0;
    }
    if(count == 3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  
 
  cout << setprecision(12) << "No" << endl; // 標準出力
  
}







Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var n = Int64.Parse(Console.ReadLine());
        var ts = new List<Int64>();
        ts.Add(Int64.Parse(Console.ReadLine()));
        ts.Add(Int64.Parse(Console.ReadLine()));
        ts.Add(Int64.Parse(Console.ReadLine()));
        ts.Add(Int64.Parse(Console.ReadLine()));
        ts.Add(Int64.Parse(Console.ReadLine()));
        var tm = ts.Min();
        Console.WriteLine(4 + ((n % tm == 0) ? n / tm : n / tm + 1));
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
  // read inputs
  long N;
  scanf("%ld", &N);

  // solve
  long ans = 0;
  for (long i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      const long j = N / i;
      if (j >= i + 2) {
        ans += j - 1;
      }
    }
  }
  printf("%ld\n", ans);
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 4 * 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200)
    {
        cout << s;
    }
    else
    {
        cout << "red";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in", "r", stdin);freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out", "w", stdout);
    
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int S = 0, T = N;
  for (int i = 0; i < 9; i++) {
    S += T % 10;
    T = T / 10;
  }
  int U = N % S;
  if (U == 0) {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000009;

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

int h,w,n;

int pos_to_human(int x,int y){
	if(!y){
		x = x % (w * 2) - 1;
		if(x < 0) x += w * 2;
		if(x < w) return (x / 2 + 1) * 2 - 1;
		else return (w * 2 - x - 1) / 2 * 2;
	}
	if(y == w - 1) return w - pos_to_human(x,0) - 1;
	if((x + y) % 2) return pos_to_human(x + y,0);
	else return pos_to_human(x + w - y - 1,w - 1);
}

signed main(){
	cin >> h >> w >> n;
	vector<P> vec;
	for(int i = 0;i < n;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		vec.emplace_back(a,b);
	}
	sort(all(vec));
	int human_to_zekken[200010];
	for(int i = 0;i < w;i++) human_to_zekken[i] = i;
	for(int i = 0;i < n;i++){
		int a = vec[i].first,b = vec[i].second;
		swap(human_to_zekken[pos_to_human(a,b)],human_to_zekken[pos_to_human(a,b + 1)]);
	}
	int ans[200010];
	for(int i = 0;i < w;i++) ans[human_to_zekken[pos_to_human(h,i)]] = i;
	for(int i = 0;i < w;i++) cout << ans[i] + 1 << endl;
}


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

bool isBeautiful (string s);

int main () {

    string w;
    cin >> w;

    cout << ((isBeautiful(w))? "Yes" : "No") << endl;

    return 0;
}

bool isBeautiful (string s) {

    for (char c = 'a'; c <= 'z'; c++) {
        int cnt = 0;

        for (int i = 0; i < s.size(); i++) {
            if (s[i] == c) cnt++;
        }
        if (cnt % 2 != 0) {
            return false;
        }
    }

    return true;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n; 
  string s;
  cin >> n >> s;
  if(n%2 !=0)
  { cout << "No" << endl;
   return 0;
  }
  
 string s1 = s.substr(0, n/2);
  string s2 = s.substr(n/2);
  
   if((s1 == s2))
   cout << "Yes" ;
   else 
   cout << "No";
  return 0;
  
}

Measured memory_bytes: 256
def solve(n, id, ln, a)
  return if @flag == 0
  a[id] = n
  if id == ln-1
    @cnt += 1
    if @k == @cnt
      @flag = 0
      @ans = a
    end
    return
  else
    solve(n-1, id+1, ln, a) if n > 0
    solve(n,   id+1, ln, a)
    solve(n+1, id+1, ln, a) if n < 9
  end
end

@k = gets.to_i
@cnt = 0
@ans = Array.new(0)
@flag = 1
dg = 0
while @flag == 1
  dg += 1
  a = Array.new(dg)
  for i in 1..9
    solve(i, 0, dg, a)
    break if @flag == 0
  end
end
puts @ans.join

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;
    int n, m;
    cin >> n >> m;
    string u;
    cin >> u;
    if (u == a)
        n--;
    else
        m--;

    cout << n << " " << m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N; cin >> N;
    vector <ll> A(N);
    ll count=0;
    loop(i,0,N){
        cin >> A[i];
        if (i%2==0 && A[i]%2) count++;
    }
    cout <<  count << "\n";
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{

    int n, k;
    cin >> n >> k;

    put((n - 1 + k - 2) / (k - 1) );

    return 0;
}

Measured memory_bytes: 3576