akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
	int N, K;

	cin >> N >> K;

	int mx = (N - 1) * (N - 2) / 2; 
	if (K > mx) {
		cout << -1 << endl;
		return 0;
	}

	vector<pair<int, int> > ans;
	for (int i = 0; i < N - 1; i++) {
		ans.push_back(make_pair(i + 1, N));
	}

	int add = mx - K;
	vector<pair<int, int> > edge;
	for (int i = 0; i < N - 1; i++) {
		for (int j = 0; j < i; j++) {
			edge.push_back(make_pair(i + 1, j + 1));
		}
	}

	for (int i = 0; i < add; i++) {
		ans.push_back(edge[i]);
	}

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].first << " " << ans[i].second << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main()
{
	int a, b, c, ans;
	cin >> a >> b >> c;
	if(c > b/a) ans = b/a;
	if(c <= b/a) ans = c;
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define PI 3.14159265358979323846
int main(void) {
    double A, B , H , M;
    double ans;
    cin >> A >> B >> H >> M;

    double ang_A,ang_B;

    if(H>6)      ang_A = 30.0*(H-12);
    else         ang_A = 30.0*(H);

    if(M>30){     ang_B = 6.0*(M-60);
                ang_A += 0.5 * (M);
              }
    else      {   ang_B = 6.0*(M);
      ang_A += 0.5*M;
    }

    if(H==0 && M==0) {
      cout << abs(A-B) << endl;
      return 0;
    }
    double rad;
    if(ang_A>ang_B){
      //rad =  (ang_A-ang_B)*  PI/180.0;
      ans = sqrt(A*A + B*B - 2.0*A*B*cos((ang_A-ang_B)*  PI/180.0));
    }
    else if(ang_A == ang_B){
      cout << 0.0 <<endl;
      return 0;
    }
    else{
      //rad =  (ang_B-ang_A) * PI/180.0;
      ans =  sqrt(A*A + B*B - 2.0*A*B*cos((ang_B-ang_A) * PI/180.0));
    }




    //ans = sqrt(ans);
    //ans = pow(ans,0.5);
    printf("%.10lf\n",ans );

    return 0;
}


Measured memory_bytes: 4176
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        long divisor = IntStream.range(a, b + 1).filter(x -> (c % x) == 0).count();
        System.out.println(divisor);
        sc.close();
    }
}



