akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
typedef long long ll; 
char ans[105][105]; 
int main()
{
	// freopen("ARC093-D.in", "r", stdin); 
	// freopen("ARC093-D.out", "wt", stdout); 
	int a, b, n = 100, m = 100; 
	scanf("%d%d", &a, &b); 
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
			ans[i][j] = j >= m / 2 ? '.' : '#'; 
	}
	a--; 
	b--; 
	int x = 0, y = 0; 
	while (a--)
	{
		ans[x][y] = '.'; 
		x += 2; 
		if (x >= n)
		{
			x = 0; 
			y += 2; 
		}
	}
	x = 0; 
	y = m - 1; 
	while (b--)
	{
		ans[x][y] = '#'; 
		x += 2; 
		if (x >= n)
		{
			x = 0; 
			y -= 2; 
		}
	}
	printf("%d %d\n", n, m);
	for (int i = 0; i < n; i++)
		puts(ans[i]); 
	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

struct UnionFind{
    vl par,dist;
    UnionFind(int x){par.assign(x,-1); dist.assign(x,0);}
    ll find(ll x){return par[x]<0?x:find(par[x]);}
    ll depth(ll x){return par[x]<0?0:depth(par[x])+dist[x];}
    bool same(ll x,ll y){return find(x)==find(y);}
    ll size(ll x){return -par[find(x)];}
    ll diff(ll x,ll y){return same(x,y)?depth(x)-depth(y):LINF;}
    void unite(ll x,ll y,ll k=0){
        k+=depth(y); k-=depth(x); k=-k;
        x=find(x); y=find(y);
        if(x==y)return;
        if(size(x)<size(y)){swap(x,y);k=-k;}
        par[x]+=par[y]; par[y]=x; dist[y]=k;
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	UnionFind u(n);
	vl h(n),a(m),b(m);
	vl good(n,true);
	rep(i,n)cin>>h[i];
	rep(i,m){
		cin>>a[i]>>b[i];
		a[i]--;b[i]--;
		if(h[a[i]]>=h[b[i]])good[b[i]]=false;
		if(h[a[i]]<=h[b[i]])good[a[i]]=false;
	}
	ll ans=0;
	rep(i,n)if(good[i])ans++;
	puta(ans);
}


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

int main(){
    int N, S = 0;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
        S ^= a[i];
    }
    for(int i = 0; i < N; i++){
        cout << (S ^ a[i]) << " ";
    }
}

Measured memory_bytes: 3960
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    Z = [N]*N

    while K > 0 and A != Z:
        K-=1
        B = [int(0)]*(N+1)
        for i in range(N):
            B[max(int(0),i-A[i])]+=1
            B[min(N-1,i+A[i])+1]-=1
        for i in range(1,N):
            B[i]+=B[i-1]

        A = B[0:N]

    print(' '.join(map(str,A)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 175732
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  998244353
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
bool isvalid(ll x,ll y,ll n, ll m) { return (x>=0&&x<n&&y>=0&&y<m); }
vector<ll>v[100011];

int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,k;
    cin>>n>>k;

    ll ap[n+11];

    for(ll i=0;i<n;i++){
        cin>>ap[i];
    }

    for(ll i=k;i<n;i++){
        if(ap[i]>ap[i-k]){
            cout<<"Yes\n";
        }else{
            cout<<"No\n";
        }
    }

    return 0;
}

Measured memory_bytes: 7540
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max()/100;
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, s, t, ans, cnt, sum, a[310000], b[310000]
,d[110000][3];
string str;
bool f;
char c[1100][1100];
int main() {
	cin >> n;
	rep(i, n)
		cin >> a[i];
	sort(a, a + n);
	cnt = 0;
	a[n] = INF;
	rep(i, n) {
		while (cnt<a[i]) {
			cnt++;
			if (i == n / 2)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;


string toString(int n)
{
    string str;
    stringstream ss;
    ss << n;
    ss >> str;
    return str;
}

string toNegativeBase(int n, int negBase)
{
    if (n == 0)
        return "0";
    
    string converted = "";
    while (n != 0)
    {
        int remainder = n % negBase;
        n /= negBase;
        
        if (remainder < 0)
        {
            remainder += (-negBase);
            n += 1;
        }
        
        converted = toString(remainder) + converted;
    }
    
    return converted;
}

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    
    cout << toNegativeBase(n, -2);

    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
bool f[1000][1000];
int dp[1001][1001];
int main(){
	int h,w,n;
	int i,j;
	while(1){
	scanf("%d %d %d",&h,&w,&n);
	if(h==0)return 0;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			int b;
			scanf("%d",&b);
			f[i][j]=b==0;
		}
	}
	for(i=0;i<h;i++)for(j=0;j<w;j++)dp[i][j]=0;
	dp[0][0]=n-1;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			int a,b;
			if(dp[i][j]%2==0){a=dp[i][j]/2;b=dp[i][j]/2;}
			else{
				if(f[i][j]){a=dp[i][j]/2+1;b=dp[i][j]/2;}
				else{a=dp[i][j]/2;b=dp[i][j]/2+1;}
			}
			dp[i+1][j]+=a;dp[i][j+1]+=b;
			f[i][j]=!(f[i][j]^dp[i][j]%2==0);
		}
	}
	i=0;j=0;
	while(i!=h&&j!=w){
		if(f[i][j])i++;
		else j++;
	}
	printf("%d %d\n",i+1,j+1);
	}
}

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


