akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};




bool solve(){
    string s,t;
    cin>>s>>t;
    ll n=s.size();
    ll a[30];
    ll b[30];
    rep(i,30) a[i]=-1,b[i]=-1;
    rep(i,n){
        if(s[i]!=t[i]){
            if(a[s[i]-'a']==-1){
                a[s[i]-'a']=t[i]-'a';
            }
            else if(a[s[i]-'a']!=t[i]-'a'){
                return false;
            }
        }
        else{
            if(a[s[i]-'a']==-1){
                a[s[i]-'a']=s[i]-'a';
            }
            else if(a[s[i]-'a']!=s[i]-'a'){
                return false;
            }
        }
    }
    rep(i,n){
        if(t[i]!=s[i]){
            if(b[t[i]-'a']==-1){
                b[t[i]-'a']=s[i]-'a';
            }
            else if(b[t[i]-'a']!=s[i]-'a'){
                return false;
            }
        }
        else{
            if(b[t[i]-'a']==-1){
                b[t[i]-'a']=s[i]-'a';
            }
            else if(b[t[i]-'a']!=t[i]-'a'){
                return false;
            }
        }
    }
    return true;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    if(solve()) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N = 10;
const int M_MAX = 205;
int ch[N][N];

void warshall_floyd(){
  int i,j,k;
  rep(k,N)rep(i,N)rep(j,N) ch[i][j] = min(ch[i][j],ch[i][k]+ch[k][j]);
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int H,W;cin >> H >> W;
  rep(i,N)rep(j,N) cin >> ch[i][j];
  int sum = 0;
  warshall_floyd();
  int z;
  rep(y,H)rep(x,W){
    cin >> z;
    if(z != -1) sum += ch[z][1];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
/*

         o###########oo
      o##"          ""##o
    o#"                "##
  o#"                    "#o
 #"  ##              ##   "##
#"                          ##
#  ###################       #
#                            #
#                            #
#                            #
#                            #
#                            #
#                            #
#o                           #
"#o                         ##
 "#o                       ##
  "#o                    o#"
   "#o                  ##
     "#o              o#"
       "#ooo      ooo#######oo
        ###############   "######o
     o###""        "###o      # ###
   o###o     oooo    ###    oo####"
 o###**#     #**#   ############"
 ""##""""""""""###########    #
    # oooooooo#"#**     ##    #
    # #       # # **    ##    #
    #o#       #o#  *****###ooo#
                        ##
                        ##   o###o
                        ## o##***##
               o########## #***#**##o
             o##"   ""###  #***##***#
 o#######o  ###   oo####   ##**####*#
o##"  ""#############""     ##****###
##"         ##              ##*##*###
##          ###              ##### ##
##           ###              # ##  #
##            ##                 #
##             ##
##             ###
##              ###oo
###              ""###
 ###
  ###
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long double ld;

typedef vector<vector<ll> > matrix;

matrix mul(matrix a, matrix b){
    matrix c;
    c.resize(a.size());
    for (int i = 0; i < c.size(); i++)
        c[i].resize(b[0].size(), 0);
    for (int i = 0; i < c.size(); i++)
        for (int j = 0; j < c[i].size(); j++)
            for (int k = 0; k < b.size(); k++)
                c[i][j] = (c[i][j] + a[i][k] * b[k][j]);
    return c;
}

matrix def;

matrix bpow(matrix a, ll st){
    if (st == 0)
        return def;
    if (st == 1)
        return a;
    matrix b = bpow(a, st >> 1);
    b = mul(b, b);
    if (st & 1)
        b = mul(a, b);
    return b;
}

ll AR = 19, BR = 13, CR = 23, XR = 228, YR = 322, MOD = 1e9 + 993;

ll myrand(){
    ll ZR = (XR * AR + YR * BR + CR) % MOD;
    XR = YR;
    YR = ZR;
    return ZR;
}

ll sqr(ll x){
    return x * x;
}

const ll llinf = 2e18;

const ld EPS = 1e-9;

const int maxn = 1e5 + 100, inf = 1e9 + 100, sq = 300, mod = 1e9 + 9;

bitset<10001> q;

int n;

int main()
{
    #ifdef ONPC
    //ifstream cin("a.in");
    //ofstream cout("a.out");
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
    #else
    //ifstream cin("a.in");
    //ofstream cout("a.out");
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin >> n;
    q[0] = 1;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        q |= q << x;
    }
    for (int i = 10000; i >= 0; i--)
    if (i % 10 != 0 && q[i]){
        cout << i;
        return 0;
    }
    cout << 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=2e5+50;
using namespace std;
int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
{
    int n;
    cin>>n;
    int mat[n][3];
    int res[n][3];
    for(int i=0;i<n;i++)
    {
    	cin>>mat[i][0]>>mat[i][1]>>mat[i][2];
    	res[i][0]=0;
    	res[i][1]=0;
    	res[i][2]=0;
	}
	res[0][0]=mat[0][0];
	res[0][1]=mat[0][1];
	res[0][2]=mat[0][2];
	for(int i=1;i<n;i++)
	{
		res[i][0]=mat[i][0]+max(res[i-1][2],res[i-1][1]);
		res[i][1]=mat[i][1]+max(res[i-1][2],res[i-1][0]);
		res[i][2]=mat[i][2]+max(res[i-1][0],res[i-1][1]);
	}
    	cout<<max(res[n-1][0],max(res[n-1][1],res[n-1][2]));
}



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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

int const N=1e6+3;
const double PI = acos(-1);
const ll MOD=1000000007;  ///1e9+7

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}

///************************************************ C o d e ************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    string a,b;
    cin>>a>>b;
    int i,n=sz(a),ans=0;
    for(i=0;i<n;i++) if(a[i]!=b[i]) ans++;
    cout<<ans el;

}

main()
{
///    test
///    while(1)
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!



Measured memory_bytes: 3896
#include <stdio.h>

int main(void){
  int n, s[10000], q, t[500], c;
  int i, j;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &s[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &t[i]);
  }

  c = 0;
  for (i = 0; i < q; i++) {
    for (j = 0; j < n; j++) {
      if (t[i] == s[j]) {
        c++;
        break;
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 2144
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    S = list(_ for _ in input())
    
    # 基準点iより右にいる白石の数と基準点iより左にいる黒石の数の和が答え
    # i=0 のとき答えは文字列中の白石の数になる
    cnt_w = S.count('.') # iより右みいる白石の数
    cnt_b = 0 # iより左にいる文字列中の黒石の数
    ans = cnt_w 
    for i in range(N): # i番目の石を左に置くとき       
        if(S[i] == '#'): # 黒石を左に置く場合
            cnt_b +=1
        else: # 白石を左に置く場合
            cnt_w -=1
        ans = min(ans,cnt_b+cnt_w)
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 5716
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        
        if (S.startsWith("keyence") || S.endsWith("keyence")) {
        	System.out.println("YES");
        	return;
        }
        
        boolean flg = false;
        int index = 0;
        char[] keyence = "keyence".toCharArray();
        for (int i = 0; i < S.length(); i++) {
        	if (flg) {
        		System.out.println(S.endsWith("keyence".substring(index)) ? "YES":"NO");
        		return;
        	}
        	
        	if (index >= keyence.length) {
        		break;
        	}
        	
        	if (S.charAt(i) == keyence[index]) {
        		index++;
        	} else {
        		flg = true;
        	}
        }
        
        System.out.println("NO");
    }
}

Measured memory_bytes: 22868
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n;
    cin>>n;
    double a[n];
    double x=0;
    double y=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        x+=1/a[i];
    }
    cout<<fixed<<setprecision(7);
    cout<<1/x<<endl;
    return 0;
}

Measured memory_bytes: 3752
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    d = {}
    for i in range(2,int(math.sqrt(N))+1):
        while N % i == 0:
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
            N //= i
    if N > 1:
        d[N] = 1

    ans = 0
    for i in d.values():
        n = int((-1+math.sqrt(1+4*2*i))/2)
        ans += n
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 68812
#include <cstdio>
#include <cstring>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

typedef long long llong;

int main() {
  int n;
  scanf("%d", &n);

  std::vector<int> a(n);
  std::vector<int> b(n);

  llong atotal = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    atotal += a[i];
  }
  llong btotal;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
    btotal += b[i];
  }

  int result;
  if (atotal < btotal) {
    result = -1;
  } else {
    llong need = 0;

    result = 0;
    for (int i = 0; i < n; ++i) {
      if (a[i] < b[i]) {
        need += b[i] - a[i];
        result += 1;
      }
    }

    std::vector<int> d;
    for (int i = 0; i < n; ++i) {
      if (a[i] > b[i]) {
        d.push_back(a[i] - b[i]);
      }
    }
    std::sort(d.begin(), d.end(), std::greater<int>{});

    int dn = (int)d.size();
    for (int i = 0; i < dn && need > 0; ++i) {
      need -= d[i];
      result += 1;
    }
  }

  printf("%d\n", result);
  return 0;
}

Measured memory_bytes: 1912
import math
def main():
    a, b, x = tuple(map(int, input().split()))
    x = x / a
    if a * b / 2 >= x:
        print(math.atan(b * b / 2 / x) * 180 / math.pi)
    else:
        print(math.atan((2 / a) * (b - x / a)) * 180 / math.pi)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
using namespace std;

signed main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    int q;
    cin>>q;
    rep(i,q){
        int b,e;
        cin>>b>>e;
        reverse(a+b,a+e);
    }
    rep(i,n){
        cout<<(i?" ":"")<<a[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int N;
    cin >> N;
    vector<int> p(4), t(4), lim(4);
    for (int i = 0; i < 4; ++i) cin >> p[i];
    for (int i = 0; i < 4; ++i) {
        cin >> t[i];
        lim[i] = (N + t[i] - 1) / t[i];
    }
    int ans = 1 << 30;
    REP (i, lim[0] + 1) REP (j, lim[1] + 1) REP (k, lim[2] + 1) {
        int rem = N - (t[0] * i + t[1] * j + t[2] * k), tmp = p[0] * i + p[1] * j + p[2] * k;
        if (rem > 0) {
            int l = (rem + t[3] - 1) / t[3];
            ans = min(ans, tmp + p[3] * l);
        } else {
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    ll N;
    cin >> N;
    vl A(N + 1), B(N);
    for (auto &x : A) cin >> x;
    for (auto &x : B) cin >> x;
    ll ans = 0;
    FOR(i, 0, N) {
        if (A[i] <= B[i]) {
            ans += A[i];
            ans += min(B[i] - A[i], A[i + 1]);
            A[i + 1] -= min(B[i] - A[i], A[i + 1]);
        } else {
            ans += B[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;


    int main(){
      ll n;
      cin>>n;
      ll mn = INF*INF;
      rep(i,5){
        ll a;
        cin>>a;
        mn = min(mn,a);
      }
      ll ans;
      if(n%mn == 0)ans = 4+n/mn;
      else ans = 5+n/mn;
      cout<<ans<<endl;
    }
      


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long l1,l2,n1,n2,k,i,H[10000009],ans;
bool ok[100000009];
int main()
{
	cin>>n1>>n2;
	for(k=1;k<=n1;k++)
	{
		cin>>H[k];
	}
	for(k=1;k<=n2;k++)
	{
		cin>>l1>>l2;
		if(H[l1]>=H[l2])
		{
			ok[l2]=true;
		}
		if(H[l1]<=H[l2])
		{
			ok[l1]=true;
		}
		
	}
	for(k=1;k<=n1;k++)
	{
		if(ok[k]==false) ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 4528
N, K = map(int, input().split())

A = list()
treat = {}
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for a in A:
        if a in treat.keys():
            treat[a] += 1
        else:
            treat[a] = 1

counter = 0
for j in range(1,N+1):
    if not(j in treat.keys()):
        counter += 1

print(counter)


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

int main(void){
  int n;
  cin>>n;
  long long int sum = 0;
  
  for(int i = 1; i <= n; i++) {
      if(i%3==0 || i%5==0) {
          continue;
      } else {
          sum += i;
      }
  }
  
  cout<<sum;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=1e9+7;

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

int main(){
    int H, W; cin >> H >> W;
    vector<vector<char>> s(H, vector<char>(W, 0));
    int cnt=0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> s[i][j];
            if(s[i][j] == '.') cnt++;
        }
    }
    queue<pii> que;
    vector<vi> dist(H, vi(W, 0));
    que.push({0,0});
    dist[0][0]=1;
    while(!que.empty()){
        int x, y;
        tie(x, y)=que.front();
        que.pop();
        for(int i=0; i<4; i++){
            int nx=x+dx[i];
            int ny=y+dy[i];
            if(nx<0 || nx>=H || ny<0 || ny>=W) continue;
            if(s[nx][ny] == '#' || dist[nx][ny] != 0) continue;
            dist[nx][ny]=dist[x][y]+1;
            que.push({nx, ny});
        }
    }
    if(dist[H-1][W-1] == 0) cout << -1 << endl;
    else cout << cnt-dist[H-1][W-1] << endl;
    return 0;
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);        
        List<Integer> S = new ArrayList<Integer>();
        List<Integer> T = new ArrayList<Integer>();
        int sum = 0;
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            S.add(sc.nextInt());
        }
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            T.add(sc.nextInt());
        }
        for (int i = 0; i < q; i++) {
            sum += search(S, 0, n, T.get(i));
        }
        System.out.println(sum);
        sc.close();
    }

    private static int search(List<Integer> list, int L, int R, int target) {
        while (L < R) {
           int pivot = (L + R) / 2;
            if (list.get(pivot) < target) {
                L = pivot + 1;
            } else if (list.get(pivot) > target) {
                R = pivot;
            } else {
                return 1;
            }
        }
        if (L == target) {
            return 1;
        } else {
            return 0;
        }
    }
}


Measured memory_bytes: 85568
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N = 3e5 + 7;
int32_t main(){
    IOS;
    int n; 
    cin>>n;
    int arr[n];
    for(int &x:arr) cin>>x;
    int dp[n+1];
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(arr[1] - arr[0]);
    for(int i = 3; i<=n; i++) dp[i] = min((dp[i-1] + abs(arr[i-1] - arr[i-2])), dp[i-2] + abs(arr[i-1] - arr[i-3]));
    cout << dp[n] << endl; 
    return 0;
}



Measured memory_bytes: 5228
n,q = gets.split.map(&:to_i)
s = gets.chomp
lr = q.times.map { gets.split.map(&:to_i) }
t = Array.new(n+1, 0)
n.times {|i|
  t[i+1] = t[i] + (s[i..i+1] == 'AC'? 1 : 0)
}
q.times {|i|
  l,r = lr[i]
  puts t[r-1] - t[l-1]
}

Measured memory_bytes: 11132
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int X, i, j;
    cin >> X;
    int ans = 1;

    for (i = 2; i <= X; i++){
      int beki = 1;
      for (j = 2; j < 10; j++){
        beki = pow(i, j);
        if(X >= beki){
          ans = max(ans, beki);
        }
      }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  ll n;
  cin >> n;
  
  vector<ll> p(n);  rep(i, 0, n) cin >> p[i];
  
  int ans = 0;
  rep(i, 1, n-1)
    if((p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1])) ans++;
  cout << ans << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";
  
  //cout << fixed << setprecision(15) << n << "\n";

}

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

int main(void){
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    vector<int> vecx(n), vecy(m);
    for(int i=0; i<n; i++){
        cin >> vecx.at(i);
    }
    for(int i=0; i<m; i++){
        cin >> vecy.at(i);
    }
    sort(vecx.begin(), vecx.end());
    sort(vecy.begin(), vecy.end());

    if(vecx.at(n-1) < vecy.at(0) && vecx.at(n-1) < y && vecy.at(0) > x){
        cout << "No War" << endl;
    }else{
        cout <<"War" << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
const int MAX = 2020;
bool a[MAX][MAX]={};
bool dpL[MAX][MAX]={};
bool dpR[MAX][MAX]={};

signed main(){
  int n;
  cin>>n;
  for(int i=1;i<n;i++){
    string s;
    cin>>s;
    for(int j=0;j<i;j++){
      a[i][j]=s[j]-'0';      
      a[j][i]=!a[i][j];
    }
  }
  
  for(int i=0;i<n;i++)
    dpL[i][i]=dpR[i][i]=1; 

  for(int w=2;w<=n;w++){
    {
      int l=0,r=w-1;
      for(int k=l;k<r;k++)
        dpR[l][r]|=dpR[l][k]&dpL[r-1][k]&a[r][k];    
    }    
    for(int i=1;i+w<=n+1;i++){
      int l=i,r=i+w-1;
      for(int k=l;k<r;k++){
        dpL[r-1][l-1]|=dpR[l][k]&dpL[r-1][k]&a[l-1][k];        
        dpR[l][r]|=dpR[l][k]&dpL[r-1][k]&a[r][k];
      }
    }
  }
  
  int ans=0;
  for(int i=0;i<n;i++)
    if(dpR[0][i]&dpL[n-1][i]) ans++;  
  cout<<ans<<endl;  
  return 0;
}


Measured memory_bytes: 12288
X, Y = map( int, input().split())
MOD = 10 ** 9 + 7
  
def n_H_r( n, r ):
  n1, n2 = 1, 1
  for i in range( 1, r + 1 ):
    n1 = n1 * ( n + i )  % MOD
    n2 = n2 * i % MOD
  return ( n1 * pow( n2, MOD - 2, MOD )) % MOD

cnt = 0
if ( ( X + Y ) % 3 == 0 ) and ( max( X, Y ) <= 2 * min( X, Y )):
  base = ( X + Y ) // 3
  a, b = 0, 0
  for i in range( base + 1 ):
    j = base - i
    if ( 2 * i + j == X ) and ( i + 2 * j == Y ):
      a = i
      b = j
      break
  cnt = n_H_r( a, b )
print( cnt )

Measured memory_bytes: 3064
from collections import deque
n,q=map(int, input().split())
l=[[] for i in range(n+1)]
ans=[0]*(n+1)

for i in range(n-1):
    a,b=[int(j) for j in input().split()]
    l[a].append(b)
    l[b].append(a)
for i in range(q):
    p,x=[int(j) for j in input().split()]
    ans[p]+=x

que=deque()
que.append(1)
ll=[0]*(n+1)
while que:
    y=que.popleft()
    ll[y]=1
    for i in l[y]:
        if ll[i]==1:
            continue
        ans[i]+=ans[y]
        que.append(i)
print(*ans[1:])


Measured memory_bytes: 108108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int a, b;
	cin >> a >> b;
	if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
		cout << "Possible" << endl;
	}
	else{
		cout << "Impossible" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 2*1e5;
#define PI 	3.14159265358979323846
ll lvl[15];
int books[15][15]; // books[i][0] is cost
int cost[15];


int main(){
    AC
    int n, m, x;
    cin>>n>>m>>x;
    for(int i=0; i<n; i++){
        cin>>cost[i];
        for(int j=0; j<m; j++){
            cin>>books[i][j];
        }
    }
        

    ll ans = -1;

    for(int i=0; i<(1<<n); i++){
        ll cur_cost = 0;
        memset(lvl, 0, sizeof(lvl));

        for(int j=0; j<n; j++){
            if((i>>j)&1){
                cur_cost+=cost[j];
                for(int k=0; k<m; k++){
                    lvl[k] += books[j][k];
                }
            }
        }

        bool flag = true;
        for(int j=0; j<m; j++){
            if(lvl[j]<x){
                flag = false;
                break;
            }
        }

        if(flag){
            if(ans==-1)
                ans = cur_cost;
            else
                ans = min(ans, cur_cost);
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 3520
#include <stdio.h>
#define MAX 1000000

int main(int argc, const char * argv[]) {
    int t[MAX],n,i,j,k,sum=0,count=0;
    for(i=0;i<MAX;i++){
        t[i]=1;
    }
    t[0]=t[1]=0;
    for(i=2;i*i<MAX;i++){
        if(t[i]==1){
            for(j=i*i;j<MAX;j+=i){
                t[j]=0;
            }
        }
    }
    while(1){
        scanf("%d",&n);
        if(n==0)
            break;
        for(k=2;k<MAX;k++){
            if(t[k]==1){
                sum+=k;
                count++;
            }
            if(count==n)
                break;
        }
        printf("%d\n",sum);
        sum=0;
        count=0;
    }
    return 0;
}

Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl
 
#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()
 
#define pb push_back
#define ff first
#define ss second
#define hell 1000000007
 
#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009
 
ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
ll a,b;
bool check(ll num)
{
	ll haha=num*8;
	haha/=100;
	ll hihi=num*10;
	hihi/=100;
	return haha>=a and hihi>=b;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	cin>>a>>b;
	ll low=0,high=1e18;
	ll ans;
	while(low<=high)
	{
		ll mid=(low+high)/2;
		if(check(mid))
		{
			ans=mid;
			high=mid-1;
		}
		else
		low=mid+1;
	}
	if( ((ans*8)/100)==a  and ans/10==b)
	cout<<ans<<endl;
	else
	cout<<-1<<endl;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Text.Printf (printf)

solve [x1,y1,x2,y2,x3,y3] = 
    let 
        (x,y) = solve2 (2*(x2-x1)) (2*(y2-y1)) (x1^2-x2^2+y1^2-y2^2) (2*(x3-x1)) (2*(y3-y1)) (x1^2-x3^2+y1^2-y3^2)
        r = sqrt ((x1-x)^2 + (y1-y)^2)
    in showSolution x y r

solve2 a1 b1 c1 a2 b2 c2 = ((b1*c2-b2*c1)/(a1*b2-a2*b1), (c1*a2-c2*a1)/(a1*b2-a2*b1))

showSolution x y r = printf "%.3f %.3f %.3f" (round4 x) (round4 y) (round4 r)

round4 :: RealFrac a => a -> Float
round4 x = (fromIntegral (round (x * 1000))) / 1000

main = do
    n <- readLn
    replicateM_ n $ do
        points <- (map read . words) <$> getLine
        putStrLn $ solve points

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

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

  int n, ta, ha;
  ta = 0; ha = 0;
  cin >> n;
  for (int i = 0; i < n ; i++) {
    string s, t;
    cin >> s >> t;
    if (t < s) {
      ta += 3;
    } 
    else if (t > s) {
      ha += 3;
    }
    else {
      ta++;
      ha++;
    }
  }
  cout << ta << ' ' << ha << '\n';
}


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

int t[9],d;

//âèÉêvµ½@wÅ é©Ì»è
bool isModuicSquare(void){
	int rem = (t[0] + t[1] + t[2]) % t[9];

	return ((t[3] + t[4] + t[5]) % t[9] == rem &&
					(t[6] + t[7] + t[8]) % t[9] == rem &&
					(t[0] + t[3] + t[6]) % t[9] == rem &&
					(t[1] + t[4] + t[7]) % t[9] == rem &&
					(t[2] + t[5] + t[8]) % t[9] == rem &&
					(t[0] + t[4] + t[8]) % t[9] == rem &&
					(t[2] + t[4] + t[6]) % t[9] == rem);
}

int solve(int idx,bool *used){
	if(idx == 10) return isModuicSquare() ? 1 : 0;
	if(t[idx] != 0) return solve(idx+1,used);

	int res = 0;
	for(int i=1;i<=10;i++){
		if(!used[i]){
			t[idx] = i;
			used[i] = true;
			res += solve(idx+1,used);
			used[i] = false;
			t[idx] = 0;
		}
	}

	return res;
}

int main(void){
	while(1){
		bool used[11];
		memset(used,0,sizeof(used));

		for(int i=0;i<10;i++){
			cin>>t[i];
			if(t[i] > 0) used[t[i]] = true;
		}
		if(t[0] == -1) break;

		cout<<solve(0,used)<<endl;
	}

	return 0;
}

Measured memory_bytes: 868
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d) ) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
#define PI 3.141592653589793
 
int main()
{
    double a, b, c, s, C;
    double S, L, h; 
     
    scanf("%lf%lf%lf", &a, &b, &C);
    c = sqrt(a*a + b*b - 2*a*b*cos(C*PI/180));
    L = a+b+c;
    s = L/2;
    S = sqrt(s*(s-a)*(s-b)*(s-c));
    h = 2*S/a;
    printf("%.8lf\n%.8lf\n%.8lf\n", S, L, h);
    return 0;
}


Measured memory_bytes: 2132
import java.io.*;
import java.util.*;
public class Main {
 
  public static void main(String[] args) { 
        solve();
      out.close();
  }

  private static void solve() {
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int k = sc.nextInt();
      while(a >= b && k > 0) {
        b *= 2;
        k--;
      }
      while(b >= c && k > 0) {
        c *= 2;
        k--;
      }
      if(a < b && b < c)
      out.println("Yes");
      else
      out.println("No");
  }

  public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
 
  public static FastScanner sc = new FastScanner();

  static class FastScanner {
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st=new StringTokenizer("");
      String next() {
        while (!st.hasMoreTokens())
          try {
            st=new StringTokenizer(br.readLine());
          } catch (IOException e) {
            e.printStackTrace();
          }
        return st.nextToken();
      }
      
      int nextInt() {
        return Integer.parseInt(next());
      }
      int[] readArray(int n) {
        int[] a=new int[n];
        for (int i=0; i<n; i++) a[i]=nextInt();
        return a;
      }
      long nextLong() {
        return Long.parseLong(next());
      }
  }
}

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

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

  vector<int> b(n), w(n);
  if (s[0] == '#')
    b[0] = 1;
  else
    w[0] = 1;
  for (int i = 1; i < s.size(); ++i) {
    if (s[i] == '#')
      b[i] = b[i - 1] + 1, w[i] = w[i - 1];
    else
      b[i] = b[i - 1], w[i] = w[i - 1] + 1;
  }

  int sum_b = b.back();
  int sum_w = w.back();
  int ans = sum_w;
  for (int i = 0; i < s.size(); ++i) {
    int cnt_b = b[i];
    int cnt_w = sum_w - w[i];
    ans = min(ans, cnt_b + cnt_w);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int a,b; cin >> a >> b;
    if(a<b){
        for(int i = 0; i < b; ++i) cout << a;
        cout << endl;
    }
    else{
        for(int i = 0; i < a; ++i) cout << b;
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<ll> a(n);
    ll sunuke=0,arai=0;
    ll ans=1e18;
    REP(i,n){
        cin>>a[i];
        arai+=a[i];
    }
    if(n==2){
        ans = abs(a[0]-a[1]);
    }
    else{
        REP(i,n-1){
            arai -= a[i];
            sunuke += a[i];
            //cout<<sunuke<<":"<<arai<<endl;
            ans = min(ans,abs(sunuke-arai));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
rooms=[ [[0]*10 for i in range(3)] for k in range(4) ]
rooms
      
N=int(input())
for n in range(N):
  b,f,r,v=map(int,input().split())
  rooms[b-1][f-1][r-1] += v

x=0
for i in range(4):
  if x!=0:
    print("#"*20)
  for a in range(3):
    for b in range(10):
      print(" {:d}".format(rooms[i][a][b]),end="")
    print()
  x=x+1


Measured memory_bytes: 5636
#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>

using namespace std;


class UnionFind {
  public:
    UnionFind() : _n{0}{}
    UnionFind(int n) : _n{n}, pr(n, -1){}

    int merge(int a, int b) {
      assert(0 <= a && a < _n);
      assert(0 <= b && b < _n);
      a = leader(a);
      b = leader(b);
      if (a == b) return a;
      if (-pr[a] < -pr[b]) swap(a, b);
      pr[a] += pr[b];
      pr[b] = a;
      return a;
    }

    bool same(int a, int b) {
      assert(0 <= a && a < _n);
      assert(0 <= b && b < _n);
      return leader(a) == leader(b);
    }

    int leader(int a) {
      assert(0 <= a && a < _n);
      return (pr[a]<0) ? a : (pr[a]=leader(pr[a]));
    }

  private:
    int _n;
    vector<int> pr;
};

int main() {
  int N, Q;
  cin >> N >> Q;
  UnionFind U{N};
  while (Q--) {
    int t, u, v;
    cin >> t >> u >> v;
    if (!t) {
      U.merge(u, v);
    } else {
      cout << U.same(u, v) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4048
#include <stdio.h>

int main() {
  char s[100], t[100];
  int n, i;
  scanf("%d", &n);
  scanf("%s %s", s, t);
  for(i = 0; i < n; i++) {
    printf("%c%c", s[i], t[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
int n;
vector<int> a;
int main(){
    cin >> n;
    rep(i,n){
        int temp;
        cin >> temp;
        a.pb(temp);
    }
    sort(ALL(a));
    
    int ans = a[n-1];
    int pr;
    rep(i,n-1){
        if(abs(a[n-1]-2*a[i]) <= ans){
            ans = abs(a[n-1]-2*a[i]);
            pr = a.at(i);
        }
    } 
    
    cout << a[n-1] << " " << pr << endl;
}

Measured memory_bytes: 892
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int M;
int A;
int B;
int mat[8][8];
int main(){
  int Lj4PdHRW, i, ind[8], res=0;
  rd(N);
  rd(M);
  for(Lj4PdHRW=0;Lj4PdHRW<(M);Lj4PdHRW++){
    rd(A);A += (-1);
    rd(B);B += (-1);
    mat[A][B] = mat[B][A] = 1;
  }
  for(i=0;i<(N);i++){
    ind[i] = i;
  }
  do{
    for(i=(1);i<(N);i++){
      if(!mat[ind[i-1]][ind[i]]){
        break;
      }
    }
    if(i==N){
      res++;
    }
  }
  while(next_permutation(ind+1, ind+N));
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190829-1

// --- original code ---
// int N, M, A, B;
// int mat[8][8];
// {
//   int i, res = 0;
//   int ind[8];
//   
//   rd(N,M);
//   rep(M){
//     rd(A--,B--);
//     mat[A][B] = mat[B][A] = 1;
//   }
// 
//   rep(i,N) ind[i] = i;
//   do{
//     rep(i,1,N) if(!mat[ind[i-1]][ind[i]]) break;
//     if(i==N) res++;
//   }while(next_permutation(ind+1, ind+N));
// 
//   wt(res);
// }


Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int k, x;
	cin >> k >> x;
	if((k * 500) >= x) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int D;
    cin >> D;
    if (D == 25) {
        cout << "Christmas" << endl;
    } else if (D == 24) {
        cout << "Christmas Eve" << endl;
    } else if (D == 23) {
        cout << "Christmas Eve Eve" << endl;
    } else {
        cout << "Christmas Eve Eve Eve" << endl;
    }
    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int H,W;
  cin>>H>>W;
  for(int y=0;y<H;y++){
    for(int x=0;x<W;x++){
      string s;
      cin>>s;
      if(s=="snuke"){
        cout<<(char)(x+'A')<<y+1<<endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
D = list(map(int, input().split()))
if (D[0]!=0) or (0 in D[1:]):
  print(0)
else:
  mapping = dict()
  max_ = 0
  for n in D[1:]:
    if n in mapping:
      mapping[n]+=1
    else:
      mapping[n]=1
      if max_ < n :
        max_ = n
  ans=1
  for i in range(1,max_):
    if (i in mapping) and (i+1 in mapping):
      ans *= mapping[i]**(mapping[i+1])
    else:
      ans = 0
      break
  print(ans % 998244353)

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int count=0;
  if(C!=B && A==B)count++;
  if(C!=B && A==C)count++;
  if(A!=B && B==C)count++;
  if(count==1)cout << "Yes" << endl;
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int _max = 2e6 + 10;
const int mod = 1e9 + 7;
typedef long long ll;


int main() {
    string s1,s2;
    int num=0;
    cin>>s1>>s2;
    for(int i=0;i<s1.size();i++){
        if(s1[i]!=s2[i]){
            num++;
        }
    }
    cout<<num;
    return 0;
}

Measured memory_bytes: 3916