Measured memory_bytes: 32480
#include<iostream>
using namespace std;
int main() {
	int w,a,b;
	cin>>w>>a>>b;
	if(a<b) {
		if(a+w<b) {
			cout<<b-a-w;
		} else if(a+w>=b) {
			cout<<"0";
		}
	} else {
		if(b+w<a) {
			cout<<a-b-w;
		} else if(b+w>=a) {
			cout<<"0";
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
#define Fi first
#define Se second
signed main(){
    int n;
    cin>>n;
    vector<int>vec;
    for(int i=2;i<=n;i++){
        int x=i;
        for(int j=2;j<=i;j++){
            if(x%j==0){
                vec.push_back(j);
                x/=j;
                j--;
            }
        }
    }
    sort(vec.begin(),vec.end());
    int l=vec.size();
    int cnt=0,ans=1;
    rep(i,l){
        if(i==0||vec[i]==vec[i-1])cnt++;
        else{
            ans*=(cnt+1);
            cnt=1;
        }
        ans%=mod;
    }
    ans*=(cnt+1);
    ans%=mod;
    cout<<ans<<endl;
    return 0;
}


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

int main(void){
  int n,l;
  int i,j;
  char **S;
  char *min;

  scanf("%d %d",&n,&l);

  
  S=malloc(n*sizeof(char*));
  for(i=0;i<n;i++){
    S[i]=malloc(l*sizeof(char));

  }
  min=malloc(sizeof(char)*l);

  
  for(i=0;i<n;i++){
      scanf("%s",S[i]);
  }
  
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      if(strcmp(S[i],S[j])>0){
	strcpy(min,S[i]);
	strcpy(S[i],S[j]);
	strcpy(S[j],min);
      }
    }
  }

  
  for(i=0;i<n;i++){
    printf("%s",S[i]);
    }

  putchar('\n');

  free(S);
  free(min);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define forn for(int i=0;i<n;i++)
#define form for(int j=0;j<m;j++)
#define pb push_back
#define s second
#define f first
int main()
{
   string s;
   cin>>s;
   int n=s.size();
   int cnt=0;
   forn
   {
             if(s[i]=='2') cnt++;
   }
   cout<<cnt;
   return 0;
}

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

int main()
{
  int m,n,x,y;
  cin >> x >> y;

  m=y-2*x;
  n=4*x-y;

  if(m>=0 && n>=0 && m%2==0 && n%2==0){
    cout << "Yes\n";
  }
  else cout << "No\n";

  return 0;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {
	static public void main(String args[]){
		Scanner sc=new Scanner(System.in);
		
		Long nu=sc.nextLong();
		
		String str="abcdefghijklmnopqrstuvwxyz";
		List<String>list=new ArrayList<>();
		
		do{
			nu--;
			String s=Long.toString(nu%26);
			//System.out.print(s);
			list.add(s);
			nu/=26;
		}while(nu>0);
		
	
		for(int i=list.size()-1;i>=0;i--){
			int a=Integer.parseInt(list.get(i));
			//System.out.print(a);
			System.out.print(str.charAt(a));
		}
	}
}

Measured memory_bytes: 35696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define met(s) memset(s,0, sizeof(s))
const int mod=100000007;
const int maxn=1100;
const int inf = 0x3f3f3f3f;
queue<int> q[maxn];
queue<int> a;
queue<int> b;
bool vis[maxn];
int main()
{
    int n;
    memset(vis,false,sizeof(vis));
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<n-1;j++)
        {
            int x;
            scanf("%d",&x);
            q[i].push(x);
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis[i]&&q[q[i].front()].front()==i)
        {
            a.push(i);
            vis[i]=vis[q[i].front()]=true;
        }
    }
    int ans=0;
    while(!a.empty())
    {
        ans++;
        while(!a.empty())
        {
            int now=a.front();a.pop();
            int nn=q[now].front();
            vis[now]=vis[nn]=false;
            q[nn].pop();
            if(!q[nn].empty()&&q[q[nn].front()].front()==nn)
            {
                vis[nn]=vis[q[nn].front()]=true;
                b.push(nn);
            }
            q[now].pop();
            if(!q[now].empty()&&q[q[now].front()].front()==now)
            {
                vis[now]=vis[q[now].front()]=true;
                b.push(now);
            }
        }
        while(!b.empty())
        {
            a.push(b.front());
            b.pop();
        }
    }
    int fo=1;
    for(int i=1;i<=n;i++) if(!q[i].empty())
    {
        fo=0;
        break;
    }
    if(fo) printf("%d\n",ans);
    else printf("-1\n");
    return 0;
}

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

int main(){
    int n;
    int64_t mon = 1000, cor = 0;
    cin >> n;
    vector<int> vec(n);
    vector<char> act(n, 'n');
    for (int i = 0; i < n; i++) cin >> vec.at(i);

    if (vec.at(0) < vec.at(1)) act.at(0) = 'b';

    for ( int i = 1; i < n-1; i++){
        if( vec.at(i) <= vec.at(i-1) && vec.at(i) < vec.at(i +1)) act.at(i) = 'b';
        else if( vec.at(i-1) < vec.at(i) && vec.at(i+1) <= vec.at(i)) act.at(i) = 's';
    }

    act.at(n-1) = 's';

    for (int i = 0; i < n; i++){
        if(act.at(i) == 'b'){
            cor = mon / vec.at(i);
            mon = mon % vec.at(i);
        }else if(act.at(i) == 's'){
            mon = mon + cor * vec.at(i);
            cor = 0;
        }
    }
    cout << mon << endl;

}

Measured memory_bytes: 3592
#include <stdio.h>
#include <math.h>
#include <iostream>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
using namespace std;
typedef long long ll;
 
ll ch1(ll a,ll b){
    if(a>b)swap(a,b);
    ll s=sqrtl((long double)a*b-1);
    if(s==0)return 0;
    ll mx=(a*b-1)/s;
    ll ans=2*s;
    if(mx==s)ans--;
    if(a<=s)ans--;
    return ans;
}
 
signed main(){
  ll q,a,b;
  cin>>q;
  while(q--){
    cin>>a>>b;
    cout<<ch1(a,b)<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
//using P = pair<int,int>;
//int dy[4] = {-1,0,1,0};
//int dx[4] = {0,-1,0,1};


int main()
{
    int N;
    cin >> N;
    vector<string> data(N);
    
    for(int i=0;i<N;i++)
    {
        cin >> data[i];
    }
    
    sort(data.begin(),data.end());
    
    string temp;
    int ans = 0;
    for(int i=0;i<N;i++)
    {
        if(i==0)
        {
            temp = data[0];
            ans++;
        }
        else
        {
            if(data[i] == temp) continue;
            temp = data[i];
            ans ++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

/*
int main()
{
    int A,B,C,D;
    cin >> A>>B>>C>>D;
    
    int taka = A/D + min(1,A%D);
    int ao = C/B + min(1,C%B);
    
    
    if(taka >= ao) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
    
}
 */

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


/*
    int N;
    cin >> N;
    
    int ans;
    cout >> ans;
    */

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

int main() {
    int H = 0;
    int W = 0;

    while (1)
    {
        cin >> H >> W ;
        
        if(H == 0 && W == 0){
            break;
        }

        for(int h = 1 ; h <= H ; h ++){
            for(int w = 1 ; w <= W ; w ++){
                cout << "#";
            }
            cout << "\n";
        }

        cout << "\n";
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(void) {
	int h, w;
	cin >> h >> w;

	string board[50];

	for (int i = 0; i < h; ++i)  cin >> board[i];

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

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (board[i][j] == '#') continue;

			int num = 0;
			for (int d = 0; d < 8; ++ d) {
				const int ni = i + dy[d];
				const int nj = j + dx[d];

				if (ni < 0 or h <= ni) continue;
				if (nj < 0 or w <= nj) continue;
				if (board[ni][nj] == '#') num++;
			}

			board[i][j] = char(num + '0');

		}
	}

	for (int i = 0; i < h; ++i)  cout << board[i] << endl;

	return 0;
}

Measured memory_bytes: 256
from sys import stdin

n, k = [int(x) for x in stdin.readline().rstrip().split()]

count = 0
for i in range(n):
    if i == 0:
        count = k
    elif i == 1:
        count = count * (k - 1)
    else:
        count = count * (k - 1)
print(count)


Measured memory_bytes: 2940
def main():
    A,B,C=map(int,input().split())
    K=int(input()) 
    for _ in range(K):
        if not A<B: 
            B *=2
            continue
        if not B < C:
            C *=2
            continue
        break
    if A<B<C:
        print("Yes")
    else:
        print("No")

main()

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 1000 + 5;
const int MAX_N = 1e5 + 5;

int main() {
    int a, b;
    cin >> a >> b;
    set<int> s = {1, 2, 3};
    s.erase(a);
    s.erase(b);
    cout << *s.begin() << endl;
}


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

int main() {
	int q;cin>>q;
//	long long a[q],b[q];
	long long a,b;
//	for(int i = 1; i <= q; i++)
//	{
//		cin >> a >> b;
//		long long ans;
//		long long pr = a * b;
//		long long t = sqrt(pr);
//		if(t * (t + 1) < pr)
//			ans = t * 2 - 1;
//		else if(t * t == pr)
//		{
//			if(a == b)
//				ans = (t - 1) * 2;
//			else
//				ans = (t - 1) * 2 - 1;
//		}
//		else
//			ans = (t - 1) * 2;
//		cout << ans << endl;
//	}

	for(int i=0;i<q;i++){
		cin>>a>>b;
		long long ans=0;
		long long s=a*b;
		long long k=sqrt(s);
		if(k*(k+1)<s){
			ans=2*k-1;
		}else if(k*k==s){
			if(a==b){
				ans=2*k-2;
			}else{
				ans=2*k-3;
			}
		}else{
			ans=2*k-2;
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<long long> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

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

    int N, M, K; cin >> N >> M >> K;
    vb visit(N+1, 0);
    vvi fgraph(N+1);
    vvi bgraph;

    while (M--) {
        int A, B; cin >> A >> B;
        fgraph[A].push_back(B);
        fgraph[B].push_back(A);
    }

    while (K--) {
        int C, D; cin >> C >> D;
        bgraph.push_back({C, D});
    }

    vi rst(N+1, 0);
    vi cnum(N+1);
    int cnt = 0;
    for (int i = 1; i <= N; i++) {
        if (visit[i]) continue;
        vi comp;
        queue<int> q;
        visit[i] = 1;
        q.push(i);
        comp.push_back(i);

        while (q.size()) {
            int c = pop(q);
            for (int n : fgraph[c]) {
                if (visit[n]) continue;
                visit[n] = 1;
                comp.push_back(n);
                q.push(n);
            }
        }

        for (int i : comp) {
            rst[i] = comp.size() - 1 - fgraph[i].size();
            cnum[i] = cnt;
        }
        cnt++;
    }

    for (vi& b : bgraph) {
        if (cnum[b[0]] == cnum[b[1]]) {
            rst[b[0]]--;
            rst[b[1]]--;
        }
    }

    for (int i = 1; i <= N; i++) {
        cout << rst[i] << " ";
    }
}

Measured memory_bytes: 15980
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

#define MAX_N 100000

int n;
string s[MAX_N];

int main(){
  cin >> n;

  REP(i,n)cin >> s[i];
  ll m = 0, a = 0, r = 0, c = 0, h = 0;
  REP(i,n){
    if(s[i][0] == 'M'){
      m++;
    }else if(s[i][0] == 'A'){
      a++;
    }else if(s[i][0] == 'R'){
      r++;
    }else if(s[i][0] == 'C'){
      c++;
    }else if(s[i][0] == 'H'){
      h++;
    }
  }

  ll ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h;


  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 6144
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t  i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

ll gcd(ll a,ll b){
  if(a%b==0)return b;
  return gcd(b,a%b);
}

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

  ll h,w;
  std::cin>>h>>w;

  if(h==1||w==1){
    std::cout<<1<<"\n";
    return 0;
  }

  std::cout<<((h+1)/2)*((w+1)/2) + (h/2)*(w/2)<<"\n";

  return 0;
}



Measured memory_bytes: 256
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
R=[]
for i in range(N):
  a=max(0,L[i][0]-L[i][1])
  b=L[i][0]+L[i][1]
  R.append([b,a])
R.sort()

ans=0
last=0
for i in range(N):
  if last<=R[i][1]:
    ans+=1
    last=R[i][0]
print(ans)

Measured memory_bytes: 41440
#include<bits/stdc++.h>
#define AtCoder return
#define Water 0
#define AT int
#define At string
using namespace std;
int main()
{
	AT a,b;
	At s;
	cin>>a>>b>>s;
	if(s[a]!='-') {cout<<"No\n";AtCoder Water;}
	for(int i=0;i<=a+b;i++)
		if(i!=a)
			if(s[i]>'9'||s[i]<'0')
				{cout<<"No\n";AtCoder Water;}
	cout<<"Yes\n";
	AtCoder Water;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	string S, T;
	cin >> S >> T;
	string ans = T + S;
	cout << ans << endl;
	return 0;
}


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

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <int> a(n+1),b(n);
    generate(all(a),nxt);
    generate(all(b),nxt);
    ll test=0;
    for(int i=0;i<n;i++)
    {
        ll x=min(b[i],a[i]);
        test+=x;
        b[i]-=x;
        a[i]-=x;

        x=min(b[i],a[i+1]);
        test+=x;
        b[i]-=x;
        a[i+1]-=x;

    }    
    cout<<test<<endl;
    
    
    return 0;   
}


 
 


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
void dp1(int a[],int n){
	int cost[n];
	cost[0]=0;
	cost[1]=abs(a[0]-a[1]);
	for(int i=2;i<n;i++)
	cost[i]=min(abs(a[i]-a[i-1])+cost[i-1],abs(a[i]-a[i-2])+cost[i-2]);
	cout<<cost[n-1];
}
int main(){
	int n;cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	dp1(a,n);
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

int main(){

    int N;
    cin >> N;

    if(N%4 == 0){
        puts("Yes");
    }else if(N%4 == 3 && N >= 7){
        puts("Yes");
    }else if(N%4 == 2 && N >= 14){
        puts("Yes");
    }else if(N%4 == 1 && N >= 21){
        puts("Yes");
    }else{
        puts("No");
    }
    
    return 0;

}


Measured memory_bytes: 256
N, M = map(int,input().split())
students = []
for _ in range(N):
    l = list(map(int,input().split()))
    students.append(l)

check_points = []

for _ in range(M):
    l = list(map(int,input().split()))
    check_points.append(l)

minimum_points = 0

for person in students:
    minimum = 10**10
    for i in range(len(check_points)):
        d=abs(person[0]-check_points[i][0])+abs(person[1]-check_points[i][1])
        if minimum > d:
            minimum = d
            minimum_points = i
    print(minimum_points+1)

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(100000,0);
	for(int i=0;i<n;++i){
		int A; cin>>A;
		++a.at(A);
	}
	int mx=0;
	for(int i=2;i<n;++i){
		mx=max(mx,a.at(i-2)+a.at(i-1)+a.at(i));
	}
	cout<<(mx==0?1:mx)<<"\n"s;
}

Measured memory_bytes: 640
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

#include "bits/stdc++.h"

using namespace std;

int main()
{
	long long x;
	cin >> x;

	vector<int> primes;
	for (int i = 2; i <= 100003; i++)
	{
		primes.push_back(i);
	}
	int m = 2;
	while (m + 1 < sqrt(100003))
	{
		for (int i = 0; i < primes.size(); i++)
		{
			if (primes[i] != m && primes[i] % m == 0) {
				primes.erase(primes.begin() + i);
				i--;
			}
		}
		m++;
	}
	int ans;
	for (int i = 0; i < primes.size(); i++)
	{
		if (x <= primes[i])
		{
			ans = primes[i];
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 892
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
     int n;
   cin>>n;
   long long a[n];
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   int ans=0;
   for(int i=0;i<n;i++)
   {
       for(int j=i+1;j<n;j++)
       {
           for(int k = j+1;k<n;k++)
           {
               if(a[i]+a[j]>a[k] && a[j]+a[k]>a[i] && a[i]+a[k]>a[j] && a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k])
                ans++;
           }
       }
   }
   cout<<ans<<endl;
}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数（ll）
ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

//素因数分解？
vector<pair<ll, int>>factorize(ll n){
  vector<pair<ll, int>> res;
  for(ll i = 2; i * i <= n; ++i){
    if(n % i) continue;
    res.emplace_back(i, 0);
    while(n % i == 0){
      n /= i;
      res.back().second++;
    }
  }
if(n != 1) res.emplace_back(n, 1);
return res;
}




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

 vector<string> inputs = {"dream", "dreamer", "erase", "eraser"};
 reverse(all(S));
 REP(i,inputs.size()) reverse(all(inputs.at(i)));
  int pos = 0;
 while(true){
   bool update = false;
   REP(i, inputs.size()){
     if(S.substr(pos, inputs.at(i).size()) == inputs.at(i)){
       pos += inputs.at(i).size();
       update = true;
       break;
     }
   }
 if(!update) break;
 }


if(pos == S.size()) YES;
else NO;

}

Measured memory_bytes: 512
A,B=gets.chomp.split(" ").map(&:to_i);

  if (A == B)
    puts ("Draw")
#互いに「1」でドロー
  elsif (A == 1)
    puts ("Alice")
  elsif (B == 1)
    puts ("Bob")
  elsif (((A != 1) && (B != 1)) && (A < B))
    puts ("Bob")
  elsif (((A != 1) && (B != 1)) && (A > B))
    puts ("Alice")
  else
    puts("想定外")
  end

Measured memory_bytes: 1788
#include <stdio.h>

#define H 10
#define W 10

int count(int data[][W], int height, int width, int key);
int getMax(int data[][W], int height, int width);

void drop(int data[][W], int height, int width, int x, int y, int size);

void display(int data[][W], int height, int width);


int main(void)
{
	
	int i, k;
	int x, y, size;
	int field[H][W] = {
	
		{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}
	
	};
	
	//display(field, H, W);
	
	while(scanf("%d,%d,%d", &x, &y, &size) != EOF){
		
		drop(field, H, W, x, y, size);
		
	}
	
	//display(field, H, W);
	
	printf("%d\n", count(field, H, W, 0));
	printf("%d\n", getMax(field, H, W));;
	
	return 0;
	
	
}


int count(int data[][W], int height, int width, int key){
	
	int ret = 0;
	int i, k;
	
	for(i=0; i<height; i++){
		
		for(k=0; k<width; k++){
			
			if(data[i][k] == key){
				
				ret++;
				
			}
			
		}
		
	}
	
	return ret;
	
}


int getMax(int data[][W], int height, int width){
	
	int max = data[0][0];
	int i, k;
	
	for(i=0; i<height; i++){
		
		for(k=0; k<width; k++){
			
			if(max < data[i][k]){
				
				max = data[i][k];
				
			}
			
		}
		
	}
	
	return max;
	
}



void drop(int data[][W], int height, int width, int x, int y, int size){
	
	switch(size){
		
		case 1:
			data[x][y]++;
			
			if(x>0){
				
				data[x-1][y]++;
				
			}
			
			if(x<width-1){
				
				data[x+1][y]++;
				
			}
			
			if(y>0){
				
				data[x][y-1]++;
				
			}
			
			if(y<height-1){
				
				data[x][y+1]++;
				
			}
			
		
		break;
		
		
		case 2:
			data[x][y]++;
			
			if(x>0){
				
				data[x-1][y]++;
				
			}
			
			if(x<width-1){
				
				data[x+1][y]++;
				
			}
			
			if(y>0){
				
				data[x][y-1]++;
				
			}
			
			if(y<height-1){
				
				data[x][y+1]++;
				
			}
			
			if(x>0 && y>0){
				
				data[x-1][y-1]++;
				
			}
			
			if(x>0 && y<height-1){
				
				data[x-1][y+1]++;
				
			}
			
			if(x<width-1 && y>0){
				
				data[x+1][y-1]++;
				
			}
			
			if(x<width-1 && y<height-1){
				
				data[x+1][y+1]++;
				
			}
			
		
		break;
		
		
		case 3:
			data[x][y]++;
			
			if(x>0){
				
				data[x-1][y]++;
				
			}
			
			if(x<width-1){
				
				data[x+1][y]++;
				
			}
			
			if(y>0){
				
				data[x][y-1]++;
				
			}
			
			if(y<height-1){
				
				data[x][y+1]++;
				
			}
			
			if(x>0 && y>0){
				
				data[x-1][y-1]++;
				
			}
			
			if(x>0 && y<height-1){
				
				data[x-1][y+1]++;
				
			}
			
			if(x<width-1 && y>0){
				
				data[x+1][y-1]++;
				
			}
			
			if(x<width-1 && y<height-1){
				
				data[x+1][y+1]++;
				
			}
			
			if(x>1){
				
				data[x-2][y]++;
				
			}
			
			if(x<width-2){
				
				data[x+2][y]++;
				
			}
			
			if(y>1){
				
				data[x][y-2]++;
				
			}
			
			if(y<height-2){
				
				data[x][y+2]++;
				
			}
			
		
		break;
		
		
		default:
		break;
		
	}
	
}


void display(int data[][W], int height, int width){
	
	int i, k;
	
	
	for(i=0; i<height; i++){
		
		for(k=0; k<width; k++){
			
			printf("%d ", data[i][k]);
			
		}
		
		printf("\n");
		
	}
	
}

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

using namespace std;

typedef long long ll;
#define mems(p) memset(p,-1,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

const int mxN = 1e5;
const ll MOD = 1e9 + 7;

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

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

int main() {
	fast();
	int l, r, d;
	cin>>l>>r>>d;
	int ans = 0;
	for (int i = l; i <= r; ++i) {
		if (i % d == 0) ++ans;
	}
	cout << ans << nl;
}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a[3],k,p[11]={1,2,4,8,16,32,64,128,256,512,1024};
	cin>>a[0]>>a[1]>>a[2]>>k;
	sort(a,a+3);
	cout<<a[0]+a[1]+a[2]*p[k];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define gif(a,b) (a/b +(a%b?1:0))
#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n";
using namespace std;

int32_t main()
{   
    cin.tie(NULL);
    std::ios::sync_with_stdio(false);
   
   string s, t;
   cin >> s >> t;
   int n = t.length();
   s += t[n-1];
   if(s == t)
   	cout << "Yes";
   else
   	cout << "No";

    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll n;
  cin >> n;

  cout << "ABC" << n << endl;
  return 0;
}


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

int main() {
  ll a, b, c, d; cin >> a >> b >> c >> d;

  cout << max(max(max(b*d,a*c),b*c),a*d) << endl;
  //cout << -1000000000*-1000000000 <<endl;
}


Measured memory_bytes: 3596
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let n = read1::<usize>();
    let s = read1::<String>().chars().collect::<Vec<char>>();

    let mut ans = 0;
    
    for i in 0..10 {
        for j in 0..10 {
            for k in 0..10 {
                let v = vec![i, j, k];
                let mut now = 0;
                for l in 0..n {
                    if s[l] as usize - 48 == v[now] {
                        if now == 2 {
                            ans += 1;
                            break;
                        } else {
                            now += 1;
                        }
                    }
                }
            }
        }
    }
    
    println!("{}", ans);
}

Measured memory_bytes: 4476
#!/usr/bin/python
# coding: UTF-8
import math

n = int(input())
a = list(map(int,input().split()))

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

res = a[-1]
for i in a[:-1]:
  res = gcd(res, i)

print(res)


Measured memory_bytes: 15020
import java.util.Scanner;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    new Main().solve();
  }

  void solve() {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ans = 100000;
    int c = 0;
    for (int i = 0; i <= N; i++) {
      int t = i;
      while (t > 0) {
        c += t % 6;
        t /= 6;
      }
      t = N - i;
      while (t > 0) {
        c += t % 9;
        t /= 9;
      }
      ans = Math.min(c, ans);
      c = 0;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
s = input()

result = 'Yes'
j = int((len(s)-1)/2)

for i in range(j):
    if(s[i] != s[len(s)-i-1]):
        result = 'No'
        break

if(result !='No'):
    for i in range(int(j/2)):
        if(s[i] != s[j-i-1]):
            result = 'No'
            break

if(result !='No'):
    for i in range(int(j/2)):
        if(s[i+j+1] != s[len(s)-i-1]):
            result = 'No'
            break

print(result)

Measured memory_bytes: 3064
// abc101_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n,sum=0,n_num;
  cin>>n;
  n_num = n;
  while(n>0){
    sum+=n%10;
    n/=10;
  }
  if(n_num%sum==0){
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;

const ll MOD = 1e9 + 7;

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

  reverse(s.begin(), s.end());
  int n = s.size();
  ll dp[2][13] = {0};
  dp[0][0] = 1;

  ll keta = 1;
  rep(is, n){
    if (s[is] == '?'){
      rep(i, 10){
        int m = (keta * i) % 13;
        rep(j, 13){
          int ni = (j + m) % 13; 
          dp[1][ni] += dp[0][j];
          dp[1][ni] %= MOD;
        }
      }
    }else{
      ll idx = (s[is] - '0') * keta;
      rep(i, 13){
        dp[1][(i+idx) % 13] = dp[0][i];
      }
    }

    swap(dp[0], dp[1]);
    rep(i, 13) dp[1][i] = {0};
    keta = (10*keta) % 13;
  }
  cout << dp[0][5] << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
typedef long long ll;
ll N,T;
ll t[200010];

int main(){
	cin >> N >> T;
	for(int i=0;i<N;i++){
		cin >> t[i];
	}
	ll sub = 0;
	for(int i=0;i<N-1;i++){
		if(t[i+1]-t[i]<T) sub += T-(t[i+1]-t[i]);
	}
	cout << N*T-sub << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

const int mod = 2019;
int main() {
    string s;
    cin >> s;
    int n = s.size();
    int fac = 1;
    map<int,int>mp;
    int ans = 0;
    mp[0] = 1;
    ll cur = 0;
    for(int i = 0;i<n;i++) {
        cur += (s[n-1-i]-'0')*fac;
        cur %= mod;
        mp[cur]++;
        fac = fac*10%mod;
    }
    rep(i,mod) {
        ans += mp[i]*(mp[i]-1)/2;
    }
    cout << ans << endl;
}
    




Measured memory_bytes: 3776
#include<stdio.h>

int main()
{
	int n, k, x, y, i, sum=0;

	scanf("%d %d %d %d", &n, &k, &x, &y);

	for (i = 0;i < k&&i<n;i++) {
		sum += x;
	}

	for (k;k+1 <= n;k++) {
		sum += y;
	}

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

	return 0;

} 

Measured memory_bytes: 128
//Hack me if you can :)
//lalalalala

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define rep(i , j) for (int i = 0 , i##_end_ = j; i < i##_end_ ; ++ i)
#define For(i , j , k) for (int i = (j) , i##_end_ = (k) ; i <= i##_end_ ; ++ i)
#define Fordown(i , j , k) for (int i = (j) , i##_end_ = (k) ; i >= i##_end_ ; -- i)
#define Set(a , b) memset(a , b , sizeof(a))
#define SZ(a) ((int)(a.size()))
#define ALL(a) a.begin(), a.end()
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define Mod (1000000007)
#define y1 wozenmezhemecaia 
#ifdef hany01
#define debug(...) fprintf(stderr , __VA_ARGS__)
#else
#define debug(...)
#endif

inline void File() {
#ifdef hany01 
	freopen("a.in" , "r" , stdin);
    freopen("a.out" , "w" , stdout);
#endif
}

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

char c_; int _ , __;
inline int read() {
    for (_ = 0 , __ = 1 , c_ = getchar() ; !isdigit(c_) ; c_ = getchar()) if (c_ == '-')  __ = -1;
    for ( ; isdigit(c_) ; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}

int n, a, b;

int main()
{
	File();
    n = read(); a = read(); b = read();
    if ((abs(a - b) - 1) % 2 == 0) { puts("Borys"); return 0; }
    puts("Alice");
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        vec[i]=x;
    }
    int count=0;
    for(int i=0;i<n-2;i++){
        if((vec[i]<vec[i+1]&&vec[i+1]<vec[i+2])||(vec[i]>vec[i+1]&&vec[i+1]>vec[i+2])){
            count++;
        }
    }
    cout << count <<endl;
}

Measured memory_bytes: 256
from heapq import *
N,M=map(int,input().split())
G=[[] for i in range(N)]
for i in range(N-1):
  G[i+1].append((i,0))
l,r,c=0,0,0
for i in range(M):
  l,r,c=map(int,input().split())
  G[l-1].append((r-1,c))
D=[0]*N
INF=10**20
def ijk(s):
  global D,INF,G
  for i in range(len(G)):
    D[i]=INF
  D[s]=0
  Q=[]
  heapify(Q)
  heappush(Q,(0,s))
  p,v,e=0,0,0
  while len(Q):
    p=heappop(Q)
    v=p[1]
    if D[v]<p[0]:
      continue
    for i in range(len(G[v])):
      e=G[v][i]
      if D[e[0]]>D[v]+e[1]:
        D[e[0]]=D[v]+e[1]
        heappush(Q,(D[e[0]],e[0]))

ijk(0)
if D[-1]>=INF:
  print(-1)
else:
  print(D[-1])

Measured memory_bytes: 100008
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

N=int(input())
if digitSum(N)%9==0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 11180
#include<stdio.h>
#define NIL -1
struct Node_struct{int p, l, r, s, d;};
typedef struct Node_struct Node;
Node T[25];
int D[25];
int H[25];

void print(int u){
int i, c;
printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", u, T[u].p, T[u].s, T[u].d+1, D[u], H[u]);

if(T[u].p == NIL) printf("root\n");
else if(T[u].l == NIL && T[u].r == NIL) printf("leaf\n");
else printf("internal node\n");

}

void calcDepth(int u, int p){
D[u] = p;
if(T[u].l != NIL) calcDepth(T[u].l,p+1);
if(T[u].r != NIL) calcDepth(T[u].r,p+1);
}

void calcHeight(int u){
if(T[u].d == NIL) H[u] = 0;
else{
if(T[u].l != NIL) calcHeight(T[u].l);if(T[u].r != NIL) calcHeight(T[u].r);

H[u] = H[T[u].l]+1;
if( H[T[u].l] < H[T[u].r]) H[u] = H[T[u].r]+1;
}
}

int main(){
int i, j;
int n;
int id,l,r;
int root = NIL;
scanf("%d", &n);
for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = T[i].s = T[i].d = H[i] = NIL;

for(i=0; i<n; i++)
  {
scanf("%d %d %d", &id, &l, &r);
if(l != -1)
  {
T[id].l = l;
T[l].p = id;
T[id].d++;
if(r != -1) T[l].s = r;
}
if(r != -1)
  {
T[id].r = r;
T[r].p = id;
T[id].d++;
if(l != -1) T[r].s = l;
}

}

//根を求める (find the root)
for(i=0; i<n; i++){
if(T[i].p == -1) root = i;
}

//それぞれのノードの深さを求める (find depth of each node)
calcDepth(root, 0);

calcHeight(root);

//出力 (output)
for(i=0; i<n; i++) print(i);

  return 0;
}



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

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

int main(void){
	int N,M,K;
	cin >> N >> M >> K;
	if(N+M+K < 22) cout << "win" << endl;
	else cout << "bust" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;
int l;

string dp[2][30];
auto comp = [](const string& a, const string& b) { return (a.size() == b.size()) ? a < b : a.size() < b.size(); };

string solve() {
    int idx = 0;
    for (int i = 0; i < 26; i++) {
        string a = {(char)('a'+i)};
        if (s[l-1]-'a' == i) {
            dp[idx][i] = a + "a";
        } else {
            dp[idx][i] = a + "";
        }
    }

    for (int n = l-2; n >= 0; n--) {
        for (int k = 0; k < 26; k++) {
            if (s[n]-'a' == k) {
                vector<string> v;
                for (int i = 0; i < 26; i++) {
                    v.push_back(dp[idx][i]);
                }
                sort(ALL(v), comp);
                dp[1-idx][k] = (char)('a'+k) + v[0];
            } else {
                dp[1-idx][k] = dp[idx][k];
            }            
        }
        idx = 1 - idx;
    }
    
    vector<string> v;
    for (int i = 0; i < 26; i++) {
        v.push_back(dp[idx][i]);
    }
    sort(ALL(v), comp);
    return v[0];
}

void input() {
    cin >> s;
    l = s.size();
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 788
#include <stdio.h>
#include <string.h>

int main(void)
{
	char sa[100],sb[100],sc[100];
	int ca[1]={0},cb[1]={0},cc[1]={0};
	scanf("%s%s%s",sa,sb,sc);
	int lena,lenb,lenc;
	lena=strlen(sa);
	lenb=strlen(sb);
	lenc=strlen(sc);

	char win='z';
	char turn='a';
	while(win=='z'){
		switch(turn)
		{
		case 'a':
			if(ca[0]==lena)
				{win='A';}

			turn=sa[ca[0]];
			ca[0]++;
			break;
		case 'b':
			if(cb[0]==lenb)
				{win='B';}
			turn=sb[cb[0]];
			cb[0]++;
			break;
		case 'c':
			if(cc[0]==lenc)
				{win='C';}
			turn=sc[cc[0]];
			cc[0]++;
			break;
		}
		}
	printf("%c\n",win);
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>

int main(){
	int N;
	scanf("%d", &N);
	char tmp;
	for (int i = 0; i < N; ++i)	{
		scanf("%c", &tmp);
		if(tmp == 'Y'){
			printf("Four\n");
			return 0;
		}
	}
	printf("Three\n");
	return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n + 1), b(n), c(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> c[i];
	}

	sort(a.begin(), a.end());
	sort(c.begin(), c.end());
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		auto s = lower_bound(a.begin(), a.end(), b[i]), t = upper_bound(c.begin(), c.end(), b[i]);

		long long p, q;
		if (a[s - a.begin() - 1] == 0) {
			p = 0;
		} else {
			p = s - a.begin() - 1;
		}
		
		if (t == c.end()) {
			q = 0;
		} else {
			q = t - c.begin();
			q = n - q + 1;
		}
		ans += p * q;
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int even = 0, odd = 0, four = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a%2 == 0) {
      even++;
      if (a%4 == 0) {
        four++;
      }
    }
  }
  odd = N - even;
  if (odd <= four || odd == four + 1 && even == four) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256