int main(void)
{
    int i;
    int length;
    char str[21];
    scanf("%s", str);
    length = strlen(str) - 1;

    for (i = length; i >= 0; i--){
        printf("%c", str[i]);
    }
    printf("\n");

    return (0);

}


Measured memory_bytes: 2032
package main

import "fmt"

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

	ans := n
	for i := 0; i <= n; i++ {
		sum := 0
		for x := i; x > 0; x /= 6 {
			sum += x % 6
		}
		for x := n - i; x > 0; x /= 9 {
			sum += x % 9
		}
		if sum < ans {
			ans = sum
		}
	}
	fmt.Println(ans)
}


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

const int MOD=1000000007;

int main() {
  int n; cin>>n;
  vector<ll> a(n);
  rep(i, n) cin>>a[i];

  ll res=0;
  rep(d, 60) {
    int zero=0;
    int one=0;
    rep(i, n) {
      if (a[i]&1LL<<d) one++;
      else zero++;
    }
    ll tmp=(ll)one*zero;
    rep(i, d) {
      tmp*=2;
      tmp%=MOD;
    }
    res+=tmp;
    res%=MOD;
  }
  cout<<res<<endl;
}

Measured memory_bytes: 2560
while True:
    x,y=map(int,input().split())
    if x<=y:
        x,y=y,x
    if x==y==0:
        break
    z=0
    while True:
        if y==0:
            break
        x=x%y
        x,y=y,x
        z+=1
    print(x,z)


Measured memory_bytes: 5612
#include<bits/stdc++.h>
#define MAX (1<<17)
using namespace std;
int n,q;
int data[MAX*2];
void Segtree(){
	int tmp=1;
	while(tmp<n)tmp*=2;
	n=tmp;
	for(int i=0;i<n*2-1;i++)data[i]=INT_MAX;
}
void update(int k,int x){
	k+=n-1;
	data[k]=x;
	while(k>0){
		k=(k-1)/2;
		data[k]=min(data[k*2+1],data[k*2+2]);
	}
}
int find(int a,int b,int k,int l,int r){
	if(r<=a || b<=l)return INT_MAX;
	if(a<=l && r<=b)return data[k];
	int v1=find(a,b,k*2+1,l,(l+r)/2);
	int v2=find(a,b,k*2+2,(l+r)/2,r);
	return min(v1,v2);
}
int main(){
	int c,x,y;
	cin>>n>>q;
	Segtree();
	for(int i=0;i<q;i++){
		scanf("%d%d%d",&c,&x,&y);
		if(c)cout<<find(x,y+1,0,0,n)<<endl;
		else update(x,y);
	}
}

Measured memory_bytes: 4232
#ifndef LOCAL
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#else
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair


int main() {
    ios::sync_with_stdio(false);
    
    int x, y;
    cin >> x >> y;

    for (double i = 1; i < 1100; i++)
    {
        if (int(i * 0.08) == x and int(i * 0.1) == y){
            cout << i;
            return 0;
        }
    }
    cout << -1;
    

}


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

int main() {
  int A, N, rem;
  string op;
  cin >> N;
  cin >> A;
  
  rem = N % 500;
  
  if (A >= rem) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;

const ll MOD_CONST = 1000000007;



int main()
{
	int h, w, d;
	cin >> h >> w >> d;
	int q;
	vector<vector<int>> grid(h*w);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int a;
			cin >> a;
			grid[w * i + j] = vector<int>{ a,i,j };
		}
	}

	sort(grid.begin(), grid.end());
	/*for (int i = 0; i < h * w; i++) {
		cout << grid[i][0] << endl;
		cout << grid[i][1] << " " << grid[i][2] << endl;
	}
	*/
	
	

	vector<ll> sum(h * w,0);
	for (int i = d; i < h * w; i++) {
		sum[i] = sum[i - d] + abs(grid[i][1] - grid[i - d][1]) + abs(grid[i][2] - grid[i - d][2]);
		
		//cout << abs(grid[i][1] - grid[i - d][1]) << " "  << abs(grid[i][2] - grid[i - d][2]) << endl;
	}



	cin >> q;

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		r--;
		l--;
		cout << sum[r] - sum[l] << endl;
	}
	
}  



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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

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

  if (a >= 3200) {
    cout << s << BR;
  } else {
    cout << "red" << BR;
  }

  return 0;
}

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

