akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>


using namespace std;
#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 repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for(int i = (int)(n); i > 0; --i)
#define all(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rall(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define sz(a) (int)(a).size()
#define mins(a,...) a = min({a, ## __VA_ARGS__})
#define maxs(a,...) a = max({a, ## __VA_ARGS__})
#define plusMod(a,b) a = (a % mod + b % mod) % mod
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);

int n;

struct V {
    vector<double> l, r;

    V() :l(3, dinf), r(3, -dinf) {}

    void add(int x, double val) {
        ++x;
        mins(l[x], val);
        maxs(r[x], val);
    }

    vector<double> getEvent() {
        vector<double> res(1, 0);

        rep(j, 3) rep(i, j) {
            {
                auto t = (l[i] - l[j]) / (j - i);

                if (t > 0)
                    res.push_back(t);
            }
            {
                auto t = (r[i] - r[j]) / (j - i);

                if (t > 0)
                    res.push_back(t);
            }

        }

        return res;
    }

    double get(double t) {
        double mmin = dinf, mmax = -dinf;

        rep(i, 3) {
            mins(mmin, l[i] + 1.0 * t * (i - 1));
            maxs(mmax, r[i] + 1.0 * t * (i - 1));
        }

        return mmax - mmin;
    }

};

void solve() {
    cin >> n;

    V xv, yv;

    rep(i, n) {
        double x, y;
        char d;
        cin >> x >> y >> d;

        switch (d)
        {
        case 'L':
            xv.add(-1, x);
            yv.add(0, y);
            break;
        case 'R':
            xv.add(1, x);
            yv.add(0, y);
            break;
        case 'U':
            xv.add(0, x);
            yv.add(1, y);
            break;
        case 'D':
            xv.add(0, x);
            yv.add(-1, y);
            break;
        }
    }

    auto xe = xv.getEvent();
    auto ye = yv.getEvent();

    double ans = inf;
    auto p = sz(xe);
    auto q = sz(ye);
    rep(i, p) {
        auto xx = xv.get(xe[i]);
        auto yy = yv.get(xe[i]);

        mins(ans, xx * yy);
    }

    rep(i, q) {
        auto xx = xv.get(ye[i]);
        auto yy = yv.get(ye[i]);

        mins(ans, xx * yy);
    }

    cout << ans << endl;

}


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

    solve();

    return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize(3,"Ofast","inline")
// #pragma GCC optimize(2)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#include <assert.h>
#include <time.h>
#include <iomanip>
// #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
// char buf[(1 << 21) + 1], * p1 = buf, * p2 = buf;
// #define int long long
#define lowbit(x) (x & (-x))
#define lson root << 1, l, mid
#define rson root << 1 | 1, mid + 1, r
#define pb push_back
typedef unsigned long long ull;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> VI;
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define SZ(x) ((int)((x).size()))
#define bug puts("BUG")
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
template <class T>
inline void read(T &x)
{
    int sign = 1;char c = getchar();x = 0;
    while (c > '9' || c < '0'){if (c == '-')sign = -1;c = getchar();}
    while (c >= '0' && c <= '9'){x = x * 10 + c - '0';c = getchar();}
    x *= sign;
}
#ifdef LOCAL
    FILE* _INPUT=freopen("input.txt", "r", stdin);
    // FILE* _OUTPUT=freopen("output.txt", "w", stdout);
#endif
using namespace std;
int main()
{
    ll a, b, c, k;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
    if (k <= a + b)
    {
        printf("%lld\n", min(a, k));
    }else
    {
        printf("%lld\n", a - (k - a - b));
    }
    
}

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

