akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1LL<<60
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main(){
  ll n, W;
  cin >> n >> W;
  ll dp[n+1][n+1][3*n+1] = { };
  ll w[n], v[n];
  REP(i, n) cin >> w[i] >> v[i];
  dp[0][1][0] = v[0];
  REP(i, n){
    REP(j, n){
      if(i >= j){
      dp[i+1][j+1][0] = dp[i][j+1][0];
      REP(k, 3*n+1){
        if(k < (w[i]-w[0])) dp[i+1][j+1][k] = dp[i][j+1][k];
        else if(k == 0){
          dp[i+1][j+1][k] = max(dp[i][j+1][k], dp[i][j][k-w[i]+w[0]] + v[i]);
        }
        else dp[i+1][j+1][k] = max(max(dp[i][j+1][k], dp[i+1][j+1][k-1]), dp[i][j][k-w[i]+w[0]] + v[i]);}
      }
    }
  }
  ll ans = 0;
  REP(i, n+1){
    REP(j, 3*n+1){
      if(w[0]*i + j <= W) ans = max(ans, dp[n][i][j]);
    }
    cout << endl;
  }
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 24192
import itertools
S=input()
N=len(S)+1
ans=0
KEY=[]
gr=itertools.groupby(list(S))
i=0
for key,group in gr:
  n=len(list(group))
  ans+=n*(n+1)//2
  KEY+=[n]
  if key==">" and i!=0:
    ans-=min(KEY[i-1],KEY[i])
  i+=1
print(ans) 

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

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 + (y1 - y2) << " " << y2 + (x2 - x1) << " ";
    cout << x1 + (y1 - y2) << " " << y1 + (x2 - x1) << endl;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
use std::io;

fn bubble_sort(a: &mut [i32]) -> i32 {
    let mut flag = true;
    let n: usize = a.len();
    let mut cnt = 0;

    let mut j: usize = 1;
    while flag {
        flag = false;
        for i in (j..n).rev() {
            if a[i] < a[i-1] {
                let t = a[i];
                a[i] = a[i-1];
                a[i-1] = t;
                flag = true;
                cnt+=1;
            }
        }
        j+=1;
    }
    cnt
}

fn print_vec(a: &Vec<i32>){
    let s = a.iter()
        .map(|e| e.to_string())
        .collect::<Vec<String>>()
        .join(" ");
    println!("{}", s);
}

fn main() {
    let sin = io::stdin();

    let mut buf = String::new();
    sin.read_line(&mut buf).unwrap();
    let _n: i32 = buf.trim().parse().unwrap();
    
    let mut buf = String::new();
    sin.read_line(&mut buf).unwrap();
    let mut a: Vec<i32> = buf.trim().split_whitespace().map(|e| e.parse().unwrap()).collect();

    // print_vec(&a);
    let cnt = bubble_sort(&mut a);
    print_vec(&a);
    println!("{}", cnt);
}



Measured memory_bytes: 5044
#include "bits/stdc++.h"
#include<assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define MRE assert(0);
const int inf = 1e17;
const int mod =924844033;
typedef pair<int, int> P;
typedef pair<int, P> PP;

signed main() {
	string s; cin >> s;
	if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi")puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  if(k>(n-1)*(n-2)/2){
    cout<<-1<<endl;
    return 0;
  }
  cout<<(n-1)+((n-1)*(n-2)/2-k)<<endl;
  for(int i=2;i<=n;i++)
    cout<<1<<' '<<i<<endl;
  for(int i=2,x=(n-1)*(n-2)/2;i<=n&&x>k;i++)
    for(int j=i+1;j<=n&&x>k;j++,x--)
      cout<<i<<' '<<j<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;

bool m[N];
vi primes(1,2);
ld nk[N][N];
void sieve(){
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

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

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7


int main(){_
	int n; cin>>n;
	vl v(10005,0);
	fore(i,1,101)fore(j,1,101)fore(k,1,101){
		int r = i*i + j*j + k*k + i*j + i*k + j*k;
		if(r>int(1e4))break;
		v[r]++;
	}
	fore(i,1,n+1)cout<<v[i]<<ENDL;


}


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

const int INF = 1e18;

signed main() {
  int Q;
  cin >> Q;

  int suma = 0, sumb = 0;
  priority_queue<int> ql;
  priority_queue<int, vector<int>, greater<int>> qr;
  ql.push(-INF);
  qr.push(INF);

  while (Q--) {
    int q;
    cin >> q;

    if (q == 1) {
      int a, b;
      cin >> a >> b;
      sumb += b;

      if (ql.size() == qr.size()) {
        if (ql.top() <= a && a <= qr.top()) {
          suma += 0;
        } else {
          suma += min(abs(ql.top() - a), abs(a - qr.top()));
        }
      } else {
        suma += abs(ql.top() - a);
      }

      if (qr.top() <= a) {
        qr.push(a);
      } else {
        ql.push(a);
      }

      if (qr.size() > ql.size()) {
        ql.push(qr.top());
        qr.pop();
      } else if (ql.size() > qr.size() + 1) {
        qr.push(ql.top());
        ql.pop();
      }

    } else if (q == 2) {
      cout << ql.top() << " " << suma + sumb << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3828
import sys
import fractions
sys.setrecursionlimit(200000000)

N = int(input())
NUMS = [int(input()) for _ in range(N)]
NUMS = list(set(NUMS))

def gcd(num1, num2):
    if num2 == 0:
        return num1
    else:
        return gcd(num2, num1 % num2)


res = NUMS[0]
for num in NUMS[1:]:
    res = res * num // fractions.gcd(res, num)

print(int(res))

Measured memory_bytes: 5048
#include <iostream>

using std::cout;
using std::cin;
using std::endl;


constexpr int MAX = 100;

int main()
{
    int in_mat1_row, in_mat1_col, in_mat2_row, in_mat2_col;
    cin >> in_mat1_row >> in_mat1_col >> in_mat2_col;
    in_mat2_row = in_mat1_col;

    int in_mat1[MAX][MAX];
    for (int i = 0; i < in_mat1_row; i++) {
        for (int j = 0; j < in_mat1_col; j++) {
            cin >> in_mat1[i][j];
        }
    }

    int in_mat2[MAX][MAX];
    for (int i = 0; i < in_mat2_row; i++) {
        for (int j = 0; j < in_mat2_col; j++) {
            cin >> in_mat2[i][j];
        }
    }

    long out_mat[MAX][MAX];
    for (int i = 0; i < in_mat1_row; i++) {
        for (int j = 0; j < in_mat2_col; j++) {
            out_mat[i][j] = 0;
            for (int k = 0; k < in_mat1_col; k++) {
                out_mat[i][j] += in_mat1[i][k] * in_mat2[k][j];
            }
            if (j != 0) {
                cout << " ";
            }
            cout << out_mat[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1236
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
ma=max(a)
a.sort()
era=[1]*(ma+1)
#0と1はふるいにかけられている。
cn=Counter(a)

count=0
for i in range(n):
  if era[a[i]]==0:continue
  else:
    era[a[i]]=0
    if cn[a[i]]==1:
      count+=1
    for j in range(2*a[i],ma+1,a[i]):
      era[j]=0
print(count)

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

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

	int64_t n = s.size(), m = t.size();

	vector<vector<int64_t>> ps(26);

	for (int64_t i = 0; i < n; i++)
	{
		ps[s[i] - 'a'].emplace_back(i);
	}

	int64_t ans = 0;

	for (int64_t x = 0, pos = -1; x < m; x++)
	{
		auto itr = upper_bound(ps[t[x] - 'a'].begin(), ps[t[x] - 'a'].end(), pos);
		if (itr == ps[t[x] - 'a'].end())
		{
			ans += n - pos - 1;
			pos = -1;
			itr = upper_bound(ps[t[x] - 'a'].begin(), ps[t[x] - 'a'].end(), pos);
		}

		if (itr == ps[t[x] - 'a'].end())
		{
			cout << -1 << endl;
			return 0;
		}

		ans += *itr - pos;
		pos = *itr;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1724
def main():
    h,w = map(int,input().split())
    if h*w == 0:
        return False
    for i in range(h):
        if i == 0 or i == h-1:
            print("#"*w)
        else:
            print("#" + "."*(w-2) + "#")
    print()
    return True

while main():
    pass


Measured memory_bytes: 5620
N,Q = list(map(int,input().split()))
S = input()
LR = [list(map(int,input().split())) for _ in range(Q)]
COUNT = [0]*N
for i in range(1,N):
    if S[i-1] == 'A' and S[i] == 'C':
        COUNT[i] = COUNT[i-1]+1
    else:
        COUNT[i] = COUNT[i-1]
for lr in LR:
    if lr[0] == 1:
        print(COUNT[lr[1]-1])
    else:
        print(COUNT[lr[1]-1]-COUNT[lr[0]-1])

Measured memory_bytes: 30664
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register ll i=(a);i<=(b);i++)
#define For(i,a,b) for (register ll i=(a);i>=(b);i--)
#define mem(i,j) memset(i,j,sizeof(i))
#define GO(u) for (register ll j=f[u];j!=-1;j=nxt[j])
#define fi first
#define se second
#define pb push_back
#define pii pair<ll,ll>
#define MP make_pair
using namespace std;
typedef long long ll;
const ll N=150000;
ll n,a[N],v[N],mn[20000005],L,R,MID,du[N];
vector <pii> F[N];
ll tot=0,f[N],nxt[N<<1];
struct E
{
	ll u,v,w;
}e[N<<1];
inline void add(ll u,ll v,ll w)
{
	tot++;
	nxt[tot]=f[u];
	f[u]=tot;
	e[tot]=(E){u,v,w};
	return;
}
inline ll read()
{
	ll x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return f*x;
}
inline void write(ll x)
{
	if (x<0) putchar('-'),x=-x;
	if (x>9) write(x/10);
	putchar(x%10+'0');
	return;
}
bool cmpfi(const pii x,const pii y) {return x.fi<y.fi;}
bool cmpse(const pii x,const pii y) {return x.se<y.se;}
inline void update(vector<pii> &G,ll ls,ll rs)
{
	ll siz1=F[ls].size(),siz2=F[rs].size();
	if ((!siz1)||(!siz2)) return;
	if (siz1>siz2) swap(ls,rs),swap(siz1,siz2);
	sort(F[ls].begin(),F[ls].end(),cmpfi);
	sort(F[rs].begin(),F[rs].end(),cmpse);
	mn[0]=F[rs][0].fi;
	FOR(i,1,siz2-1) mn[i]=min(mn[i-1],F[rs][i].fi);
	for (register ll i=0,pt=siz2-1;i<siz1;i++)
	{
		while (pt>-1&&F[ls][i].fi+F[rs][pt].se>MID) pt--;
		if (pt>=0) G.pb(MP(mn[pt],F[ls][i].se));
	}
	sort(F[ls].begin(),F[ls].end(),cmpse);
	sort(F[rs].begin(),F[rs].end(),cmpfi);
	mn[0]=F[rs][0].se;
	FOR(i,1,siz2-1) mn[i]=min(mn[i-1],F[rs][i].se);
	for (register ll i=0,pt=siz2-1;i<siz1;i++)
	{
		while (pt>-1&&F[ls][i].se+F[rs][pt].fi>MID) pt--;
		if (pt>=0) G.pb(MP(F[ls][i].fi,mn[pt]));
	}
	return;
}
inline void dfs(ll u,ll fa)
{
	int lson=0,rson=0;
	F[u].clear();
	if (du[u]==1){F[u].pb(MP(0,0));return;}
	GO(u)
	{
		ll v=e[j].v;
		if (v==fa) continue;
		if (!lson) lson=v;
		else rson=v;
		dfs(v,u);
	}
	GO(u)
	{
		ll v=e[j].v;
		if (v==fa) continue;
		FOR(i,0,(ll)F[v].size()-1)
		{
			F[v][i].fi+=e[j].w;
			F[v][i].se+=e[j].w;
		}
	}
	update(F[u],lson,rson);
	return;
}
int main()
{
//	freopen("data.in","r",stdin);
	mem(f,-1);
	n=read();
	FOR(i,2,n) a[i]=read(),v[i]=read(),add(i,a[i],v[i]),add(a[i],i,v[i]),du[i]++,du[a[i]]++;
	L=0,R=1e9;
	while (L<R)
	{
		MID=(L+R)>>1;
		dfs(1,0);
		if (F[1].size()) R=MID;
		else L=MID+1;
	}
	write(L);
	return 0;
}

Measured memory_bytes: 40184
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<double,int> P;

int n;
double a[100001];
double b[100001];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lf",&a[i]);
		b[i]=a[i];
	}
	sort(b,b+n);
	for(int i=0;i<n;i++){
		int w=lower_bound(b,b+n,a[i])-b;
		int l=upper_bound(b,b+n,a[i])-b;
		printf("%d\n",w*3+(l-w-1)*1);
	}
	return 0;
}

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

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

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

#define INF 1e16
#define mod 1000000007

int N;
vector<int> g[100010];
int d[100010];
int dp[100010];

bool dfs(int v,int pre,int X){
  vector<int> w;
  for(int nv : g[v]){
    if(nv==pre)continue;
    if(!dfs(nv,v,X))return false;
    w.push_back(dp[nv]+1);
  }
  if(d[v])w.push_back(0);
  sort(all(w));
  int m=w.size();
  if(m%2==0){ // r
    rep(j,m)if(w[j]+w[m-1-j]>X)return false;
  }else{
    int lb=-1,ub=m;
    while(ub-lb>1){
      int mid=(lb+ub)/2;
      bool ok=true;
      int l=0,r=m-1;
      if(l==mid)l++;
      if(r==mid)r--;
      while(l<r){
        if(w[l]+w[r]>X)ok=false;
        l++; if(l==mid)l++;
        r--; if(r==mid)r--;
      }
      if(ok) ub=mid;
      else lb=mid;
    }
    if(ub==m)return false;
    dp[v]=w[ub];
  }
  return true;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin>>N;
  rep(i,N-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);g[b].push_back(a);
  }
  memset(dp,-1,sizeof(dp));

  int A=0;
  rep(i,N){
    if((int)g[i].size()%2==1)A++;
    d[i]=(int)g[i].size()%2;
  }
  A/=2;

  int lb=0,ub=N;
  while(ub-lb>1){
    int mid=(lb+ub)/2;
    if(dfs(0,-1,mid))ub=mid;
    else lb=mid;
  }
  cout<<A<<" "<<ub<<endl;

  return 0;
}


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

int main()
{   
    int x,a,b,d_a,d_b;
    
    scanf("%d %d %d",&x, &a, &b);
    d_a=abs(x-a);
    d_b=abs(x-b);
    
    if (d_a<d_b){
        printf("A");
    }
    else{
        printf("B");
    }
  
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long dp[11][1010];

int main(){
    dp[0][0] = 1;
    for(int i = 0;i <= 100;i++)
        for(int j = 9;j >= 0;j--)
            for(int k = 0;k <= 1000-i;k++)
                dp[j+1][k+i] += dp[j][k];
    int n, s;
    while(cin >> n >> s, n | s)cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    if((a[0]==a[1]) and (a[0]!=a[2])){
        cout << "Yes" << endl;
        return 0;
    }else{
        if (a[1]==a[2] and a[0]!=a[1]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;


long long int N,M,X[202000],res=0;
vector<long long int>vec;
int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>M;
    for(long long int i=0;i<M;i++){
        cin>>X[i];
    }
    sort(X,X+M);
    for(long long int i=1;i<M;i++){
        vec.push_back(X[i]-X[i-1]);
    }
    sort(vec.begin(),vec.end());
    for(long long int i = 0; i <max(M-N,0LL); i++){
        res+=vec[i];
    }
    cout<<res<<endl;
}


Measured memory_bytes: 2168
K, N = map(int, input().split())
As = list(map(int, input().split()))
dmax = 0
for i in range(N-1):
    dmax = max(dmax, As[i+1]-As[i])
dmax = max(dmax, As[0] + K - As[N-1])
print(K - dmax)


Measured memory_bytes: 26444
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 	first
#define s 	second
#define ll 	int
#define int 	long long
#define ld 	long double
#define pb 	push_back
#define eb 	emplace_back
#define mk 	make_pair
#define vi 	vector<int>
#define pii 	pair<int,int>
#define vpi 	vector<pii>
#define fori(a,b,c) for(register int i=a;i<b;i+=c)
#define ford(a,b,c) for(register int i=a;i>=b;i-=c)
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl()
{
	cout<<"Control\n";
}
signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
    cin>>n;
    int A[n+1],B[n],C[n];

    fori(0,n-1,1)
    cin>>B[i];

    int s=0;

    A[0]=B[0];
    A[n-1]=B[n-2];

    for(int i=1;i<n-1;i++)
    {   
        
        A[i]=min(B[i-1],B[i]);
    
        
        s+=A[i];
    }
    cout<<s+A[0]+A[n-1];

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n; cin>>n;
  int a[n], b[n], c[n-1];
  rep(i,n) cin>>a[i], a[i]--;
  rep(i,n) cin>>b[i];
  rep(i,n-1) cin>>c[i];
  c[n-1] = 0;
  int ans = 0;
  rep(i,n){
    ans += b[a[i]];
    if(i==0) continue;
    if(a[i-1]+1==a[i]) ans += c[a[i-1]];
  }
  cout << ans << endl;

  return 0;
}


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

    string s;
    cin >> s;

    int ans = 700;

    for(int i = 0; i < 3; ++i){
        if(s.at(i) == 'o')ans += 100;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
bool check(string s,int n) {
	if (s.size() <= n)return true;
	return false;
}
void solve() {
	string s; cin >> s;
	int n = 0;
	if (s[n] == '>') {
		n++;
		if (check(s, n));
		else if (s[n] == '\'') {
			n++;
			int cnt = 0;
			while (s[n] == '=' && !check(s, n)) { cnt++; n++; }
			if (s[n] == '#') {
				n++;
				if (check(s, n))goto exit;
				else if (s[n] != '=')goto exit;
				while (s[n] == '=' && !check(s, n)) { cnt--; n++; }
				if (cnt == 0) {
					if (s[n] == '~') {
						n++;
						if (n == s.size()) {
							cout << "A\n";
							return;
						}
					}
				}
			}
		}
		else if (s[n] == '^') {
			n++;
			if (check(s, n))goto exit;
			bool b = false;
			while (true) {
				if (check(s, n + 1))goto exit;
				else {
					if (s[n] == 'Q'&&s[n + 1] == '=') { n += 2; b = true; }
					else if (s[n] == '~'&&s[n + 1] == '~') {
						if (b) {
							cout << "B\n";
							return;
						}
						else goto exit;
					}
					else goto exit;
				}
			}
			n++;
			if (check(s, n))goto exit;
			if (s[n] == '~') {
				n++;
				if (check(s, n))goto exit;
				if (s[n] == '~') {
					n++;
					if (n == s.size()) {
						cout << "B\n";
						return;
					}
				}
			}
		}
	}
exit:;
	cout << "NA\n";
	return;
}
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++)solve();
}

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

class Edge {
public:

	int start;
	int end;
	int weight;

	Edge(int s, int e, int w) : start(s), end(e), weight(w) {}


	
};

bool operator < (const Edge &a, const Edge &b) {
	return a.weight > b.weight;
}

class UnionFind {
public:

	vector<int> numbers;
	vector<int> rank;

	UnionFind(int n) {

		for (int i = 0; i < n; ++i) {
			numbers.push_back(i);
			rank.push_back(0);
		}

	}

	int FindParent(int n) {

		if (numbers[n] == n)
			return n;

		return numbers[n] = FindParent(numbers[n]);

	}

	bool isSame(int a, int b) {

		return FindParent(a) == FindParent(b);

	}

	void Union(int a, int b) {

		int a_parent = FindParent(a);
		int b_parent = FindParent(b);

		if (rank[a_parent] < rank[b_parent]) {
			swap(a_parent, b_parent);
		}
		else if (rank[a_parent] == rank[b_parent]) {
			rank[a_parent]++;
		}

		numbers[b_parent] = a_parent;
	}

};

int main() {

	priority_queue<Edge> edges;

	int n, edgeCount;

	cin >> edgeCount >> n;

	UnionFind tree(edgeCount);

	for (int i = 0; i < n; ++i) {

		int start, end, w;

		cin >> start >> end >> w;
		
		edges.push(Edge(start, end, w));

	}


	int sum = 0;

	while (!edges.empty()) {
		Edge e = edges.top();
		// cout << e.start << " " << e.end << " " << e.weight << endl;
		edges.pop();

		if (tree.FindParent(e.start) == tree.FindParent(e.end))
			continue;

		sum += e.weight;
		tree.Union(e.start, e.end);

	}

	cout << sum << endl;


	return 0;

}


Measured memory_bytes: 4752
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }
        

        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            
         
            var input =Reads();
            var k = input[0];
            var s = input[1];
            var anwer = 0;
            for (int i = 0; i <=k; i++)
            {
                for (int j= 0; j <=k; j++)
                {
                    if (0 <= s - i - j && s - i - j <= k)
                        anwer++;
                }
            }
            Console.WriteLine(anwer);
            

            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
typedef long long ll;
int main() {
  ll h;
  cin >> h;
  ll n=2;
  ll sum=0;
  while(h>1){
    h=h/2;
    n*=2;
  }
  cout << n-1 << endl;
}



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

const int kNmax = 1e5 + 10;

int n, a[kNmax], b[kNmax], c[kNmax], prv[kNmax], nxt[kNmax];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; i++) {
        scanf("%d", &b[i]);
    }
    for (int i = 1; i <= n; i++) {
        scanf("%d", &c[i]);
    }
    
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    sort(c + 1, c + n + 1);
    
    for (int i = 1, j = 1; j <= n; j++) {
        while (i <= n && a[i] < b[j]) {
            i++;
        }
        prv[j] = i - 1;
    }
    for (int i = n, j = n; i >= 1; i--) {
        while (j >= 1 && c[j] > b[i]) {
            j--;
        }
        nxt[i] = n - j;
    }
    
    long long res = 0;
    for (int i = 1; i <= n; i++) {
        res += 1LL * nxt[i] * prv[i];
    }
    printf("%lld\n", res);
}

Measured memory_bytes: 2176
import java.util.Scanner;
public class Main {
	public static void main(String[] args)
	{	Scanner sc = new Scanner(System.in);
		int input[] = new int[3];
		int key[][] = {{5,5,7},{0,0,0}};
		for(int i=0;i<3;i++)
		{
			input[i]=sc.nextInt();
		}
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				if(input[i]==key[0][j] && key[1][j] != 1)
				{	key[1][j] = 1;
					break;
				}
			}
			
		}
		if((key[1][0]==1) && (key[1][1]==1) && (key[1][2]==1))
		{
			System.out.println("YES");
		}
		else
			System.out.println("NO");
	}
}

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

using namespace std;

//mem(a, b) memset(a, (b), sizeof(a))

typedef long long ll;

#define f(i,a,b) for (ll i=a ; i<b ; i++)

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define faster ios::sync_with_stdio(0);cin.tie(0);
typedef pair<int, int> p;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<p> vii;
typedef vector<vi> vvi;
typedef map<int,int> mp;
typedef set<int> se;
typedef multiset<int> MSETI;


// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

// traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)

// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c,x) ((c).find(x) != (c).end())

//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())

// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) int((a).size())


struct duo{
    ll x,y;
};

bool mycomp(duo a,duo b) { return a.x < b.x ;}

bool comp(int a,int b){
	return a<b;
}


int main()
{
	faster


	ll t,n,b=0,d,i,j,k,c,sum;
   cin>>n;
   vi v(n);
   map<ll,ll> m;
   f(i,0,n){cin>>v[i];
   b+=v[i];
   if(m[v[i]]==0){
       m[v[i]]=1;
   }
   else 
   {
       m[v[i]]++;
   }
   }
   //cout<<m[1]<<m[2]<<endl;
   
   cin>>t;
   while(t--)
   {
       cin>>k>>c;
       j=m[k];
       b=b-(j*k);
       m[c]=m[c]+m[k];
        
       b=b+(m[k]*c);
       m[k]=0;
       cout<<b<<"\n";
   }
  
    
	
	
}


Measured memory_bytes: 9440
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define mid ((l+r)>>1)
const int M=3e5+20,P=1e9+7;
struct Task{
    LL n,m,v,p,a[M];
    LL sum[M];
    void run(){
        init();
        sort(a+1,a+n+1);
        for(int i=1;i<=n;++i){
        	sum[i]=sum[i-1]+a[i];
		} 
        LL ans=n-p;
        while(ans>=1){
            if(a[ans]+m<a[n-p+1]){
            	break;
			}   
            if(1LL*(ans+p-1)*m+1LL*(n-p+1-(ans+1)+1)*(a[ans]+m)-(sum[n-p+1]-sum[ans])>=1LL*v*m){
            	--ans;
			}   
            else{
            	break;
			}
        }
        printf("%lld\n",n-ans);
    }
    void init(){
        scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
        for(int i=1;i<=n;++i){
        	scanf("%lld",&a[i]);
		}
    }
}t;
int main(){
    t.run();
    return 0;
}

Measured memory_bytes: 3072
X=gets.to_i
if X <= 599
    puts 8
elsif X <= 799
    puts 7
elsif X <= 999
    puts 6
elsif X<= 1199
    puts 5
elsif X<= 1399
    puts 4
elsif X<= 1599
    puts 3
elsif X<= 1799
    puts 2
else
    puts 1
end


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

int main(){
  string s;
  cin >> s;
  int counter = 0;
  for (int i=0; i<3; i++){
    if (s[i] == '1'){
      counter++;
    }
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 256
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabCout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headCout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabHeadCout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
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 T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

void Main()
{
	while (true)
	{
		int n;
		cin >> n;
		if (n == 0)	break;

		vector<ll> dp(n+10);
		dp[0] = 1;

		for (int i = 0; i < n; i++)
		{
			for (int j = 1; j <= 3; j++)
			{
				dp[i + j] += dp[i];
			}
		}

		cout << divUp(dp[n], 3650ll) << '\n';
	}
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);

	Main();

	return 0;
}



Measured memory_bytes: 2988
a, b, c = map(int, input().split())

x = []
x.append(a)
x.append(b)
x.append(c)

y = [5, 7, 5]
for z in y:
    if z in x:
        x.remove(z)

if len(x) == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <stack>
#include <cmath>
#include <utility>
#include <complex>

using ll = long long;
template <class T>
using vec = std::vector<T>;

using pos = std::complex<int>;

int main()
{
    using namespace std;

    vec<ll> costs(4);
    ll n;

    for (auto& e : costs)
    {
        cin >> e;
    }
    cin >> n;

    for (int i = 0; i < 3; ++i)
    {
        costs[i + 1] = min(costs[i + 1], costs[i] * 2);
    }

    ll ans{};

    if (n >= 2)
    {
        ans += (n / 2) * costs[3];
        n %= 2;
    }
    if (n == 1)
    {
        ans += costs[2];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<queue>
#include<string>
using namespace std;
int main(){
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=1;i<=k;i++){
		if(i%2!=0){
			if(a%2!=0){
				a-=1;
			}
			a/=2;
			b+=a;
		}
		else{
			if(b%2!=0){
				b-=1;
			}
			b/=2;
			a+=b;
		}
	}
	cout<<a<<" "<<b ;
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   ll n,m,sum=0,cnt=0,i;
   cin>>n>>m;
   int a[n];
   for(i=0;i<n;i++)
   {
       cin>>a[i];
       sum+=a[i];
   }

   for(i=0;i<n;i++)
   {
       if(a[i]>=(float)sum/(4*m))
        cnt++;
   }
   if(cnt>=m)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;





    return 0;
}


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

int main(){
  int k,s; cin >> k >> s;
  int count =0;
  
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
       if(s-i-j<=k && s-i-j>=0){
         count++;
      }
    } 
  }
  
  cout << count << endl;
  
}

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

using namespace std;

int main() {
    int n, cnt = 0;
    cin >> n;
    vector<int> l(2 * n);
    for (int i = 0; i < 2 * n; ++i) cin >> l.at(i);
    sort(l.begin(), l.end());
    for (int i = 0; i < n; ++i) cnt += l.at(i * 2);
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
    	Scanner input = new Scanner(System.in);
    	while(true){
    		int num = input.nextInt();
    		if(num == 0)break;
    		System.out.println(prime(num));
    	}
    }
    
    public static long prime(int n){
    	long sum = 0;
    	int index = 0;
    	int num = 1;
    	while(index != n){
    		boolean isprime = true;
    		if(num == 1){
    			num++;
    		}else if(num == 2){
    			sum += 2;
    			index++;
    		}else{
    			if(num % 2 != 0){
    				for(int i = 3 ; i <= Math.sqrt(num) ; i+=2){
    					if(num % i == 0){
    						isprime = false;
    						break;
    					}
    				}
    			}else{
    				isprime = false;
    			}
    		}
    		if(isprime){
    			sum += num;
    			index++;
    		}
    		num++;
    	}
    	return sum;
    }
}

Measured memory_bytes: 19164
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n;
    cin>>n;
    ll ans=INF;
    for(ll i=0;i<=n;i++){
        ll cc=0;
        ll mon=i;
        while(mon>0){
            cc+=mon%6;
            mon/=6;
        }
        mon=n-i;
        while(mon>0){
            cc+=mon%9;
            mon/=9;
        }
        ans=min(ans,cc);
    }   
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
a = LIST()
g = a[0]
for i in range(1, n):
    g = gcd(g, a[i])
print(g)

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

int main()
{
  int n, m;	cin>>n>>m;
  vector<vector<int>> c(n, vector<int> (0));
  vector<bool> visited(n, false);
  
  int x, y;
  while(m--)
  {
    cin>>x>>y;
    c[x-1].push_back(y-1);
    c[y-1].push_back(x-1);
  }
  
  int i=0, count=0;
  while(i<n)
  {
    if(visited[i])
    {
        i++;
        continue;
    }
    
    count++;
    queue<int> q;
    while(!q.empty())	q.pop();
    q.push(i);
    visited[i]=true;
    while(!q.empty())
    {
      int r=q.front();
      for(int j=0; j<c[r].size(); j++)
      {
        if(!visited[c[r][j]])	
        {
          q.push(c[r][j]);
          visited[c[r][j]]=true;
        }
      }
      q.pop();
    }
    i++;
   }
  cout<<count-1;
}

static int fastio = []() {
    #define endl '\n'
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    return 0;
}();

Measured memory_bytes: 8480
/*author : Yashvardhan
Saturday, May 02, 2020
5:28 PM
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int k,a,b;
	cin >> k >> a >> b;

	for(int i = a; i <= b; i++){
		if(i % k == 0){
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;
	

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



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

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)



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

    if(a!=c){
        ANS(1);
    }
    else{
        ANS(0);
    }

    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    vector<bool> flag(3, false);
    for(char c : s){
        flag.at(c - 'a') = true;
    }
    if(flag.at(0) && flag.at(1) && flag.at(2)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

#define _USE_MATH_DEFINES
#define reb(i,b,n)         for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n)           reb(i,0,n)
#define each(it,v)         for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v)        for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vsort(v)           sort((x).begin(), (x).end()
#define rvsort(v)          sort((x).rbegin(), (x).rend()
#define mp(a, b)           make_pair(a, b)
#define fi                 first
#define se                 second
#define pb                 push_back
#define dbg(x)             cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;
#define dbgArr(table, n)   rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define dbg2Arr(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}

using namespace std; using std::stringstream;

typedef long long       ll; typedef unsigned long long ull; typedef long double     ld;
typedef pair <int, int> P;  typedef pair <int, P>      PP;
typedef vector<int>     vi; typedef vector<vi>         vvi; typedef vector<ll>      vl;
typedef vector<P >      vP; typedef vector<char>       vc;  typedef vector<string>  vs;

static const int    INF  = 0x3f3f3f3f;
static const ll     INFL = 0x3f3f3f3f3f3f3f3fLL;
static const double EPS  = 1e-9;
static const ll     MOD  = 1000000007LL;

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

int main(int argc, char *argv[])
{
    string S;
    cin >> S;

    int ans=0;
    int acgt_length = 0;
    rep(i, S.size()) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') { acgt_length++; }
        else                                                          { acgt_length = 0; }
        ans = max(ans, acgt_length);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static int N;
        static long mod = 1000000007;
        static char[] az = Enumerable.Range('a', 'z' - 'a' + 1).Select(i => (Char)i).ToArray();
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = NK[0];
            var K = NK[1];
            var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var gcd = A[0];
            for (int i = 1; i < N; i++)
            {
                gcd = Gcd(gcd, A[i]);
            }

            if(A.Max() >= K && K%gcd == 0)
            {
                Console.WriteLine("POSSIBLE");
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }

            //R = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            //var S = Console.ReadLine();

        }
        // ユークリッドの互除法 
        public static int Gcd(int a, int b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
}


Measured memory_bytes: 38464
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>

#define rep(i,n) for(long long int (i)=0;(i)<n;(i)++)
#define repa(i,n) for(long long int (i)=0;i<=n;i++)
#define co(a) cout<<(a)<<endl;
typedef long long ll;
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a+b==15){
  	cout<<'+'<<endl;
  }
  else if(a*b==15){
  	cout << '*' << endl;
  }
  else{
  	cout << 'x' <<endl;
  }

  
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
nokori=a[0]
ans=0
for i in range(n):
  if nokori>=b[i]:
    ans+=b[i]
    nokori=a[i+1]
  elif nokori+a[i+1]>=b[i]:
    ans+=b[i]
    nokori=nokori+a[i+1]-b[i]
  else:
    ans+=nokori+a[i+1]
    nokori=0
print(ans)

Measured memory_bytes: 19116
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    if(2 * k - 1 <= n)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256