int main()
{
  double a,b,c,d; cin>>a>>b>>c>>d;
  cout << fixed << setprecision(10) << pow(pow(a-c , 2) + pow(b-d, 2), 0.5) << "\n";
}


Measured memory_bytes: 3416
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
using namespace std;

int main()
{
    int n, k;

    cin >> n >> k;

    if((n - (k - 1)) - 1 >= 0 && k  != 1) cout << (n - (k - 1)) - 1;
    else cout << 0;    

    return 0;
}

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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s;
    cin >> s;
    
    int n = (int)s.size();
    
    int cnt = 0;
    for(int i = 0; i < n - 1; i++){
        if(s[i]!=s[i+1]) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 512
import numpy as np

n,m,l = map(int,input().split())
X = [1]*n
Y = [1]*m

for i in range(l):
    x,y,a = map(int,input().split())
    if a == 1:
        for i in range(x):
            X[i] = 0
    elif a == 3:
        for i in range(y):
            Y[i] = 0
    elif a == 2:
        for i in range(x,n):
            X[i] = 0
    else:
        for i in range(y,m):
            Y[i] = 0

c_x = 0
c_y = 0
for x in X:
    if x == 1:
        c_x += 1

for y in Y:
    if y == 1:
        c_y += 1

print(c_x*c_y)

Measured memory_bytes: 12512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,k;
	unsigned long long ans=0;
	cin >> n >> k;

	if(k == 0) ans += (long long)n*n;
	else {
		for(int b=1;b<=n;b++){
			ans += n/b * max(0,b-k) + max(n%b - k+1,0);
		}
	}
	
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define VI vector<int>
#define P pair
#define M map
#define F first()
#define S second()
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define br(c,y,n) cout << ((c)? y : n) << endl

int main(){
    sts(s);
    s.at(5)=' ';
    s.at(13)=' ';
    print(s);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
   int a,b,c,d,e,k;
    
   scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&k);
   if (b-a<=k && c-a<=k && d-a<=k && e-a<=k) puts("Yay!");
   else                                      puts(":(");
   return 0;
}


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