int main() {
  int k,x; cin >>k >>x;
  for (int i=x-(k-1); i<=x+(k-1); i++){
    cout <<i <<" ";
  }
  
  //cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

S = s()
if S[2] == S[3] and S[4] == S[5]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9924
#include <iostream>
#include <set>

using namespace std;

int main() {

    string s;
    int k;
    cin >> s >> k;

    set<string> p;

    for (auto i = 1u; i <= 5; i++) {
        for (auto j = 0u; j + i <= s.size(); j++) {
            p.insert(s.substr(j, i));
        }
    }

    for (auto x : p) {
        k--;
        if (k == 0) {
            cout << x << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 1664
mod = 1000000007
n, k = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))

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

for i in range(1, k+2):
    dp[i][0] = 1

for i in range(1, k+2):
    for j in range(1, n+1):
        K = i-1
        if K < arr[j-1]:
            dp[i][j] = dp[i-1][j] + dp[i][j-1]-dp[0][j-1]
        else:
            dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-arr[j-1]-1][j-1]
        
        dp[i][j] %= mod


print((dp[-1][-1]-dp[-2][-1] + mod)%mod)

Measured memory_bytes: 171372
#include <bits/stdc++.h>
//#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
//#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll modpow(ll b, ll i){
  ll s=1;
  while(i){
    if(i%2) s=(s*b)%MOD;
    b=(b*b)%MOD; i/=2;
  }
  return s;
}
ll nCr(ll n, ll r){
  ll m1=1,m2=1; r=min(r,n-r);
  for(int i=0; i<r; i++){
    m1=(m1*(n-i))%MOD; m2=(m2*(r-i))%MOD;
  }
  return (m1*modpow(m2,MOD-2))%MOD;
}
int main(){
  int n,a,b; cin >>n >>a >>b;  
  cout <<(modpow(2,n)-nCr(n,a)-nCr(n,b)-1+2*MOD)%MOD;
return 0;}

Measured memory_bytes: 256
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
char s[201];
int main(){
    scanf("%s",s);
    int an=-1;
    int len=strlen(s);
    for(int i=0;i<len-1;i++){
        if((i+1)%2==0){
            bool can=1;
            for(int j=0,k=(i+1)/2;j<(i+1)/2;j++,k++){
                if(s[j]!=s[k])can=0;
            }
            if(can)an=max(an,i+1);
        }
    }
    assert(an!=-1);
    printf("%d\n",an);
    return 0;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
   	
    int n,d,a;
    cin>>n>>d>>a;
    d*=2;
    vector<pair<int,int>> tp(n);
    f1(i,0,n)
    	cin>>tp[i].ff>>tp[i].ss;

    sort(tp.begin(),tp.end());
    int arr[n];
    memset(arr,0,sizeof(arr));
    int ans=0;
    int temp=0;
    f1(i,0,n)
    {
    	temp+=arr[i];
    	tp[i].ss+=temp;
    	
    	int need = max(0ll,(tp[i].ss+a-1)/a);
    	ans+=need;
    	temp-=max(0ll,((tp[i].ss+a-1)/a)*a);
    	if(need!=0)
    	{
    		auto dd = upper_bound( tp.begin()+i, tp.end(), mp(tp[i].ff+d,mod) );
    	    	if(dd-tp.begin()<n)
    	    		arr[dd-tp.begin()]+=(((tp[i].ss+a-1)/a)*a);
    	}
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4992
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

N = iin()
h = iln()
dp = [10**10 for _ in range(N)]
dp[0] = 0

for i in range(N):
    if i + 1 < N: dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
    if i + 2 < N: dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]))
print(dp[N-1])

Measured memory_bytes: 80776
n=int(input())
t,a=map(int,input().split())
H=list(map(int,input().split()))
x=1000
for i in range(n):
    if x>abs(a-(t-H[i]*0.006)):
        x=abs(a-(t-H[i]*0.006))
        ans=i+1

print(ans)

Measured memory_bytes: 9076
#-*-coding:utf-8-*-

def main():
    n = int(input())
    a1 = list(map(int, input().split()))
    a2 = list(map(int, input().split()))
    total_candy = 0

    for i in range(1, n+1):
        candy = sum(a1[:i]) + sum(a2[i-1:])
        if candy > total_candy:
            total_candy = candy
            
    print(total_candy)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    char a[105];
    for(int i=0;i<105;i++)a[i]='0';
    scanf("%s",a);
    long long k;
    scanf("%lld",&k);
    int b=0;
    int u;
    u=k;
    if(k>105)u=105;
    for(int i=0;i<u;i++){
        if(a[i]-'1'>0&&a[i]-'1'<9&&!b){
            b=a[i]-'1'+1;
        }
    }
    if(b)printf("%d\n",b);
    else printf("%c\n",a[k-1]);
}

Measured memory_bytes: 128
X, Y, A, B, C = list(map(int, input().split(' ')))
p = list(map(int, input().split(' ')))
q = list(map(int, input().split(' ')))
r = list(map(int, input().split(' ')))

