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

#define what_is(x) cout << #x << " is " << x << endl;
#define PI acos(-1)
#define hell 1000000007
#define HELL 998244353
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
// #define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define bug(n) {outl(n);return;}
#define pii pair<int,int>
#define lim 9223372036854775805
#define ninf -9223372036854775802
#define M 1000000007
#define eps 1e-9
#define MAX 10
#define N 500001
#define db(a) for(auto it:a) {cout<<it<<" ";}cout<<endl;
ll prime[MAX];
ll fact[MAX];

const long long INF64 = 1e18;
ll vpow(ll a,ll b,ll p){
    if(b==0)
        return 1;
    if(b==1)
            return a;
    ll temp=vpow(a,b/2,p);
    temp*=temp;
    temp%=p;
    if(b%2==0)
        return temp;
    temp=temp*a;
    temp%=p;
    return temp;
}

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


ll inverseMod(ll a,ll b,ll p){
    if(b==0)
        return 1;
    ll temp=vpow(b,p-2,p);
    ll ans=temp*a;
    ans%=p;
    return ans;
}
void sieve()
{
    prime[0] = prime[1] = 1;
    for (ll i = 2; i < MAX; i++) {
        if (prime[i] == 0) {
            for (int j = i * 2; j < MAX; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
            prime[i] = i;
        }
    }
}
ll max(ll a, ll b)
{
    return a>b?a:b;
}

void factorial(){
    fact[0]=1;
    fact[1]=1;
    rep(i,2,MAX){
        fact[i]=(fact[i-1]*i);
        // fact[i]%=M;
    }
}
ll rand(ll a,ll b){
    return a+rand()%(b-a+1);
}

void solve(ll ttt)
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*c, max(b*d, max(b*c, a*d)));
    

}

int main(){
    io;
    // sieve();
    // factorial();
#ifndef ONLINE_JUDGE
    //
    //freopen("input1.txt","r",stdin);
    // freopen("output1.txt","w",stdout);
#endif
    ll t=1;
     //cin>>t;
    fix(12);
    rep(q,1,t+1){
         //cout<<"Case #"<<q<<": ";
         //cout<<"Test Case : "<<q<<endl;
         solve(q);
    }
    return 0;

}




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

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

using namespace std;

const double EPS=1e-8;
const double INF=1e77;

template<class T>
struct point{
	T x,y;
	point &operator+=(const point &a){ x+=a.x; y+=a.y; }
	point operator+(const point &a)const{ return (point){x+a.x,y+a.y}; }
	point operator-(const point &a)const{ return (point){x-a.x,y-a.y}; }
};

template<class T>
point<T> operator*(T c,const point<T> &a){ return (point<T>){c*a.x,c*a.y}; }

point<double> &operator/=(point<double> &a,double c){ a.x/=c; a.y/=c; return a; }

template<class T>
double abs(const point<T> &a){ return sqrt(a.x*a.x+a.y*a.y); }

template<class T>
T abs2(const point<T> &a){ return a.x*a.x+a.y*a.y; }

template<class T>
T dot(const point<T> &a,const point<T> &b){ return a.x*b.x+a.y*b.y; }

int simulate(int n,point<double> *dog,const double *v,point<double> pf,point<double> vf){
	double t[10]; // 犬 i がフリスビーを取得する時刻
	rep(i,n){
		double a=abs2(vf)-v[i]*v[i];
		double b=-dot(vf,dog[i]-pf);
		double c=abs2(dog[i]-pf);
		if(abs(a)>EPS){
			t[i]=INF;
			if(b*b-a*c>0){
				if((-b+sqrt(b*b-a*c))/a>-EPS) t[i]=min(t[i],(-b+sqrt(b*b-a*c))/a);
				if((-b-sqrt(b*b-a*c))/a>-EPS) t[i]=min(t[i],(-b-sqrt(b*b-a*c))/a);
			}
		}
		else if(abs(b)>EPS){
			t[i]=-c/(2*b);
			if(t[i]<-EPS) t[i]=INF;
		}
		else{
			t[i]=(c<EPS?0:INF);
		}
	}

	int i_opt=min_element(t,t+n)-t;
	if(t[i_opt]>EPS){
		rep(i,n) if(t[i]<INF/2) {
			point<double> vec=(pf+t[i]*vf)-dog[i];
			vec/=abs(vec);
			dog[i]+=v[i]*t[i_opt]*vec;
		}
	}
	return i_opt;
}