int main(void) {

	int n; cin >> n;
	vector<int>r(n);
	for (int i = 0; i < n; i++)cin >> r.at(i);

	int max_val = -1234567890;
	int min_val = r.at(0);	//初期値を初めの値に設定

	for (int i = 1; i < n; i++) {
		max_val = max(max_val, r.at(i) - min_val);
		min_val = min(min_val, r.at(i));
	}
	cout << max_val << endl;
	return 0;

}


Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main()
{
	double a = 0;
	double b = 0;
	while (cin >> a, cin >> b)
	{
		if (a < 35.5 && b < 71)
		{
			cout << "AAA" << endl;
		}
		else if (a < 37.5 && b < 77)
		{
			cout << "AA" << endl;
		}
		else if (a < 40 && b < 83)
		{
			cout << "A" << endl;
		}
		else if (a < 43 && b < 89)
		{
			cout << "B" << endl;
		}
		else if (a < 50 && b < 105)
		{
			cout << "C" << endl;
		}
		else if (a < 55 && b < 116)
		{
			cout << "D" << endl;
		}
		else if (a < 70 && b < 148)
		{
			cout << "E" << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
  int n;
  cin>>n;
  vector<int> v1;
  vector<int> v2;
  int candy;
  for(int i=0; i<n; i++) {
    cin>>candy;
    v1.push_back(candy);
  }
  for(int i=0; i<n; i++) {
    cin>>candy;
    v2.push_back(candy);
  }

  int max=0,num=0;
  for(int i=0; i<n; i++){
    for(int j=0; j<=i; j++){
      num+=v1[j];
    }
    for(int j=n-1; j>=i; j--){
      num+=v2[j];
    }
    if(max<=num) { max=num;}
    num=0;
   }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   int n, v, minj;
   int A[150];
   int i = 0,
	   j = 0,
	   s = 0;

   scanf("%d", &n);
   while (i < n) {
      scanf("%d", &A[i]);
      i++;
   }

   for (i = 0; i < n - 1; ++i) {
      minj = i;
	  for (j = i; j < n; ++j) {
         if (A[j] < A[minj])
            minj = j;
	  }
	  if (i != minj) {
		  v = A[i];
		  A[i] = A[minj];
		  A[minj] = v;
		  s = s + 1;
	  }
   }
   for (i = 0; i < n; ++i) {
	   printf("%d", A[i]);
	   if (i != n - 1)
		   putchar(' ');
   }
   putchar('\n');
   printf("%d\n", s);
   return 0;
}

Measured memory_bytes: 1780
#include<stdio.h>

void selectionsort(int A[], int n);
int count;

int main(){
  int n, k;
  int A[100];

  scanf("%d", &n);
  for(k = 0; k < n; k++){
    if(k == n-1){
      scanf("%d", &A[k]);
    }else{
      scanf("%d ", &A[k]);
    }
  }

  count = 0;
  selectionsort(A, n);

  for(k = 0; k < n; k++){
    if(k == n-1){
      printf("%d\n", A[k]);
    }else{
      printf("%d ", A[k]);
    }
  }

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

  return 0;
}

void selectionsort(int A[], int n){
  int i, j;
  int min, tmp;

  for(i = 0; i < n; i++){
    min = i;
    for(j = i; j < n; j++){
      if(A[j] < A[min]){
        min = j;
      }
    }
    if(A[i] != A[min]){
      tmp = A[i];
      A[i] = A[min];
      A[min] = tmp;
      count++;
    }
  }
}



Measured memory_bytes: 2088
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  vector<int> a;
  rep(i,4) {
    ll b;
    cin >> b;
    a.pb(b);
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
const int N=200010;
vector <int> q[N];
int fa[N],id[N],ans[N],L[N],R[N],op[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
inline bool cmp(const int &x,const int &y) {return fa[x]<fa[y];}
inline int query(vector <int> &v,int x) {
    int l=0,r=v.size()-1;
    while(l<=r) {
	int mid=(l+r)>>1;
	if(v[mid]<=x) l=mid+1;
	else r=mid-1;
    }
    return r;
}
int main() {
    int n,k,m;
    cin>>n>>k>>m;
    for(int i=1;i<=n;i++) fa[i]=i;
    for(int i=1;i<=k;i++) {
	int x=find(gi()),y=find(gi());
	if(x!=y) fa[x]=y;
    }
    for(int i=1;i<=n;i++) find(i),op[i]=i;
    sort(op+1,op+1+n,cmp);
    for(int i=1;i<=n;i++) id[op[i]]=i;
    for(int i=1,j;i<=n;i++) {
	if(fa[op[i]]!=fa[op[i-1]]) j=i;
	L[i]=j;
    }
    for(int i=n,j;i;i--) {
	if(fa[op[i]]!=fa[op[i+1]]) j=i;
	R[i]=j;
    }
    for(int i=1;i<=n;i++) fa[i]=i;
    for(int i=1;i<=m;i++) {
	int x=find(gi()),y=find(gi());
	if(x!=y) fa[x]=y;
    }
    for(int i=1;i<=n;i++) q[find(i)].push_back(id[i]);
    for(int i=1;i<=n;i++) sort(q[i].begin(),q[i].end());
    for(int i=1;i<=n;i++) {
	int x=find(i);
	printf("%d ",query(q[x],R[id[i]])-query(q[x],L[id[i]]-1));
    }
    return 0;
}

Measured memory_bytes: 15744
s = input() + "R"
p = []
start = 0
for i in range(len(s)):
    if s[i] == "R":
        if s[i - 1] == "L":
            end = i - 1
            p.append([start, end])
            start = i
p2 = []
for i in p:
    for i in range(i[0], i[1] + 1):
        if s[i] == "L" and s[i - 1] == "R":
            p2.append([i - 1, i])
num = []
for i in range(len(p)):
    l1, l2, r2, r1 = p[i][0], p2[i][0], p2[i][1], p[i][1]
    for j in range(l1, r1 + 1):
        if j < l2 or j > r2:
            num.append(0)
        else:
            if j % 2 == 0:
                num.append((r1 // 2) - ((l1 - 1) // 2))
            else:
                num.append(((r1 + 1) // 2 - (l1 // 2)))
for i in num:
    print(i, end = " ")
print()

Measured memory_bytes: 21308
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

struct Vec {
  ll x = 0, y = 0;

  ll cross(const Vec& v) {
    return x*v.y - y*v.x;
  }

  ll dot(const Vec& v) {
    return x*v.x + y*v.y;
  }

  void operator+=(const Vec& v) {
    x += v.x; y += v.y;
  }

  double abs() {
    return sqrt(x*x + y*y);
  }
};

const ll MAX_N = 100;
ll N;
Vec vec[MAX_N];

int main() {

  cin >> N;
  rep(i, N) {
    cin >> vec[i].x >> vec[i].y;
  }

  double ans = 0;
  for (ll i = 0; i < N; ++i) {
    Vec tmp;
    for (ll j = 0; j < N; ++j) {
      if (vec[i].cross(vec[j]) > 0) tmp += vec[j];
    }
    ans = max(ans, tmp.abs());
  }

  for (ll i = 0; i < N; ++i) {
    Vec tmp;
    for (ll j = 0; j < N; ++j) {
      if (vec[i].cross(vec[j]) > 0) tmp += vec[j];
      else if (vec[i].cross(vec[j]) == 0 && vec[i].dot(vec[j]) > 0) tmp += vec[j];
    }
    ans = max(ans, tmp.abs());
  }

  for (ll i = 0; i < N; ++i) {
    Vec tmp;
    for (ll j = 0; j < N; ++j) {
      if (vec[i].cross(vec[j]) < 0) tmp += vec[j];
      else if (vec[i].cross(vec[j]) == 0 && vec[i].dot(vec[j]) > 0) tmp += vec[j];
    }
    ans = max(ans, tmp.abs());
  }

  printf("%.14f\n", ans);

  return 0;
}


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

int main(){
    int N; cin >> N;
    long long a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    int right=0;
    long long sum=0;
    long long ans=0;
    for(int left=0;left<N;left++){
        while(right<N&&((sum^a[right])==(sum+a[right]))){
            sum+=a[right];
            right++;
        }
        ans+=right-left;
        if(right==left) right++;
        else{
            sum-=a[left];
        }
    }
    cout << ans << endl;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, class Op = multiplies<T>>
constexpr T power(T a, long long n, Op op = Op(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  for (long long a = -200; a < 200; ++a) {
    for (long long b = -200; b < 200; ++b) {
      if (power(a, 5) - power(b, 5) == x) {
        cout << a << ' ' << b << '\n';
        exit(0);
      }
    }
  }
}


Measured memory_bytes: 3608
n = int(input())
A = list(map(int, input().split()))

neg_count = 0
neg_candidate = abs(A[0])
for a in A:
    if a <= 0:
        neg_count += 1
    neg_candidate = min(neg_candidate, abs(a))

B = list(map(abs, A))

if neg_count % 2 == 0:
    print(sum(B))

else:
    print(sum(B)-2*neg_candidate)


Measured memory_bytes: 14332
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

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

  int ma = max({A, B, C});

  int ans = A + B + C - ma;
  for (int i = 0; i < K; i++) ma *= 2;
  ans += ma;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;


template <typename T> T gcd(T a, T b) {if(b == 0) return a;return gcd(b,a%b);}
template <typename T> T extgcd(T a, T b, T& x, T& y){
    T d = a;
    if(b != 0){d = extgcd(b,a%b,y,x); y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> T modpow(T x, T n, T m) {
    if(n==0) return 1;
    T resp = modpow(x*x%m,n/2,mod);
    if(n&1) resp = resp*x%m;
    return resp;
}
template <typename T> T modinverse(T a, T m) {
    T x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
struct combination {
    ll M = mod;
    vector<ll> fact;vector<ll> ifact;
    combination(ll n):fact(n+1),ifact(n+1){
        fact[0]=1;ifact[0]=1;
        for (ll i = 0; i<n; i++) {fact[i+1] = fact[i]*(i+1) % M;ifact[i+1] = ifact[i]*modpow(i+1, M-2, M) % M;}
    }
    ll com(ll a, ll b){
        if(a == 0 && b == 0)return 1;if(a < b || a < 0)return 0;
        ll tmp = ifact[a-b]* ifact[b] % M;
        return tmp * fact[a] % M;
    }
};




int main()
{
    int N,K;
    cin >> N >> K;
    vl A(N);in(N,A);
    sor(A);
    combination C((ll)N);

    ll ans = 0;
    rep(i,N){
        ans += A[i]*C.com((ll)i,(ll)K-1)%mod;
        ans %= mod;
        ans += mod;
        ans -= A[i]*C.com((ll)(N-i-1),ll(K-1))%mod;
        ans %= mod;
    }
    
    out(ans);


    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 2e3 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

LL d[MAXN][MAXN];
LL min(LL a, LL b){
  return a>b?b:a;
}


int main(){
  fio();
  LL n,x,y; cin>>n>>x>>y;
  vector <LL> an(n+1);
  for1(i,n){
    for(int j=i+1;j<=n;j++){
      if(i<=x && j>=y){
        an[j-i-(y-x)+1]++;
      }
      else if( i>=x && j>=y){
        LL pp = min( (i-x) + 1LL + (j-y), (j-i));
        an[pp] ++;
      }
      else if(i>=x && j<=y){
        LL pp = min( (i-x) + 1LL + (y-j), (j-i));
        an[pp]++;
      }
      else if(i<=x && y>=j && j>=x)
      {
        LL pp = min(x-i + 1LL + (y-j),(j-i));
        an[pp]++;
      }
      else an[j-i]++;
    //if(an[5]) cout<<i<<" "<<j<<endl;
    }
  }
  for1(i,n-1) cout<<an[i]<<endl;

  return 0;
}



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

int main(void){
    int n;
    std::cin >> n;
    std::vector<int> a(n), oa(n);
    int tmp;
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
    }
    oa = a;
    std::sort(a.begin(), a.end());
    int max2 = a[n-2];
    int max = a[n-1];
    for(int i = 0; i < n; i++){
        if(oa[i] == max){
            std::cout << max2 << std::endl;
        }else{
            std::cout << max << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4816
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
struct cxk{ll s,c,o;}s[100010];
int pr[100010],P;
bool yes[100010];
std::unordered_map<ll,ll>M;
cxk fuck(ll x){
	ll r=1,o=1;
	for(ll j=1;pr[j]<=2154;++j)
		if(x%pr[j]==0){
			int e=0;while(x%pr[j]==0)++e,x/=pr[j];
			e%=3;for(int i=0;i<e;++i)r*=pr[j];
			if(e)for(int i=e;i<3;++i)o*=pr[j];
		}
	if(x!=1){
		ll qt=int(sqrt(x)+0.5);
		if(qt*qt==x)o*=qt;
		else if(1.0*o*x*x>1e18)o=2e18;
		else o*=x*x;
	}
	return{r*x,1,o};
}
int main(){
	int n=gi(),ans=n;
	for(int i=2;i<=100000;++i){
		if(!yes[i])pr[++P]=i;
		for(int j=1;j<=P&&i*pr[j]<=100000;++j){
			yes[i*pr[j]]=1;
			if(i%pr[j]==0)break;
		}
	}
	for(int i=1;i<=n;++i)s[i]=fuck(gi()),s[i].c=1;
	std::sort(s+1,s+n+1,[](cxk a,cxk b){return a.s<b.s;});
	for(int i=1;i<=n;++i)if(s[i].s==s[i-1].s)s[i].c=s[i-1].c+1,s[i-1].c=-1;else s[i].c=1;
	for(int i=1;i<=n;++i)if(s[i].c==-1)s[i]=s[n],--n,--i;
	std::sort(s+1,s+n+1,[](cxk a,cxk b){return a.s<b.s;});
	for(int i=1;i<=n;++i){
		if(s[i].s==1)ans-=s[i].c-1;
		else{
			if(M.count(s[i].o))ans-=std::min(s[i].c,M[s[i].o]);
			M[s[i].s]=s[i].c;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 6820
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define inf (1LL<<60)
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x 
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

class segtree
{
    ll *tree;
    ll *upd;
    int n;
public:
    segtree(int n)
    {
        this->n = n;
        tree = new ll[4*n];
        upd = new ll[4*n];
        for(int i=0;i<4*n;i++)
            tree[i] = upd[i] = 0;
    }
    void push(int node)
    {
        tree[2*node+1] += upd[node];
        tree[2*node+2] += upd[node];
        upd[2*node+1] += upd[node];
        upd[2*node+2] += upd[node];
        upd[node] = 0;
    }
    void update(int li, int ri, ll val)
    {
        lazyProp(0,0,n-1,li,ri,val);
    }
    void lazyProp(int node, int ln, int rn, int li, int ri, ll val)
    {
        if(ri < ln || rn < li)
            return;
        if(li <= ln && rn <= ri)
        {
            tree[node] += val;
            upd[node] += val;
            return;
        }
        int mid = (ln + rn)/2;
        push(node);
        lazyProp(2*node + 1, ln, mid, li, ri, val);
        lazyProp(2*node + 2, mid + 1, rn, li, ri, val);
        tree[node] = max(tree[2*node + 1], tree[2*node + 2]);
    }
    ll query(int li, int ri, int node = 0, int ln = 0, int rn = - 1)
    {
        rn = (rn == -1)?n-1:rn;
        if(ri < ln || rn < li)
            return -(inf);
        if(li <= ln && rn <= ri)
        {
            return tree[node];
        }
        int mid = (ln+rn)/2;
        push(node);
        ll v1 = query(li, ri, 2*node+1, ln, mid);
        ll v2 = query(li, ri, 2*node+2, mid+1, rn);
        return max(v1, v2);
    }
};

struct interval
{
    ll score;
    int open;
    int close;
};

ll solve(vector<interval>& v, int n)
{
        segtree dp(n);
        vector<int> endings[n];
        for(int i = 0; i < v.size(); i++)
            endings[v[i].close]  .push_back(i);
        for(int i : endings[0])
        {
            dp.update(v[i].open, v[i].close, v[i].score);
        }
        for(int i = 1; i < n; i++)
        {
             ll large = max(dp.query(0, i-1), 0LL);
             dp.update(i,i,large);
             for(int j : endings[i])
                dp.update(v[j].open, v[j].close, v[j].score);
        }
        return max(0LL,dp.query(0, n-1));
}

int main() {
   int n,m; 
   cin >> n >>m;
   vector<interval> v(m);
   for(int i = 0; i < m; i++)
    {
        cin >> v[i].open >> v[i].close >> v[i].score;
        v[i].open--;
        v[i].close--;
    }
   cout << solve(v, n);
   return 0;
}


Measured memory_bytes: 26752
Public Class Program
  Shared Sub Main()
    Dim nm As Long() = Cin.LngArr()
    Dim n As Long = nm(0)
    Dim m As Long = nm(1)
    Dim ok(0 To n - 1) As Boolean
    Dim ng(0 To n - 1) As Integer
    For i As Long = 0 To n - 1
      ok(i) = False
      ng(i) = 0
    Next
    Dim okCount As Long = 0
    Dim ngCount As Long = 0
    For i As Long = 0 To m - 1
      Dim ps As String() = Cin.StrArr()
      Dim p As Long = Long.Parse(ps(0))
      Dim s As String = ps(1)
      If Not ok(p - 1) Then
        If s = "AC" Then
          ok(p - 1) = True
          okCount += 1
          ngCount += ng(p - 1)
        Else
          ng(p - 1) += 1
        End If
      End If
    Next
    Console.WriteLine(okCount.ToString() & " " & ngCount.ToString())
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 24784
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    long A = sc.nextLong();
    long B = sc.nextLong();
    long C = sc.nextLong();
    long D = sc.nextLong();

    sc.close();

    long lcm_ = lcm(C, D);

    long A1 = A / C;
    long B1 = B / C;
    long AB1 = B1 - A1;
    if (A % C == 0) {
      AB1++;
    }

    long A2 = A / D;
    long B2 = B / D;
    long AB2 = B2 - A2;
    if (A % D == 0) {
      AB2++;
    }

    long A3 = A / lcm_;
    long B3 = B / lcm_;
    long AB3 = B3 - A3;
    if (A % lcm_ == 0) {
      AB3++;
    }

    long AB = AB1 + AB2 - AB3;

    System.out.println(B - A + 1 - AB);

  }

  public static long gcd(long x, long y){

    if (y == 0) {
      return x;
    }
    
    return gcd(y, x % y);
    
  }

  public static long lcm(long x, long y) {

		return x / gcd(x, y) * y;
  
  }

}

Measured memory_bytes: 22740
N = int(input())
C, S, F = [], [], []
for i in range(N-1):
    ci, si, fi = map(int, input().split())
    C.append(ci)
    S.append(si)
    F.append(fi)

for i in range(N):
    T = 0
    for j in range(i, N-1):
        if S[j] > T:
            T = S[j]

        if T % F[j] != 0:
            T += F[j] - T%F[j]

        T += C[j]

    print(T)


Measured memory_bytes: 3064
def row():
  c=0
  for y in range(HEIGHT):
    for x in range(WIDTH):
      if A[y][x]!=-1:
        break
    else:
      c+=1
  return c


def col():
  c=0
  for x in range(WIDTH):
    for y in range(HEIGHT):
      if A[y][x]!=-1:
        break
    else:
      c+=1
  return c


def obl():
  c=0
  for z in range(HEIGHT):
    if A[z][z]!=-1:
      break
  else:
    c+=1
  
  y=0
  for x in range(WIDTH-1,-1,-1):
    if A[y][x]!=-1:
      break
    y+=1
  else:
    c+=1
  return c  
    

def main():
  for b in B:
    for y in range(HEIGHT):
      for x in range(WIDTH):
        if A[y][x]==b:
          A[y][x]=-1
  cnt=row()+col()+obl()
  print('Yes' if cnt else 'No')

  
if __name__=='__main__':
  HEIGHT=3
  WIDTH=3
  A=[[int(a) for a in input().split()] for y in range(HEIGHT)]
  N=int(input())
  B=[int(input()) for n in range(N)]
  main()

Measured memory_bytes: 9140
def examA():
    A, B = LI()
    if B%A==0:
        ans = A+B
    else:
        ans = B-A
    print(ans)
    return

def examB():
    N, M = LI()
    Flag = [0]*M
    for i in range(N):
        K = LI()
        for j in range(1,K[0]+1):
            Flag[K[j]-1] +=1
    ans = 0
    for i in Flag:
        if i==N:
            ans +=1
    print(ans)
    return

def gcd(x,y):
    if y==0:
        return x
    while(y!=0):
        x, y = y,x%y
    return x
def examC():
    N = I()
    A = LI()
    cur = A[0]
    for i in range(N-1):
        cur = gcd(cur,A[i+1])
    ans = cur
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()


Measured memory_bytes: 15508
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif

    string s;
    cin>>s;
    int cur=0;
    while (cur<s.size())
    {
        if (s[cur]!='h')
            break;
        if (s[cur]=='h'&&cur==(int)s.size()-1)
            break;
        else
        {
            if (s[cur]=='h'&&s[cur+1]!='i')
                break;
            else
                cur+=2;
        }

    }
    if (cur==s.size())
        cout<<"Yes";
    else
        cout<<"No";



}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define X real()
#define Y imag()
#define EQ(a,b) (abs((a)-(b))<EPS)
typedef complex<double> Po;
double isIntersect(Po p1,Po p2,Po p3,Po p4)
{
	//straight line(p1,p2) and line segment(p3,p4) are
	//if(n<0) crossed if(n==0) parallel if(n>0) not crossed
	return ((p1.X-p2.X)*(p3.Y-p1.Y) + (p1.Y-p2.Y)*(p1.X-p3.X)) * ((p1.X-p2.X)*(p4.Y-p1.Y) + (p1.Y-p2.Y)*(p1.X-p4.X));
}
int main()
{
	double x[4];
	double y[4];
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3])!=EOF)
	{
	Po p[4];
	for(int i=0;i<4;i++)
	{
		p[i].X=x[i];
		p[i].Y=y[i];
	}
	if(isIntersect(p[0],p[2],p[1],p[3])>0.0||isIntersect(p[1],p[3],p[0],p[2])>0.0)
	{
		cout << "NO" << endl;
	}
	else
	{
		cout << "YES" << endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<map>
#include<cstring>

using namespace std;

const int MAX = 51;

string text, key;
map<char,int> M;
int numKey[MAX];

typedef long long ll;

bool input(){
  text = "";

  string s = "";
  if(!getline(cin,s)) return false;
  if(s == "") return false;
  text = s;
  while(getline(cin,s)&&s!="") text += s;
  getline(cin,s);
  key = s;
  getline(cin,s); // for blank line
  return true;
}



void solve(){

  memset(numKey,0,sizeof(numKey));

  M.clear();
  for(int i = 0; i < (int)key.length(); i++)
    M[key[i]] = i;

  ll need = (1LL<<key.length())-1;

  string first = "";
  int num = 0;

  int s = 0, t = 0;

  while(s <= t && t <= (int)text.length()){
    if(need == 0){
      // if(text.size() > 400 && t-s < 50) cout << text.substr(s,t-s) << endl;
      if(first != "" && (int)first.length() == t-s){
	num++;
      }
      if(first == "" || (int)first.length() > t-s){
	first = text.substr(s,t-s);
	num = 1;
      }

      if(M.count(text[s]) != 0){
	numKey[M[text[s]]]--;
	if(numKey[M[text[s]]] == 0) need |= (1LL<<M[text[s]]);
      }
      s++;
    }else{
      if(M.count(text[t]) != 0){
	if(need&(1LL<<M[text[t]])) need -= (1LL<<M[text[t]]);
	numKey[M[text[t]]]++;
      }
      t++;
    }
  }
  // cout << "min " << minT << endl;
  if(num == 0) cout << num << endl;
  else{
    cout << num << endl << endl;

    for(int i = 0; i < (int)first.length(); i++){
      cout << first[i];
      if((i+1)%72 == 0) cout<<endl;
    }
    if((int)first.size()%72)cout << endl;
  }
  cout << endl;
}	 

int main(){

  // bool isFirst = true;
  while(input()){
    // if(isFirst) isFirst = false;
    // else cout << endl;
    solve();
  }
  return 0;
}

Measured memory_bytes: 1832
#include<stdio.h>

int main(void){

	int s;

	int min,hou;

	scanf("%d",&s);

	hou = s/3600;
	s -= hou*3600;
	min = s/60;
	s -= min*60;


	printf("%d:%d:%d\n",hou,min,s);

	return 0;

}

Measured memory_bytes: 592
S=input()
n=len(S)
ans=0
 
for paint in range(2**(n-1)):
	temp_S=S[0]
 
	for i in range(n-1):
		if (paint>>i)&1==1:
			temp_S+="+"
		temp_S+=S[i+1]
 
	ans+=sum(map(int, temp_S.split("+")))
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
using namespace std;

int main() {
	long long x, y;
	cin >> x >> y;
	int ans = 0;
	while (x <= y) {
		x *= 2;
		ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
def insertion_sort(A, N):
    for i in range(1, N):
        for s in A:
            tmp = str(s) if A[0] == s else " "+str(s)
            print(tmp, end="")
        print()

        j = i-1
        v = A[i]
        while v < A[j] and j >= 0:
            A[j+1] = A[j]
            j = j-1
        A[j+1] = v
    for s in A: 
        tmp = str(s) if A[0] == s else " "+str(s) 
        print(tmp, end="")
    print()
    
if __name__ == "__main__":
    N = int(input())
    A = [int(x) for x in input().split()]

    insertion_sort(A, N)
    

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

yakusu = []
ans = 10**15 

for x in range(1,int(n**0.5)+1):
    if(n % x == 0):
        yakusu.append(x)
        if (x != n // x):
            yakusu.append(n // x)
yakusu.sort()

for x in yakusu:
    if(ans > len(str(max(x,n // x)))):
        ans = len(str(max(x,n // x)))
print(ans)


Measured memory_bytes: 3060