p_x = sorted(p, reverse=True)[:X]
q_y = sorted(q, reverse=True)[:Y]
r_xy = sorted(r, reverse=True)[:X+Y]

apples = []
for p_ in p_x:
  apples.append(p_)
for q_ in q_y:
  apples.append(q_)
for r_ in r_xy:
  apples.append(r_)

print(sum(sorted(apples, reverse=True)[:X+Y]))

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

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

    for (int i = 0; i <= Y / 10000; i++) {
        for (int j = 0; j <= Y / 5000; j++) {
            int k = (Y - 10000 * i - 5000 * j) / 1000;
            if (k >= 0 && i + j + k == N) {
                cout << i << " " << j << " " << k;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1 " << endl;
    return 0;
}

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


int n, m;
ll ans = 0;
int w[10], l[10];
int result[10][10];
void init(){
    ans = 0;
    for(int i = 0; i < 10; i++){
        w[i] = 0;
        l[i] = 0;
        for(int j = 0; j < 10; j++){
            result[i][j] = 0;
        }
    }
}

bool check(){
    for(int i = 1; i <= n; i++){
        if(w[i] * 2 > n)return false;
        if(l[i] * 2 > n)return false;
    }
    return true;
}

void dfs(int a, int b){
    if(!check())return;
    if(a == n){
        ans++;
        return;
    }
    if(b > n){
        dfs(a + 1, a + 2);
        return;
    }
    if(result[a][b]){
        dfs(a, b + 1);
        return;
    }
    w[a]++;
    l[b]++;
    dfs(a, b + 1);
    w[a]--;
    l[b]--;
    l[a]++;
    w[b]++;
    dfs(a, b + 1);
    l[a]--;
    w[b]--;
}

int main(){
    
    while(cin >> n, n){
        cin >> m;
        init();
        for(int i = 0; i < m; i++){
            int a, b;
            cin >> a >> b;
            result[a][b] = 1;
            w[a]++;
            result[b][a] = -1;
            l[b]++;
        }
        dfs(1, 2);
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3084
#include<string>
#include<iostream>

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

using namespace std;

int simulate(int n,string s,int q){
	int len=s.length(),b=0,g=0;
	rep(i,len){
		if(s[i]=='B')	b++;
		else		g++;
	}

	int p=len-1,rm=len;
	for(int k=0;b&&g;k++){
		int rot=(n+(k==q))%rm; if(rot==0) rot=rm;
		for(int i=0;i<rot;){
			p++; if(p==len) p=0;
			if(s[p]!='@')	i++;
		}
		if(s[p]=='B')	b--;
		else		g--;
		rm--;
		s[p]='@';
	}

	return b;
}

int solve(int n,string s){
	int len=s.length(),ans=0;
	rep(i,len)	ans=max(ans,simulate(n,s,i));
	return ans;
}

int main(){
	int T;	cin>>T;
	while(T--){
		int n;
		string s;	cin>>n>>s;
		cout<<solve(n,s)<<endl;
	}
	return 0;
}

Measured memory_bytes: 928
import sys
s = input()
n = len(s)
for i in range(int((n-1)/2)):
    if s[i] != s[-1-i]:
        print("No")
        sys.exit()
second = s[0:int((n-1)/2)]
for i in range (int(len(second)/2)):
    if second[i] != second[-1-i]:
        print("No")
        sys.exit()
third = s[int((n+3)/2):n-1]
for i in range (int(len(third)/2)):
    if third[i] != third[-1-i]:
        print("No")
        sys.exit()
        
print("Yes")

Measured memory_bytes: 3064
import java.util.Scanner;

class Main
{
    public static void main(String[] args)
    {
      //入力
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      
      //計算
      long sum = 0;
      for(int i=1; i<n; i++) sum += i;
      
      
      //出力
      System.out.println(sum);
      
    }
      
}



Measured memory_bytes: 22228
X, N = map(int, input().split())
P = list(map(int, input().split()))

A = [0]*101

for i in P:
    A[i] = 1

if A[X] == 0:
    print(X)
    exit()

count = 1
while(1):
    if (X - count) >= 0:
        if (X - count) < 101:
            if A[X - count] == 0:
                print(X - count)
                exit()
        else:
            print(101)
            exit()

    if count > 0:
        count = -count
    else:
        count = -count
        count += 1

Measured memory_bytes: 9216
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i, key;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j, key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ )
  	scanf("%d", &A[i]);
  for(i = 1; i <= n; i++){
  	key = A[i];
  	j = i - 1;
  	while( j >= 0 && A[j] > key){
  		A[j+1] = A[j];
  		j--;
  	}
  	A[j+1] = key;
  	trace(A, n);
  }
  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long m,dsum=0,csum=0;
  cin >> m;
  vector<long> d(m),c(m);
  for(long i=0;i<m;i++) {
    cin >> d[i] >> c[i];
    csum+=c[i];
    dsum+=d[i]*c[i];
  }
  cout << csum-1+(dsum-1)/9 << endl;
}

Measured memory_bytes: 6340
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1000000007;

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

  ll x, y;
  if (a > k) {
    x = a - k;
    y = b;
  } else {
    x = 0;
    y = max(0LL, b - (k - a));
  }

  cout << x << " " << y << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline

N = int(readline())
A = [[] for _ in range(N)]

for i in range(N):
    count = int(readline())
    for j in range(count):
        x, y = map(int, readline().split())
        x -= 1
        A[i].append([x, y])


ans = 0
for i in range(2**N):
    pattern = [0] * N
    valid = True
    for j in range(N):
        if (i >> j) & 1:
            pattern[j] = 1

    # ビットが1になっている人の証言をみる
    for k in range(N):
        if pattern[k]:
            for x, y in A[k]:
                if pattern[x] != y:  # 矛盾があれば終了、このパターンはありえない。
                    valid = False
                    break
    if valid:
        ans = max(ans, sum(pattern))

print(ans)


Measured memory_bytes: 3064
#include<iostream>

using namespace std;

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

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

Measured memory_bytes: 256
#include<cassert>
#include<iostream>

using namespace std;

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2*N-1], dneg[2*N-1];

bool X[N][N];
//-------------------------------------------------
void in(){
    for(int i=0; i<N; i++){
        row[i] = FREE;
        col[i] = FREE;
    }
    for(int i=0; i<2*N-1; i++){
        dpos[i] = FREE;
        dneg[i] = FREE;
    }
}
//----------------------------------------------------
void print(){
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(X[i][j]){
                if(row[i] != j)
                     return;
            }
        }
    }

    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            cout << ((row[i] == j) ? "Q" : ".");
        }
        cout << endl;
    }
}
//----------------------------------------------------------------
void rec(int i){
    if(i == N){
        print();
        return;
    }

    for(int j=0; j<N; j++){
        if(NOT_FREE == col[j] ||NOT_FREE == dpos[i+j] ||NOT_FREE == dneg[i-j+N-1]) 
                 continue;
        row[i] = j;
        col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
        rec(i+1);
        row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;    
    }
}
//------------------------------------------------
int main(){
    in();
    
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            X[i][j] = false;
        }
    }

    int k;
    cin >> k;
    for(int i=0; i<k; i++){
        int r, c;
        cin >> r >> c;
        X[r][c] = true;
    }

    rec(0);

    return 0;
}