int main(){
	for(int n,m;scanf("%d%d",&n,&m),n;){
		point<double> dog[10];
		double v[10];
		rep(i,n) scanf("%lf%lf%lf",&dog[i].x,&dog[i].y,v+i);

		int ans[10]={};
		while(m--){
			point<double> pf,vf;
			scanf("%lf%lf%lf%lf",&pf.x,&pf.y,&vf.x,&vf.y);
			ans[simulate(n,dog,v,pf,vf)]++;
		}

		rep(i,n) printf("%d%c",ans[i],i<n-1?' ':'\n');
	}

	return 0;
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    REPS(i, 9)
    {
        REPS(j, 9)
        {
            cout << i << "x" << j << "=" << i * j << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra(){
	int minv;
	int d[MAX], color[MAX];
	
	for(int i=0;i < n;++i){
		d[i] = INFTY;
		color[i] = WHITE;
	}
	
	d[0] = 0;
	color[0] = GRAY;
	while(1){
		minv = INFTY;
		int u = -1;
		for(int i=0;i < n;++i){
			if(minv > d[i] && color[i] != BLACK){
				u = i;
				minv = d[i];
			}
		}
		if(u == -1)break;
		color[u] = BLACK;
		for(int v = 0;v < n;++v){
			if(color[v] != BLACK && M[u][v] != INFTY){
				if(d[v] > d[u] + M[u][v]){
					d[v] = d[u] + M[u][v];
					color[v] = GRAY;
				}
			}
		}
	}
	for(int i=0;i < n;++i){
		cout << i << " ";
		if(d[i] == INFTY) cout << -1 << endl;
		else cout << d[i] << endl;
	}
}

int main(){
	cin >> n;
	
	for(int i=0; i < n;++i){
		for(int j=0; j < n;++j){
			M[i][j] = INFTY;
		}
	}
	
	int k, c, u, v;
	for(int i=0;i < n;++i){
		cin >> u >> k;
		for(int j=0;j < k;++j){
			cin >> v >> c;
			M[u][v] = c;
		}
	}
	
	dijkstra();
	
	return 0;
}


Measured memory_bytes: 3116
def binarySearch(A, K):
    left = 1
    # right = n
    right = max(A)
    while left < right:
        mid = (left + right) // 2
        cost = sum(map(lambda x: (x-1)//mid, A))
        # print(left, right, mid)
        # print(K, cost)
        if K >= cost:
            right = mid
        else:
            left = mid + 1
    # return NOT_FOUND
    # return mid
    
    return left


N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
# print(sorted(A))
print(binarySearch(A, K))

Measured memory_bytes: 94120
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;


int main()
{
    int nb_cas;
    cin>>nb_cas;
    while(nb_cas--)
    {
        vector<int> v(3);
        cin>>v[0]>>v[1]>>v[2];
        sort(v.begin(),v.end());
        if(v[0]*v[0]+v[1]*v[1] == v[2]*v[2]) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define sqr(x) ((x) * (x))
using namespace std;
int a[3], p, q, r;
int main() {
	ios::sync_with_stdio(false);
	while(cin >> a[0] >> a[1] >> a[2]) {
		sort(a, a + 3);
		if(a[0] + a[1] <= a[2]) break;
		if(sqr(a[0]) + sqr(a[1]) == sqr(a[2])) p++;
		else if(sqr(a[0]) + sqr(a[1]) > sqr(a[2])) q++;
		else r++;
	}
	cout << p + q + r << ' ' << p << ' ' << q << ' ' << r << endl;
	return 0;
}

Measured memory_bytes: 3172
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int N; cin >> N; map<ll, int>mp; bool zero = true;
  rep(i, N){
    ll a; cin >> a; mp[a]++; if(a!=0) zero = false;
  }
  if(zero){
    cout << "Yes" << endl; return 0;
  }
  if(mp.size()==2){
    for(auto t: mp){
      if(t.first!=0){
        if(t.second==2*mp[0]){
          cout << "Yes" << endl; return 0;
        }
      }
    }
  }
  int cnt = 0; ll tmp[3];
   if(N%3 || mp.size()!=3){
    cout << "No" << endl;  return 0;
  }
  for(auto t: mp){
    if(t.second!=N/3){
      cout << "No" << endl; return 0;
    }
    tmp[cnt] = t.first;
    cnt++;
  }
  if((tmp[0]^tmp[1])!=tmp[2]){
    cout << "No" << endl; return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 8392
#include <stdio.h>


void trace(int A[],int N) {
	int i;
	for(i=0;i<N;i++) {

		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}


void insertionSort(int A[], int N) {
	int i,j,v;
	for(i=1;i<N;i++) {
		v=A[i];
		j=i-1;
		while(j>=0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1]=v;
		trace(A,N);
	}
}

int main(void)
{
	int N, i, j;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	trace(A,N);
	insertionSort(A,N);
	return 0;
}


Measured memory_bytes: 2072
W,H,N=map(int,input().split())
XYA=[list(map(int,input().split())) for i in range(N)]

MINX=0
MAXX=W
MINY=0
MAXY=H

for x,y,a in XYA:
    if a==1:
        MINX=max(MINX,x)
    if a==2:
        MAXX=min(MAXX,x)
    if a==3:
        MINY=max(MINY,y)
    if a==4:
        MAXY=min(MAXY,y)

print(max(MAXY-MINY,0)*max(MAXX-MINX,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	long long ans = 0;
	int mx_here = a[0];
	for(int i = 1; i < n; i++){
		if(mx_here > a[i]) ans += mx_here - a[i];
		mx_here = max(mx_here, a[i]);
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 3972
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
	string f, s, t;
	cin >> f >> s >> t;

	cout << char(f[0] - 32) << char(s[0] - 32) << char(t[0] - 32);
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int red[][] = new int[N][2];
		int blue[][] = new int[N][2];
		boolean paired[] = new boolean[N];
		int ans = 0;
		for (int i = 0; i < N; i++) {
			red[i][0] = sc.nextInt();
			red[i][1] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			blue[i][0] = sc.nextInt();
			blue[i][1] = sc.nextInt();
		}
		//青をx座標で昇順
		Arrays.sort(blue, (a,b) -> a[0]-b[0]);
		//赤をy座標で昇順
		Arrays.sort(red, (a,b) -> a[1]-b[1]);
		for (int i = 0; i < N; i++) {
			for (int j = N-1; j >= 0; j--) {
				//x座標が青>赤、y座標が青>赤、ペアになっていない点
				if (blue[i][0]>red[j][0] && blue[i][1]>red[j][1] && !paired[j]) {
					ans ++;
					paired[j] = true;
					break;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 29136
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
typedef long long ll;
using namespace std;
const ll MOD = 998244353;
int N, D[100001];
ll C[100001];

int main() {
  INCANT;
  cin >> N;
  rep(i, N) {
    cin >> D[i];
    C[D[i]]++;
  }
  ll ans = (C[0]>1 || D[0]!=0)?0ll:1ll;
  for (int i=1; i<N; i++) {
    ans*=C[D[i]-1];
    ans%=MOD;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


vll edge[MAX];

void dfs(ll cur, ll par) {
  if (cur != 1) {
    rep(i, edge[cur].size() - 1) {
      (ans *= m - 2 - i) %= mod;
    }
  }
  else {
    rep(i, edge[cur].size()) {
      (ans *= m - 1 - i) %= mod;
    }
  }
  rep(i, edge[cur].size()) {
    ll to = edge[cur][i];
    if (to == par) continue;
    dfs(to, cur);
  }
}


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


  
  cin >> n >> m;
  ans = m;
  rep(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    edge[a].pb(b);
    edge[b].pb(a);
  }
  dfs(1, -1);
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 12160
import sys

s_prime, t = sys.stdin.read().split()
s = list(s_prime)
ls = len(s)
lt = len(t)

def main():
    ng = 'UNRESTORABLE'

    if ls < lt:
        return ng

    for i in range(ls-lt, -1, -1):
        t_prime = s[i:i+lt]
        for j in range(lt):
            letter = t_prime[j]
            if (letter != '?') and (letter != t[j]):
                break
        else:
            for j in range(lt):
                s[i+j] = t[j]
            break
    else:
        return ng
    
    ans = ''.join(s).replace('?', 'a')
    return ans
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
use std::io;
pub trait ExRead {
    fn read_line(&mut self) -> io::Result<String>;
    fn read_to_string(&mut self) -> io::Result<String>;
}

impl<'a> ExRead for io::StdinLock<'a> {
    fn read_line(&mut self) -> io::Result<String> {
        let mut buf = String::new();
        io::BufRead::read_line(self, &mut buf).map(|_| buf)
    }

    fn read_to_string(&mut self) -> io::Result<String> {
        self.read_line().map(|s| s.trim().to_string())
    }
}

fn main() {
    let r;

    {
        let stdin = std::io::stdin();
        let mut lkin = stdin.lock();
        r = lkin.read_to_string().unwrap().parse::<f64>().ok().unwrap();
    }

    println!("{}", r * 8f64 * 1f64.atan())
}


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

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

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,d;
    cin>>n>>d;
    d*=2;
    d++;
    cout<<(n+d-1)/d<<endl;
}

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

int main(){
	int am,pm;
	while(~scanf("%d %d",&am,&pm)){
		if(am == pm && pm == 0) break;
		int maxV = -1;
		char alph;
		if(maxV < am+pm){
			alph = 'A';
			maxV = am+pm;
		}
		for(int i=0;i<4;i++){
			scanf("%d %d",&am,&pm);
			if(maxV < am+pm){
				alph = 'A'+i+1;
				maxV = am+pm;
			}
		}
		printf("%c %d\n",alph,maxV);
	}
}

Measured memory_bytes: 3192
def main():
    S = input()
    for i in range(len(S)):
        if i % 2 == 0:
            if S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
                pass
            else:
                print("No")
                exit()
        else:
            if S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
                pass
            else:
                print("No")
                exit()
    print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main() {
  int n;
  while(cin>>n && n!=0) {
    int pointA = 0, pointB = 0;
    int tmpA, tmpB;
    for(int i=0; i<n; i++) {
      cin>>tmpA>>tmpB;
      if(tmpA > tmpB) {
        pointA += tmpA+tmpB;
      }
      else if(tmpA < tmpB) {
        pointB += tmpA+tmpB;
      }
      else {
        pointA += tmpA;
        pointB += tmpB;
      }
    }
    cout<<pointA<<" "<<pointB<<endl;
  }
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  string cur="";
  string pre="";
  int ans=0;
  for(int i=0;i<s.size();i++){
    cur+=s[i];
    if(pre!=cur){
       pre=cur;
       cur="";
       ans++;
    }
  }
  cout<<ans;
}
     

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
#define MOD 1000000007
#define MN 200000
#define ll long long 
 
int main(){
    int n;
    cin >>n;
    ll c;
    ll r=0;
    ll m=0;
    for(int i=0;i<n;i++){
        cin >>c;
        m=((c*c)%MOD+m)%MOD;
        r=(c%MOD+r)%MOD;
    }
    r=(r*r)%MOD;
    r=(r-m+MOD)%MOD;
    r*=(MOD+1)/2;
    r%=MOD;
    cout <<r;
 
}


Measured memory_bytes: 3600
N,L=map(int,input().split())
a=list(map(int,input().split()))

aa_max=-1
aa_i=-1
for i in range(N-1):
  if a[i]+a[i+1]>aa_max:
    aa_max=a[i]+a[i+1]
    aa_i=i
#print(aa_max,aa_i)

if aa_max<L:
  print("Impossible")
else:
  print("Possible")
  for i in range(aa_i):
    print(i+1)
  for i in range(N-2,aa_i-1,-1):
    print(i+1)

Measured memory_bytes: 14052
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mem(a,val) memset(a,(val),sizeof((a)))
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define decimal(n)  cout << fixed ; cout << setprecision((n));
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define f first 
#define s second
#define all(v) v.begin(), v.end()
#define endl "\n"
#define lcm(m,n) (m)*((n)/__gcd((m),(n)))
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(ll (i)=1;(i)<(n);(i)++)
#define repa(i,n,a) for(ll (i)=(a);(i)<(n);(i)++)
#define repr(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define tr(c,it) for(auto (it)=c.begin();(it)!=c.end();++(it))
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define M 1000000007
#define MM 998244353
#define sz(x) (ll)x.size()
#define ub upper_bound
#define lb lower_bound
#define pcnt(x) __builtin_popcountll(x)
#define N 1000000
#define N2 1000000000

int main()
{
 FAST
//code begins from here//
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ll n;
cin>>n;
ll h[n];
rep(i,n)cin>>h[i];
ll dp[n];
dp[0]=0;
dp[1]=abs(h[1]-h[0]);
repa(i,n,2)
{
   dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
}
cout<<dp[n-1];
return 0;
}


Measured memory_bytes: 5144
include Math

n, d = gets.split.map(&:to_i)
dots = []

n.times do
  dots << gets.split.map(&:to_i)
end

ans = 0

for i in 0 .. n - 2
  for j in i + 1 .. n - 1
    dist = 0
    for k in 0 .. d - 1
      dist += (dots[i][k] - dots[j][k]) ** 2
    end
    if sqrt(dist) == (sqrt(dist)).to_i
      ans += 1
    end
  end
end

puts ans


Measured memory_bytes: 1788
N, K = [int(_) for _ in input().split()]
V = [int(_) for _ in input().split()]

ans = 0
for l in range(N + 1):
    for r in range(N - l + 1):
        if l + r > N: break
        if l + r > K: break

        lst = []
        if l > 0:
            lst += V[:l]
        if r > 0:
            lst += V[-r:]

        lst.sort()
        # print('lst', lst)
        max_drop = K - (l + r)
        for d in range(max_drop + 1):
            if d >= len(lst):
                break

            ans = max(sum(lst[d:]), ans)
print(ans)


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

struct UnionFind {
  UnionFind(size_t size) : v(size, -1) {}
  vector<int> v;

  int root(int x) {
    return (v[x] < 0 ? x : v[x] = root(v[x]));
  }

  bool is_root(int x) {
    return x == root(x);
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (v[x] > v[y]) swap(x, y);
      v[x] += v[y];
      v[y] = x;
    }
  }

  int size(int x) {
    return -v[root(x)];
  }
};

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> a(N);
  for (auto &i : a) cin >> i;

  UnionFind uf(N);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;

    uf.unite(a, b);
  }

  if (2 * (N - (M + 1)) > N) {
    cout << "Impossible" << endl;
    return 0;
  }

  if (N - M == 1) {
    cout << 0 << endl;
    return 0;
  }

  vector<vector<int>> v(N);
  for (int i = 0; i < N; ++i) {
    v[uf.root(i)].push_back(a[i]);
  }

  int64_t ans = 0;
  vector<int> u;
  for (int i = 0; i < N; ++i) {
    if (uf.is_root(i)) {
      sort(v[i].begin(), v[i].end());
      ans += v[i][0];
      for (int j = 1; j < v[i].size(); ++j) {
        u.push_back(v[i][j]);
      }
    }
  }

  sort(u.begin(), u.end());
  for (int i = 0; i < N - M - 2; ++i) {
    ans += u[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
int main()
{

    string s, t = "";

    cin >> s;
    if(s.size() > 3 && (t + s[0] + s[1] + s[2] + s[3] == "YAKI"))
        cout << "Yes";
    else
        cout << "No";

return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<cmath>
using namespace std;
int min_cost(int arr[],int n,int k){
    int cost[n];
    cost[0] = 0;
    for(int i=1;i<n;i++){
        cost[i] =  INT_MAX;
        for(int j=i-1;j>=0 and j>=i-k;j--)
            cost[i] = min(cost[j]+abs(arr[i]-arr[j]),cost[i]);
    }
    return cost[n-1];
}
int main(){
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    cout<<min_cost(arr,n,k)<<endl;
}

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

#define rep(i, n) for(int i = 0; i < n; ++i)
struct lex_order
{
	struct less
	{
		bool operator()(const string& x, const string& y)
		{
			int i;
			for (i = 0; i < x.size() && i < y.size(); ++i)
			{
				if (x[i] < y[i])
				{
					return true;
				}
				else if (x[i] > y[i])
				{
					return false;
				}
			}

			if (i < x.size())
			{
				return true;
			}

			return false;
		}

		using first_argument_type = string;
		using second_argument_type = string;
		using result_type = bool;
	};
};

int main()
{
	int N, L;
	cin >> N >> L;
	vector<string> S(N);

	rep(i, N)
	{
		cin >> S[i];
	}

	sort(S.begin(), S.end(), lex_order::less());

	rep(i, N)
	{
		cout << S[i];
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=2000005;
const long long MOD=1000000007;
int n;
char s[N];
int k;
long long ksm(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return res;
}
long long fac[N],inv[N];
void init(int n=2000000)
{
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[n]=ksm(fac[n],MOD-2);
	for(int i=n;i>=1;i--)
		inv[i-1]=inv[i]*i%MOD;
	return;
}
long long C(int m,int n)
{
	if(m>n) return 0;
	return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
int main()
{
	init();
	scanf("%d",&n);
	scanf("%s",s+1);
	k=n+strlen(s+1);
	n=strlen(s+1);
	long long ans=0;
	for(int i=1;i<=k-n+1;i++)
		ans=(ans+ksm(26,i-1)*ksm(25,k-i-n+1)%MOD*C(n-1,k-i)%MOD)%MOD;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 36052
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nq = readln.split.to!(int[]);
    auto N = nq[0];
    auto Q = nq[1];
    int[][] T;
    T.length = N;
    foreach (_; 0..N-1) {
        auto ab = readln.split.to!(int[]);
        auto a = ab[0]-1;
        auto b = ab[1]-1;
        T[a] ~= b;
        T[b] ~= a;
    }
    auto DS = new long[](N);
    foreach (_; 0..Q) {
        auto px = readln.split.to!(long[]);
        DS[px[0]-1] += px[1];
    }

    void solve(int i, int p, long s) {
        DS[i] += s;
        s = DS[i];
        foreach (j; T[i]) if (j != p) solve(j, i, s);
    }
    solve(0, -1, 0);

    writeln(DS.to!(string[]).join(" "));
}

Measured memory_bytes: 52092
N = int(input())
l = [0,1,2,3,4,5,1,2,3,1] + [0] * N
j = k = 1
for i in range(10,N+1):
    if i >= 6**(j+1):j+=1
    if i >= 9**(k+1):k+=1
    al = []
    m = i//9**(k)
    for v in range(1,m+1):
        n = i - v*(9**k)
        al.append(v+l[n])
    o = i//6**(j)
    for u in range(1,o+1):
        p = i - u*(6**j)
        al.append(u+l[p])
    l[i] = min(al)
print(l[N])

Measured memory_bytes: 4596
/**
 *  Kaiwen Zhou,
 *  CUHK
**/
#include <bits/stdc++.h>
using namespace std;

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

    int a, b, c, ans = 0;
    cin >> a >> b >> c;

    while(b != 0) {
        if(c > 0 && a > 0) {
            int d = min(c, a);
            c -= d; a -= d;
            ans += d;
        }
        else if(c > 0 && b > 0) {
            int d = min(c, b);
            c -= d; b -= d;
            ans += (2 * d);
        }
        else if(c == 0 && b > 0) {
            ans += b;
            b = 0;
        }
    }
    if(c > 0) ans ++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,n,flag=0,num=100,ans=0,a=0;
    int an[105];
    int nu[105];

    cin>>x>>n;
    for(int i=0;i<n;i++) cin>>an[i];

    sort(an,an+n);

    for(int i=0;i<=101;i++){
        if(an[flag]==i){
            flag++;
        }else{
            nu[a]=i;
            a++;
        }
    }

    for(int i=0;i<a;i++){
        if(num>abs(x-nu[i])){
            ans=nu[i];
            num=abs(x-nu[i]);
        } 
    }

    cout<<ans<<endl;
    return 0;
}
    

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

int main(){
  string O,E;
  cin>>O>>E;
  
  int a=O.size();
  int b=E.size();
  for(int i=0;i<b;i++){
    cout<<O.at(i)<<E.at(i);
  }
  if(a!=b){
    cout<<O.at(a-1);
  }
  cout<<endl;
}

Measured memory_bytes: 256
s=input()
t=input()

n=len(s)
m=len(t)

dp=[[0 for i in range(m+1)] for i in range(n+1)]

for i in range(n):
 for j in range(m):

  if s[i]==t[j]:
   dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1)

  dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j])
  dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1])

ans=''
while n>0 and m>0:
 if dp[n][m]==dp[n-1][m]:
  n-=1
 elif dp[n][m]==dp[n][m-1]:
  m-=1
 else:
  m-=1
  n-=1
  ans=s[n]+ans

print(ans)

Measured memory_bytes: 121308
#include <bits/stdc++.h>
#define N 1000050
using namespace std;
typedef long long LL;
LL ans;
int n,a[N];
inline int rd() {int r;scanf("%d",&r);return r;}
int main() {
	n = rd();
	for (int i=1;i<=n;i++) a[i] = rd();
	for (int i=1;i<=n;i++) {
		ans += a[i] / 2;
		a[i] %= 2;
		if (a[i]>0 && a[i+1]>0)
			a[i]--, a[i+1]--, ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
s = gets.chomp.reverse
n = s.size
mod = 10 ** 9 + 7

t = Array.new(n, 1)
1.upto(n-1) {|i| t[i] = t[i-1] * 10 % 13}

dp = Array.new(13, 0)
(c = s.slice!(0)) == ?? ? dp.fill(1, 0..9) : dp[c.to_i] = 1

s.each_char.with_index(1) do |c, i|
    if c == ??
        x = Array.new(13, 0)
        10.times do |j|
            z = t[i] * j % 13
            13.times {|k| x[k] += dp[k - z]}
        end
        dp = x.map! {|e| e % mod}
    else
        z = t[i] * c.to_i % 13
        dp.rotate!(-z)
    end
end

puts dp[5]

Measured memory_bytes: 2940
//Decision's template
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<set>
using namespace std;

#define maxn 100000
#define INF 10000007
#define MOD 1000000007
#define mst(s,k) memset(s,k,sizeof(s))

typedef long long ll;

struct Edge{
    int from,to,dist;
    Edge(int u,int v,int d):from(u),to(v),dist(d){}
};

/*-------------------------------template End--------------------------------*/

int y,m,d;

int main(){
	scanf("%d/%d/%d",&y,&m,&d);
	if(y>2019) cout<<"TBD"<<endl;
	else if(y<2019) cout<<"Heisei"<<endl;
	else{
		if(m<=4) cout<<"Heisei"<<endl;
		else if(m>4) cout<<"TBD"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys, math
from collections import defaultdict, deque, Counter
#from bisect import bisect_left, bisect_right
#from itertools import combinations, permutations, product
from heapq import heappush, heappop
#from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

H, W = rl()
C = rl()
D = rl()
M = []
for i in range(H):
	s = rs()
	M.append(s)

start = tuple([C[0]-1, C[1]-1])
end = tuple([D[0]-1, D[1]-1])

queue = deque()
queue.append((start, 0))
visited = defaultdict(lambda: float('inf'))
visited[start] = 0

while queue:
	n, d = queue.popleft()
	if n == end:
		print(d)
		exit()
	if visited[n] != d:
		continue
	i, j = n
	for di in range(-2, 3):
		for dj in range(-2, 3):
			if (di, dj) == (0,0): continue
			ni, nj = i+di, j+dj
			if not (0 <= ni < H and 0 <= nj < W): continue
			if M[ni][nj] == '#': continue
			if (di, dj) in [(1,0),(-1,0),(0,1),(0,-1)]:
				nd = d
				if nd < visited[(ni,nj)]:
					queue.appendleft(((ni,nj), nd))
					visited[(ni,nj)] = nd
			else:
				nd = d+1
				if nd < visited[(ni,nj)]:
					queue.append(((ni,nj), nd))
					visited[(ni,nj)] = nd
print(-1)


Measured memory_bytes: 178088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

# define MAX_N 1000010 // 10^6 + 10

// UnionFindTree
// 使い方(インスタンス名 : tree)
// インスタンス生成 : UnionFind tree;
// tree.init(要素数)
// uniteしたりsameかどうか判定したり

class UnionFind{
    private:
        int par_[MAX_N];
        int rank_[MAX_N];
        ll size[MAX_N];
        int groups_;
    
    public:
        void init(ll n){ // initializes the tree 
            for(ll i=0; i<n; i++){
                par_[i] = i;
                rank_[i] = 0;
                size[i] = 1;
            }
            groups_ = n;
        } 
        int rootOf(int x){ // returns the root of x 
            if(par_[x] == x){
                return x;
            }
            else{
                return par_[x] = rootOf(par_[x]);
            }
        } 
        void unite(int x, int y){ // unites x and y 
            x = rootOf(x);
            y = rootOf(y);
            if(x == y) return;
            if(rank_[x] < rank_[y]){
                par_[x] = y;
                groups_--;
                size[y] += size[x];
            }
            else{
                par_[y] = x;
                groups_--;
                size[x] += size[y];
                if(rank_[x] == rank_[y]) rank_[x]++;
            }
        }
        bool isSameGroupe(int x, int y){ // whether x and y are united
            return rootOf(x) == rootOf(y);
        }
        int countGroups(){ // returns the number of groups
            return groups_;
        }
        // 6 / 19 Updated!! (連結成分のサイズを返す)
        ll sizeOf(int x){
            return size[rootOf(x)];
        }
};

int main(void){
    ll n, m;
    cin >> n >> m;
    vector<P> ab;
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        ab.push_back(P(a, b));
    }

    UnionFind tree;
    tree.init(n);

    stack<ll> anss;
    ll ans = n * (n - 1) / 2;
    anss.push(ans);

    for(int i = m-1; i >= 0; i--){
        int a = ab[i].first;
        int b = ab[i].second;
        if(!tree.isSameGroupe(a, b)){
            ans -= (tree.sizeOf(a) * tree.sizeOf(b));
            anss.push(ans);
            tree.unite(a, b);
        }
        else{
            anss.push(ans);
        }
    }

    anss.pop();
    for(int i = 1; i <= m; i++){
        cout << anss.top() << endl;
        anss.pop();
    }
    return 0;
}

Measured memory_bytes: 6376
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e10;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    int n,m;
    cin >> n >> m;
    if (n == m) PRINT("Yes");
    else PRINT("No");
}


Measured memory_bytes: 256
N = int(input())
Mylist = list(input())
ANSlist = []
if N%2 == 1:
  print("No")
else: 
    for i in range(int(N/2)):
        if Mylist[i] == Mylist[i + int(N/2)]:
            ANSlist.append("Yes")
    if len(ANSlist) == N/2:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
A, B, C = map(int, input().split())

if A == B == C:
    print(0)
else:
    if(3 * max(A, B, C) - A - B - C) % 2 == 0:
        print((3 * max(A, B, C) - A - B - C) // 2)
    else:
        print((3 * max(A, B, C) - A - B - C) // 2 + 2)

Measured memory_bytes: 3060
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
const ll maxN=2e5+5 , N=1e7+1;
ll n ;
void solve(){
	cin>> n ;
	ll ans=0 , a;
	for(ll i=1;i<=n ;i++){
		a=n/i;
		ans += (a*(a+1)/2)*i;
	}
	cout<<ans<<endl;
}

int main(){
	//mahakal(),fast;
	ll t=1;
	// cin>>t ;
	while(t--)solve();

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
const double pi = acos(-1);
int main()
{
    Hello
    int n;
    string s;
    cin >> n >> s;
    if(n % 2)
        return cout << "No", 0;
    string t = s.substr(0, n/2);
    if(t + t == s) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef tuple<int,int,int> iii;
#define ll long long
 
void m1(){
  string s; cin >> s;
  string t = "";
  t += s[0];
  t += s[1];
  t += s[2];
  cout << t;
}
 
/*
void m2(){
  int t; cin >> t;
  while(t--) m1();
}
*/
 
int main(){
  //freopen("in.txt","r",stdin);
  m1();
  //m2();
}

Measured memory_bytes: 3592
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

template <typename T>
T euclid(T a, T b)
{
    assert(a > 0 && b > 0);
    T num1 = max(a, b);
    T num2 = min(a, b);
    T mod = num1 % num2;
    return (mod == 0) ? num2 : euclid(num2, mod);
}

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

    size_t n = 0;
    cin >> n;
    assert(2 <= n && n <= pow(10, 5));

    vector<uint64_t> numbers(n, 0);
    for(size_t i = 0; i < n; i++)
    {
        uint64_t num = 0;
        cin >> num;
        assert(1 <= num && num <= pow(10, 9));
        numbers.at(i) = num;
    }

    vector<uint64_t> answer_array(n, 0);
    answer_array[0] = numbers[0];
    for(size_t i = 1; i < n; i++)
    {
        // 最大公約数(Gratest common factor)
        uint64_t gcf = euclid(answer_array[i - 1], numbers[i]);
        answer_array.at(i) = gcf;
    }

    cout << answer_array.at(n-1) << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<unordered_map>
#include<queue>

using namespace std;
class CompareFirst
{
public:
  bool operator()(pair<int,int> n1,pair<int,int> n2) {
    return n1.first>n2.first; //>:desc <:asc
  }
};


int main(){

  string s;
  int b,c,i,j,k,n;
  long long  ans1;
  double ans,tmp;
  vector<string> lst;
  vector<int> cnt;

  //unordered_map<string,int> mp;

  //priority_queue<int> pq; // default ‘å‚«‚¢‡
  //priority_queue<pair<int,int>,vector<pair<int,int>>,CompareFirst pq;

  cin >> n;
  ans = 0;
  ans1 = 0;
  int a[n];
  for(i=0;i<n;++i){
    cin >> a[i];
  }
/*
  for(i=0;i<n;i++){
      tmp = 1;
    for(j=0;j<n;j++){
      if(i != j){
        tmp *= (long long)a[j];
      }
    }
    ans1 += tmp;
    tmp = 1;
  }
  */
  tmp = 0.0;
  for(i=0;i<n;i++)tmp += (double)1/a[i];
  ans = (double)1.0/tmp;
 // cout << fixed;
//  cout << setprecision(6) << (double)ans << endl;
printf("%.10f\n",ans);
  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    vector<int> N(4);
    REP(i,4)cin >> N[i];
    sort(ALL(N));
    int A = N[0]*1000 + N[1] + N[2]*10+N[3]*100;
    cout << (A == 1974?"YES":"NO") << "\n";
}

Measured memory_bytes: 256
a, b, k = map(int, input().split(' '))
odd_a, odd_b = a, b
odd_a = a - k
if odd_a < 0:
    odd_b += odd_a
    odd_a = 0
    if odd_b < 0:
        odd_b = 0

print(odd_a, odd_b)

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

int main()
{
    ll n,q;
    cin>>n;
    vector<ll>v;
    vector<ll>f(100005,0);
    ll sum=0;
    for(ll i = 0 ; i < n ; i++)
    {
        ll temp;
        cin>>temp;
        sum += temp;
        f[temp]++;
        v.push_back(temp);
    }
    cin>>q;
    bool flag = false;
    while(q--)
    {
        ll a,b,s=sum;
        cin>>a>>b;
        if(f[a])
        {
            flag = true;
            s = s - f[a]*a;
            s = s + f[a]*b;
            f[b] += f[a];
            f[a] = 0;
            sum = s;
            cout<<sum<<endl;
        }
        else
           cout<<s<<endl;
    }
}

Measured memory_bytes: 5024
N=int(input())
a=[int(i) for i in input().split()]
av=sum(a)//N
x=sum([(a[i]-av-1)**2 for i in range(N)])
y=sum([(a[i]-av)**2 for i in range(N)])
z=sum([(a[i]-av+1)**2 for i in range(N)])
print(min([x,y,z]))


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

using namespace std;

int main() {
    int n, y;
    cin >> n >> y;
    int ans10000 = -1;
    int ans5000 = -1;
    int ans1000 = -1;

    for (int a = 0; a <= n; a++) {
        for (int b = 0; b <= n; b++) {
            int c = n - a - b;
            if (c < 0) continue;
            int total = 10000 * a + 5000 * b + 1000 * c;
            if (total == y) {
                ans10000 = a;
                ans5000 = b;
                ans1000 = c;
                cout << ans10000 << " " << ans5000 << " " << ans1000 << endl;
                return 0;
            }
        }
    }
    cout << ans10000 << " " << ans5000 << " " << ans1000 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    class Card{
        int a;
        int b;
        Card(int a, int b){
            this.a = a;
            this.b = b;
        }
    }
    void run(){
        Scanner sc = new Scanner(System.in);
        while(true){
            int[] card_num = new int[101];
            int m = sc.nextInt();
            if(m==0){
                break;
            }
            Card[] cards = new Card[m];
            for(int i = 0; i < m; i++){
                cards[i] = new Card(sc.nextInt(), sc.nextInt());
            }
            int[] dp = new int[1001];
            dp[0] = 1;
            for(int i = 0; i < m; i++){
                for(int ii = 1000 - cards[i].a -1; ii >= 0; ii--){
                    for(int iii = 1; iii <= cards[i].b; iii++){
                        if(ii + cards[i].a*iii <= 1000){
                            dp[ii + cards[i].a*iii] += dp[ii];
                        }
                    }
                }
            }
            /*
              System.out.println(Arrays.toString(dp));
              for(int i = 0; i < 100; i++){
              System.out.println(i + " : " + dp[i]);
              }
            */
            int g = sc.nextInt();
            for(int i = 0; i < g; i++){
                System.out.println(dp[sc.nextInt()]);
            }
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}

Measured memory_bytes: 19064
require 'openssl'

class String
    def to_flag(c)
        self + c + self.reverse
    end
end
def gcd(a, b)
    if (b == 0) 
        a
    else 
        gcd(b, a % b)
    end
end
n, cf = gets.chomp.split(' ')
c = cf.to_i < 0 ? "" : cf
space = cf.to_i < 0 ? "" : "0"
g = (0 ... n.to_i).map{|i| ((10 ** i).to_s + space + (10 ** i).to_s.reverse + "0" * (n.to_i - i - 1)).to_i}.reduce{|a, b|gcd(a, b)}
g = gcd(g, cf.to_i * (10 ** n.to_i)) if cf.to_i >= 0
if g == 1
    puts ((10 ** n.to_i - 1).downto(10 ** (n.to_i - 1)).find{|i| OpenSSL::BN.new(i.to_s.to_flag(c)).prime?} || (10 ** n.to_i - 1)).to_s.to_flag(c)
else
    puts (10 ** n.to_i - 1).to_s + c + (10 ** n.to_i - 1).to_s
end


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

const int inf = 0x3f3f3f3f;

int main()
{
    int n, a, b;
    scanf("%d", &n);
    int h = n >> 1, ans = inf;
    for(int i = 1; i <= h; i++){
        a = i;
        b = n - a;
        int tmp = 0;
        while(a){
            tmp += a % 10;
            a /= 10;
        }
        while(b){
            tmp += b % 10;
            b /= 10;
        }
        if(tmp < ans) ans = tmp;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const MOD = 10^^9 + 7;

int[int] fac(int n) {
    assert(n > 1);

    int[int] ps;
    while (n % 2 == 0) {
        ps[2]++;
        n /= 2;
    }
    for (int i = 3; i * i <= n; i += 2) {
        while (n % i == 0) {
            ps[i]++;
            n /= i;
        }
    }
    if (n > 1) ps[n]++;
    return ps;
}

long calc(int n, int m) {
    if (m == 1) return 1;

    long ans = 1;
    foreach (v; fac(m).values) {
        // v 個の素因数と n - 1 個の仕切りの並べ方
        ans = (ans * nck(v + n - 1, n - 1)) % MOD;
    }
    return ans;
}

void main() {
    initFactTable(210000);

    int n, m; scan(n, m);
    writeln(calc(n, m));
}

long[] fact; // 階乗
long[] factInv; // 階乗の逆元

void initFactTable(int n) {
    fact = new long[n + 1];
    fact[0] = 1;
    for (int i = 1; i <= n; i++)
        fact[i] = i * fact[i - 1] % MOD;

    factInv = new long[n + 1];
    factInv[n] = modPow(fact[n], MOD - 2, MOD);
    for (int i = n - 1; i >= 0; i--)
        factInv[i] = factInv[i + 1] * (i + 1) % MOD;
}

long modPow(long x, long k, long m) {
    if (k == 0) return 1;
    if (k % 2 == 0) return modPow(x * x % m, k / 2, m);
    return x * modPow(x, k - 1, m) % m;
}

long nck(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return (fact[n] * factInv[k] % MOD) * factInv[n - k] % MOD;
}


Measured memory_bytes: 4348