Measured memory_bytes: 3112
package main

import "fmt"

func getMin(a []int) int {
	min := -1
	for i := 0; i < len(a); i++ {
		if min == -1 || min > a[i] {
			min = a[i]
		}
	}
	return min
}

func main() {
	var n int
	fmt.Scan(&n)
	var a []int
	for i := 0; i < n; i++ {
		var temp int
		fmt.Scan(&temp)
		a = append(a, temp)
	}

	var ans int
	flag := true
	for flag {
		flag = false
		ans = getMin(a)
		for i := 0; i < n; i++ {
			if a[i]%ans > 0 {
				flag = true
				a[i] = a[i] % ans
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
string str,str2;
int main()
{
	cin>>str>>str2;
	int s=str.size(),s2=str2.size();
	if(s+1!=s2)
	{
		cout<<"No";
		return 0;
	}
	for(int i=0;i<s;i++)
	if(str[i]!=str2[i])
	{
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

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

int main()
{

int r,x,y,t,s;

cin>>t;
int tt=0,px=0,py=0,pt=0,rr=0;
int flag=1;
for(int i=0;i<t;i++)
{
    cin>>r>>x>>y;
    int tm=abs(x-px)+(abs(y-py));
    if(tm>r-pt){
        cout<<"No\n";
        return 0;
    }
    else if((r-pt-tm)%2==1){
        cout<<"No\n";
        return 0;
    }
    px=x,py=y,pt=r;
}
cout<<"Yes\n";

return 0;
}


Measured memory_bytes: 256
'use strict'
 
function main(input) {
  let x = 1;
  const y = 1000000007
  input = input - 0
  for (let i = 1;i < input + 1;i++) {
    x = x * i;
    if (x > y) x = x % y;
  }
  console.log(x);
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){
  string N;
  cin>>N;
  int a=0;
  for(int i=0;i<N.size();i++){
    a+=N.at(i)-48;
  }
  if(a%9==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3596
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , bytes ) => { read_value ! ( $ next , String ) . into_bytes ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
#[allow(dead_code)]
pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer)
}
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) } ; }
#[allow(dead_code)]
fn main() {
    input!{
        n: usize,
        w: usize,
        wv: [[u64; 2]; n],
    }
    let mut dp = vec![vec![0; w+1]; n+1];
    for i in 0..n {
        for j in 0..w+1 {
            if wv[i][0] <= j as u64 {
                dp[i+1][j] = max(dp[i][j], dp[i][(j as u64 - wv[i][0]) as usize] + wv[i][1]);
            } else {
                dp[i+1][j] = dp[i][j];
            }
        }
        //debug!(dp);
    }
    println!("{}", dp[n][w]);
}

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

int main()
{
    long long n,val[200009];

    while(cin>>n)
    {
        long long sum=0,sum2=0;
        for(int i=1; i<=n; i++)
        {
            cin>>val[i];
            sum+=val[i];
        }
        long long min = 1000000000000000009;
        for(int i=1; i<n; i++)
        {
            sum2+=val[i];
            long long v = abs(sum2-(sum-sum2));
           // cout<<v<<endl;
            if(v<min)
            {
                min = v;
            }
        }
        cout<<min<<endl;
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i,l,r) for(ll i=(l); i<(r); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int inf = 1001001001;
const ll mod = 1000000007;
using pp=pair<ll,ll>;
 
// union by size + path having
class UnionFind {
public:
   vector <ll> par; // 各元の親を表す配列
   vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
 
   // Constructor
   UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
       for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
   }
   void init(ll sz_) {
       par.resize(sz_);
       siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
       for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
  }
 
   // Member Function
   // Find
   ll root(ll x) { // 根の検索
      while (par[x] != x) {
           x = par[x] = par[par[x]]; // x の親の親を x の親とする
       }
       return x;
  }
 
   // Union(Unite, Merge)
   bool unite(ll x, ll y) {
       x = root(x);
       y = root(y);
       if (x == y) return false;
       // merge technique（データ構造をマージするテク．小を大にくっつける)
       if (siz[x] < siz[y]) swap(x, y);
       siz[x] += siz[y];
       par[y] = x;
       return true;
  }
 
  bool same(ll x, ll y) { // 連結判定
       return root(x) == root(y);
  }
 
  ll size(ll x) { // 素集合のサイズ
      return siz[root(x)];
  }
};
 
ll modpow(ll x, ll n) {
   x = x%mod;
   if(n==0) return 1;  //再帰の終了条件
 
   else if(n%2==1) {
       return (x*modpow(x, n-1))%mod;  //nが奇数ならnを1ずらす
   }
   else return modpow((x*x)%mod, n/2)%mod;  //nが偶数ならnが半分になる
}
 
ll com(ll n, ll k) {
   ll x = 1;
   for(int i=n-k+1; i<=n; i++) {
      x = x*i%mod;
   }
 
   ll y = 1;
   for(int i=1; i<=k; i++) {
       y = y*i%mod;
   }
   y = modpow(y, mod-2);
 
   return x*y%mod;
}
 
bool is_prime(const unsigned n){
   switch(n){
       case 0: // fall-through
       case 1: return false;
       case 2: // fall-through
       case 3: return true;
  } // n > 3 が保証された
 
   if(n % 2 == 0 || n % 3 == 0) return false;
   // n は 2 と 3 のいずれの倍数でもないことが保証された
   // これより n は (6の倍数)-1 か (6の倍数)+1 である
 
   // 6の倍数前後の数を使って試し割りをする
   for(unsigned i = 5; i * i <= n; i += 6) {
       if(n % i     == 0) return false; // (6の倍数)-1
       if(n % (i+2) == 0) return false; // (6の倍数)+1
   }
 
   return true;
}
 
int digsum(int n) {
   int res = 0;
   while(n > 0) {
       res += n%10; //ここをres++;に変えたら桁数を求める関数になる
       n /= 10;
   }
   return res;
}
vector<ll> divisor(ll n){
   vector<ll> ret;
   for(ll i = 1 ; i*i <= n ; i++){
       if(n%i == 0){
           ret.push_back(i);
           if(i*i != n) ret.push_back(n/i);
       }
   }
   sort(ret.begin(),ret.end());
   return ret;
}
 
int main(){

    ll n;
    cin >> n;
    set<ll> a;
    a.insert(n);
    for(ll i=0; i<1010101; i++){
        if(n%2==0){
            n/=2;
        }
        else{
            n=n*3+1;
        }
        if(a.count(n)){
            cout << i+2 << endl;
            return 0;
        }
        a.insert(n);
    }
}

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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

int main(){

    ll N, A, B;

    cin >> N >> A >> B;

    cout << min(A * N, B) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main (void) {
    int n, minHeight;
    int allowCount = 0;
    scanf("%d", &n);
    scanf("%d", &minHeight);

    for (int i=0; i<n; i++) {
        int height;
        scanf("%d", &height);
        if (height >= minHeight) {
            allowCount++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
//2018.09.14 4.5min

#include <iostream>
using namespace std;

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

    bool ax = false, bx=false, cx=false;

    int i;
    for(i=0;i<3;i++){
        if(s[i]=='a'){
            ax = true;
        }
        if(s[i]=='b'){
            bx = true;
        }
        if(s[i]=='c'){
            cx = true;
        }
    }

    if(ax && bx && cx) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		int n, count;
		boolean[] primes = new boolean[50001];
		
		primes[0] = primes[1] = false;
		for(int i = 2; i < 50000; i++){
			boolean judge = true;
			for(int j = 2; j <= Math.sqrt(i); j++){
				if(i % j == 0){
					judge = false;
					break;
				}
			}
			if(judge) primes[i] = true;
			else      primes[i] = false;
		}
		
		while(!(string = reader.readLine()).equals("0")){
			n = Integer.parseInt(string);
			count = 0;
			
			for(int i = 0; i <= n / 2; i++){
				if(primes[i] && primes[n - i]) count++;
			}
			System.out.println(count);
		}
		reader.close();
	}
}

Measured memory_bytes: 31224
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define mod 1000000007
#define vll vector<ll>

ll ti[1001][1001];
vll g[100001];ll vis[1001][1001];
char arr[1001][1001];
ll dx[2]={1,0};
ll dy[2]={0,1};


ll n,m;

ll func(ll x,ll y)
{
    if(x<1 || y<1) return 0;

    if(arr[x][y]=='#') return 0;
    if(x==1 && y==1) return 1;

    if(ti[x][y]!=-1) return ti[x][y];
   /* ll l,r;
    if(ti[x-1][y]!=-1) l=ti[x-1][r];
    else l=func(x-1,y);
    if(ti[x][y-1]!=-1) r=ti[x][y-1];
    else r=func(x,y-1);*/

      //  return ti[x][y]=l%mod+r%mod;
      return ti[x][y]=func(x-1,y)%mod+func(x,y-1)%mod;

}



int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    memset(ti,-1,sizeof ti);
	//ll n;
	cin>>n>>m;
	for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=m;j++)
            cin>>arr[i][j];
    }
    cout<<func(n,m)%mod<<endl;

	return 0;
}



Measured memory_bytes: 12160
n = int(input())
h = list(map(int,input().split()))
answer = 0

while h != [0]*n:
  prev = -1
  subcount = 0 #部分列何個あるか
  for index in range(n):
    if prev != -1 and prev != 0 and h[index] == 0:
      subcount += 1
    prev = h[index]
    h[index] = max(h[index]-1, 0)
      
  if prev != 0:
    subcount+=1
  
  answer+=subcount

print(answer)

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

int main(){
	int i,l;
	char hoge[21];
	fgets(hoge,21,stdin);
	for(i=0,l=strlen(hoge)-1;i<l+1;i++)
		putc(hoge[l-i],stdout);
	puts("");
	
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

/**
 * @author yousack
 */
public class Main {
    static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {
        while (true) {
            int a = in.nextInt();
            int d = in.nextInt();
            int n = in.nextInt();
            if (n == 0) {
                break;
            } else {
                solve(a, d, n);
            }
        }
    }
    
    public static void solve(int a, int d, int n) {
        int counter = 0;
        for (int i = a; ; i += d) {
            if (isPrime(i)) {
                counter++;
            }

            if (counter == n) {
                System.out.println(i);
                break;
            }
        }
    }
    
    public static boolean isPrime(int n) {
        boolean result = true; 
        
        if (n == 1) {
            result = false;
        }
        
        for (int i = 2; i <= Math.sqrt((double)n); i++) {
            if (n % i == 0) {
                result = false;
                break;
            }
        }
        
        return result;
    }
}

Measured memory_bytes: 20644
#include<iostream>
using namespace std;
int main()
{
	
	int n,m;cin>>n>>m;
	int tgt[105];
	for(int i=1;i<m+1;i++)
	{
		cin>>tgt[i];
	}
	int game[105][105];
	for(int i=1;i<m+1;i++)
	{
		for(int j=1;j<n+1;j++)
		{
			cin>>game[i][j];
		}
	}
	int point[105]={0};
	for(int i=1;i<m+1;i++)
	{
		int cnt=0;
		for(int j=1;j<n+1;j++)
		{
			if(game[i][j]==tgt[i])
			{
				point[j]++;
			}
			else
			{
				cnt++;
			}
		}
		point[tgt[i]]+=cnt;
	}
	for(int i=1;i<n+1;i++)
	{
		cout<<point[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <vector>
const std::vector<char> intelli = { 'A','B','C','D' };
const std::vector<char> normal = { 'C','D' };
const std::vector<int> tests = { 80,65,50,30 };
const std::vector<int> mkuptests = { 50,-1 };
char grade(const std::vector<char> res, int sum, const std::vector<int> n)
{
	for (size_t i = 0; i < n.size(); i++)
	{
		if (sum >= n[i])
		{
			return res[i];
		}
	}
	return 'F';
}
int main()
{
	int mid, final, makeup;
	while (std::cin >> mid >> final >> makeup && (mid != -1 || final != -1 || makeup != -1))
	{
		if (mid == -1 || final == -1)
		{
			std::cout << 'F' << std::endl;
			continue;
		}
		auto tmpres = grade(intelli, mid + final, tests);

		if (tmpres == 'D')
		{
			tmpres = grade(normal, makeup, mkuptests);
		}
		std::cout << tmpres << std::endl;
	}
}


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

bool check(int p1) {
	for (int j = 2; j <= sqrt(p1); j++) {
		if (p1 % j == 0)
			return 0;
	}

	return 1;
}

int main()
{	
	int n;

	cin >> n;

	while (n > 0) {
		int p = n;

		while (p > 3 && (!check(p) || !check(p - 2)))
			p--;

		cout << p - 2 << " " << p << endl;

		cin >> n;
	}

	return 0;
}



Measured memory_bytes: 2972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    string A;
    cin >> A;
    map<char, ll> cnt;
    int n = A.size();
    rep(i, n)
    {
        cnt[A[i]]++;
    }
    ll ans = 0;
    rep(i, n)
    {
        ans += n - cnt[A[i]];
    }
    cout << ans / 2+1;
    return 0;
}

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

using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  if (s[s.size() - 1] == 's') {
    cout << s + "es" << endl;
  } else {
    cout << s + "s" << endl;
  }
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;
  int k;
  cin>>k;
  bool hantei=false;
  for(int i=0;i<s.size();i++){
    int a=s[i]-'0';
    if(a==1)hantei=true;
    else {
      cout<<a<<endl;
      return 0;
    }
    if(hantei&&i+1==k){
      cout<<1<<endl;
      return 0;
    }
  }
  return 0;
}
    

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();

        int _10000 = -1;
        int _5000 = -1;
        int _1000 = -1;

        for (int i = 0; i <= N; i++) {
            for (int j = 0; j <= N-i; j++) {
                for (int k = 0; k <= N-i-j; k++) {
                    if (i + j + k == N && 10000 * i + 5000 * j + 1000 * k == Y) {
                        _10000 = i;
                        _5000 = j;
                        _1000 = k;
                        System.out.printf("%d %d %d\n", _10000, _5000, _1000);
                        sc.close();
                        return;
                    }
                }
            }
        }

        System.out.printf("%d %d %d\n", _10000, _5000, _1000);
        sc.close();
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
struct node
{
    string name;
    int num,score;
}x[109];
bool cmp(node a,node b)
{
    if(a.name==b.name) return a.score>b.score;
    return a.name<b.name;
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x[i].name>>x[i].score;
        x[i].num=i;
    }
    sort(x+1,x+n+1,cmp);
    for(int i=1;i<=n;i++)
    {
        cout<<x[i].num<<endl;
    }
    return 0;
}


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

int main() {
  int N = 0;
  cin >> N;
  int aScore = 0;
  int bScore = 0;
  vector<int> number(N);
  for(int i = 0;i<N;i++){
    cin >> number.at(i);  
  }
  sort(number.begin(),number.end());
  for(int i = N;i>0;i-=2){
    aScore += number.at(i-1);  
  }
  for(int i = N;i>1;i-=2){
    bScore += number.at(i-2);
  }
  cout << aScore - bScore << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
	ll X, A, B;
	cin >> X >> A >> B;
	if(B-A <= X && B <= A){
		cout << "delicious" << endl;
	} else if (B-A <= X && B > A){
		cout << "safe" << endl;
	} else if (B-A >X){
		cout << "dangerous" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int dp[n];
    dp[0]=0;dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
      //  cout<<dp[i]<<" ";
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;

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

  int sum=0, tmp;
  int mem=n;
  while(n){
    tmp=n%10;
    n/=10;
    sum+=tmp;
  }

  if((mem%sum)==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int Q = 301;

void solve() {
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    ll sum = 0;
    REP(i,0,n-1) {
        cin>>v[i];
        sum += v[i];
    }
    sort(rall(v));
    REP(i,0,min(n-1,k-1)) {
        sum -= v[i];
    }
    cout<<sum;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    string s=stin();
    int cnt=0;
    rep(i,s.length()){
        if(s[i]=='x')cnt++;
    }
    if(cnt>=8)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
     
#define pb emplace_back
#define fi first
#define se second
     
using namespace std;
     
typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ ll x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n;
vi G[100010];

int x[100010];

priority_queue<pi,vpi,greater<pi> > que;

int main(){

  n = in();
  REP( i , n-1 ){
    int a = in() - 1;
    int b = in() - 1;
    G[a].pb( b );
    G[b].pb( a );
  }

  REP( i , n ){
    x[i] = -1;
  }

  int k = in();
  REP( i , k ){
    int v = in() - 1;
    int a = in();
    x[v] = a;
    que.emplace( a , v );
  }

  while( !que.empty() ){
    int v = que.top().se;
    int a = que.top().fi;
    que.pop();
    YYS( w , G[v] ){
      if( x[w] == -1 ){
	x[w] = a + 1;
	que.emplace( a + 1 , w );
      } else if( abs( x[w] - a ) != 1 ){
	puts( "No" );
	return 0;
      }
    }
  }

  puts( "Yes" );
  REP( i , n ){
    printf( "%d\n" , x[i] );
  }
  
  return 0;
}


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

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

  if (a <= 0 && b >= 0) {
    cout << "Zero" << endl;
  } else if (b < 0 && (b - a + 1) % 2 == 1) {
    cout << "Negative" << endl;
  } else {
    cout << "Positive" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        if ((A != B && B != C && A != C) || A == B && B == C)
            System.out.println("No");
        else
            System.out.println("Yes");
    }
}


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

int main(){
    vector<int> a(3, 0);
    cin >> a[0] >> a[1] >> a[2];
    int sum = a[0] + a[1] + a[2];
    sort(a.begin(), a.end());
    if(sum % 2 == a[2] * 3 % 2){
        cout << (a[2] * 3 - sum) / 2 << endl;
    }else{
        cout << ( (a[2] + 1) * 3 - sum) / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;
using namespace std;
int main() {
    int n;
    string s;
    set<string> Set;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> s;
        Set.insert(s);
    }
    cout << fixed << Set.size();
}

Measured memory_bytes: 19224