akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<cstdio>
#include<cmath>
using namespace std;
int s[100005],a[100005],b[100005];
int main()
{
	int n;
	cin>>n;
	int win[n+1][3];
	for(int i=1;i<=n;i++)
	{
		cin>>win[i][1]>>win[i][2];
	}
	for(int i=2;i<=100000;i++)
	{
		s[i]=1;
	}
	for(int i=2;i<(int)sqrt(100000);i++)
	{
		if(s[i]==1)
		{
			for(int j=2*i;j<=100000;j+=i)
			{
				s[j]=0;
			}
		}
	}
	for(int i=1;i<=100000;i++)
	{
		if(s[i]&&s[(i+1)/2])
		{
			a[i]=1;
		}
	}
	for(int i=1;i<=100000;i++)
	{
		b[i]=a[i]+b[i-1];
	}
	for(int i=1;i<=n;i++)
	{
		int x=b[win[i][2]]-b[win[i][1]-1];
		cout<<x<<'\n';
	}
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

//const long long MOD = 1000000007;
const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, p; cin >> a >> p;
	p += 3 * a;
	cout << p / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int d1, d2, d3, d4, d5, d6;
        d1 = scn.nextInt();
        d2 = scn.nextInt();
        d3 = scn.nextInt();
        d4 = scn.nextInt();
        d5 = scn.nextInt();
        d6 = scn.nextInt();
        int n = scn.nextInt();
        int top, front;
        for(int i=0;i<n;i++){
            top = scn.nextInt();
            front = scn.nextInt();

            if(top==d1||top==d6){
              int cube[] = {d4, d2, d3, d5};
              int temp ;
              if(top==d1){
                  temp=1;
              }else{
                  temp=-1;
              }
              for(int j=0;j<4;j++){
                  if(cube[j]==front){
                      int t = j+temp;
                      if(t<0){
                          t=3;
                      }else if(t>3){
                          t=0;
                      }
                      System.out.println(cube[t]);
                  }
                }
            }
            if(top==d2||top==d5){
                int cube[] = {d6, d3, d1, d4};
                int temp ;
                if(top==d2){
                    temp=1;
                }else{
                    temp=-1;
                }
                for(int j=0;j<4;j++){
                    if(cube[j]==front){
                        int t = j+temp;
                        if(t<0){
                            t=3;
                        }else if(t>3){
                            t=0;
                        }
                        System.out.println(cube[t]);
                    }
                }
            }
            if(top==d3||top==d4){
                int cube[] = {d1, d2, d6, d5};
                int temp ;
                if(top==d3){
                    temp=1;
                }else{
                    temp=-1;
                }
                for(int j=0;j<4;j++){
                    if(cube[j]==front){
                        int t = j+temp;
                        if(t<0){
                            t=3;
                        }else if(t>3){
                            t=0;
                        }
                        System.out.println(cube[t]);
                    }
                }
            }



        }



     scn.close();

    }


}


Measured memory_bytes: 26148
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7


def main():
    n = int(input())
    a = list(map(int, input().split()))
    r = 0
    a.sort()
    if n % 2 == 1:
        if a[0] != 0:
            return 0
        r = 1
        for i in range(n//2):
            if a[i*2+1] == a[i*2+2] and a[i*2+1] == i*2+2:
                r = r*2 % mod
            else:
                return 0
    else:
        r = 1
        for i in range(n//2):
            if a[i*2+1] == a[i*2] and a[i*2+1] == i*2+1:
                r = r*2 % mod
            else:
                return 0

    return r


print(main())


Measured memory_bytes: 16340
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

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



const int N = 1e7 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
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; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, lp[N];
ll ans;
main() {
  file("lala");
  ios;
  cin >> n;
  vi pr;
  for (int i=2; i<=N - 5; ++i) {
    if (lp[i] == 0) {
      lp[i] = i;
      pr.push_back (i);
    }
    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N-5; ++j)
      lp[i * pr[j]] = pr[j];
  }
  fo(i, 1, n, 1) {
    int x = i;
//  cerr << "Ch " << i << "\n";
    ll res = 1;
    while (x > 1) {
      int cnt = 0;
      int y = lp[x];
      while (x % y == 0) ++cnt, x /= y;
      res *= 1ll * (cnt + 1);
    }
    ans += i * 1ll * res;
  }
  cout << ans;
  return 0;
}
/**

*/


Measured memory_bytes: 46528
#include <bits/stdc++.h>
#define N 200010
#define M 1000010
#define int long long
using namespace std;
int mod = 998244353;

int n, v[N], qtd[M], ans[M], sum[M], resp, s;

int poww(int a, int b)
{
    int res = 1;

    while (b > 0)
    {
        if(b & 1) res = (res * a)%mod;

        a = (a * a)%mod;

        b >>= 1;
    }

    return res;
}

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

	cin>>n;

	for(int i = 1; i <= n; i++)
	{
		cin>>v[i];

		qtd[v[i]] ++;

		s = (s + v[i])%mod;
	}

	for(int i = 1; i < M; i++)
		for(int j = i; j < M; j += i)
			sum[i] = (sum[i] + qtd[j]*j)%mod;

	for(int i = 1; i < M; i++) ans[i] = (sum[i]*sum[i])%mod;

	for(int i = M - 1; i >= 1; i--)
		for(int j = 2*i; j < M; j+=i)
			ans[i] = ((ans[i] - ans[j])%mod + mod)%mod;

	for(int i = 1; i < M; i++) resp = (resp + ans[i]*poww(i, mod - 2))%mod;

	resp = ((resp - s)%mod + mod)%mod;

	resp = (resp*poww(2, mod - 2))%mod;

	cout<<resp<<"\n";
}

Measured memory_bytes: 25344
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    int hash[256] = {};
    REP(i, h)REP(j, w){
        char a;
        cin >> a;
        hash[(int)a]++;
    }

    int even2 = 0;
    int odd = 0;
    if(h % 2 == 1){
        if(w % 2 == 1){
            odd = 1;
            even2 = w + h - 2;
        }else{
            even2 = w;
        }
    }else{
        if(w % 2 == 1){
            even2 = h;
        }else{

        }
    }
    FOR(i, 'a', 'z'){
        if(hash[i] % 4 == 0){

        }else if(hash[i] % 2 == 0){
            even2 -= 2;
        }else{
            odd--;
        }
    }

    if(even2 >= 0 && odd >= 0){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;

typedef long long ll;

#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

int A,B,C;
int main(int argc, char * argv[])
{
    ios::sync_with_stdio(false);
    cin >> A >> B >> C;
    
    if (A==7 && B==5 && C==5) cout << "YES" << endl;
    else if (A==5 && B==7 && C==5) cout << "YES" << endl;
    else if (A==5 && B==5 && C==7) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int h[n];
    int i;
    for(i=0;i<n;i++)
    {
        cin>>h[i];
    }
    int E[n];
    E[0]=0; E[1]=abs(h[1]-h[0]);
    for(i=2;i<n;i++)
    {
        if(E[i-2]+abs(h[i-2]-h[i])>E[i-1]+abs(h[i-1]-h[i]))
        {
            E[i]=E[i-1]+abs(h[i-1]-h[i]);
        }
        else E[i]=E[i-2]+abs(h[i-2]-h[i]);
    }
    cout<<"\n"<<E[n-1];
         
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    char C1,C2;
    string s;

    cin >> a >> b >> c;

    if(c-(a-b)>0) cout << c-(a-b) << "\n";
    else cout << "0\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sub[200005];
int main()
{
    ll n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        ll x;
        cin>>x;
        sub[x-1]++;
    }
    for(int i=0;i<n;i++)
        cout<<sub[i]<<' ';
    cout<<endl;
    return 0;
}


Measured memory_bytes: 5196
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 1000000007;

//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}




pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

vector<pint> list;










void floyd(int N, ll** d) {

	rep(k, N+1){
		rep(i, N+1) {
			if (d[i+1][k+1] == inf) continue;
			rep(j, N+1) {
				if (d[j+1][k+1] == inf) continue;

				d[i+1][j+1] = min(d[i+1][j+1], d[i+1][k+1] + d[j+1][k+1]);

			}

		}
	}




}


ull modpow(ull a, ull b) {
	ll retval = 0;

	if (b == 0) { return 1; }

	else if (b % 2 == 0) {
		retval = modpow(a, b / 2) % mod;
		return (retval * retval) % mod;
	}

	else {
		
		return ((a % mod) * modpow(a, b - 1)) % mod;
	}
}

ull modkaijou(ull a) {

	if (a == 1 || a == 0) { return 1; }

	ll retval = 1;

	for (ull i = a; i >= 1; i--) {
		retval = (retval * (i % mod)) % mod;
	}

	return retval % mod;
}

ull modcomb(ull a, ull b) {

	if (a == 0 || b == 0) return 1;

	return (((modkaijou(a) * modpow(modkaijou(a-b), mod - 2)) % mod) * modpow(modkaijou(b), mod - 2)) % mod;
}


vector<pint> query;

stack<int> to_1;


class DisjointSet {
public:
	vector<int> p, rank, num;


	DisjointSet() {}

	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		num.resize(size, 0);
		rep(i, size) { p[i] = i; rank[i] = 0; num[i] = 1; }
	}

	bool same(int x, int y) {

		return findSet(x) == findSet(y);

	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {

			p[y] = x;
			num[x] += num[y];

		}

		else {
			p[x] = y;
			num[y] += num[x];
			if (rank[x] == rank[y]) {

				rank[y]++;
			}

		}


	}


	ll NumberOfElements(int x) {

		return num[findSet(x)];

	}


	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
			num[x] = 1;
		}

		return p[x];
	}



};


ll ans[100005];



int main() {
	ll N, M, t, a, b;

	cin >> N >> M;

	DisjointSet ds = DisjointSet(N+1);


	rep(i, M) {
		cin >> a >> b;
		query.push_back({ a, b });
	}
	

	ans[query.size() - 1] = N * (N - 1) / 2;
	for (int i = query.size() - 2; i >= 0; i--) {

		
		if (!ds.same(query[i+1].first, query[i+1].second)) {
			ans[i] = ans[i+1] -  ds.NumberOfElements(query[i+1].first) * ds.NumberOfElements(query[i+1].second); 
			ds.unite(query[i+1].first, query[i+1].second); 
		
		}
		else {
			ans[i] = ans[i + 1]; 
		}

	}

	rep(i, M) {
		cout << ans[i] << endl;
	}

	
	return 0;
}

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

int main() {
  int n,m;
  cin>>n>>m;
  long long a[n][2];
  for(int i=0;i<m;i++){
    int k,l;
    cin>>k>>l;
    a[i][0]=k;
    a[i][1]=l;
  }
  long long dp[10010];
  dp[0]=0;
  for(int i=1;i<10011;i++)dp[i]=999999999;
  for(int i=1;i<n+1;i++){
    for(int j=0;j<m;j++){
      if(i>a[j][0]-1){
        dp[i]=min(dp[i],dp[i-a[j][0]]+a[j][1]);
      }
      else {
        dp[i]=min(dp[i],a[j][1]);
      }
    }
  }
  cout<<dp[n]<<endl;
}




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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

LL res = 0;
string s;
void dfs(int pos, LL sum, LL ns) {
    if(pos == s.size()) {
        res += (sum + ns);
        return;

    }

    dfs(pos + 1, sum, ns * 10 + (s[pos] - '0'));
    dfs(pos + 1, sum + ns, (s[pos] - '0'));

    return;
}

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

    cin >> s;
    dfs(1, 0, s[0] - '0');
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
N, K, C = map(int, input().split())
S = input()

s_len = len(S)
from_begin = set()
from_end = set()
i = 0
while(i < s_len):
    if S[i] == "o":
        from_begin.add(i+1)
        i += C
    i += 1

i = s_len - 1

while(i > -1):
    if S[i] == "o":
        from_end.add(i+1)
        i -= C
    i -= 1

# print(from_begin, from_end)

if len(from_begin) != K or len(from_end) != K:
    exit()
else:
    ans_array = list(from_end & from_begin)
    ans_array.sort()
    print("\n".join(map(str, ans_array)))


Measured memory_bytes: 92624
d=int(input())
*c,=map(int, input().split())
s=[]
for _ in range(d):
    *si,=map(int, input().split())
    s.append(si)
t=[int(input())-1 for _ in range(d)]
last=[-1]*26
smx=0
ss=0
for i in range(d):
    ss+=s[i][t[i]]
    last[t[i]]=i
    for j in range(26):
        ss-= c[j]*(i-last[j])
    print(ss)





Measured memory_bytes: 74236
-- Your code here!
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
 
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [s,w]<-getIntList
    putStrLn $ if s-w>0 then "safe" else "unsafe"

Measured memory_bytes: 3768
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
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;}
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5

int main(){
	ll l,r;
	cin>>l>>r;
	int ans=2020;
	if((r-l)>1e4){
		cout<<0<<endl;
		return 0;
	}
	else{
		for(ll i=l;i<=r;i++){
			for(ll j=i+1;j<=r;j++){
				chmin(ans,i*j%2019);
			}
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<algorithm>
#include<numeric>
#include<string>

using namespace std;

string s;
int win=0;

int main(void) {
	cin >> s;
	int l = s.size();
	for (int i = 0; i < l; i++) {
		if (s[i] == 'o')
			win++;
	}
	string ret;
	if (15 - l + win >= 8)
		ret = "YES";
	else
		ret = "NO";
	cout << ret << endl;
	return 0;

}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 610000;

int n,Q,D,ed;
int a[maxn],d[maxn];

int ok[maxn];

int main()
{
	scanf("%d%d",&n,&D);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	
	int tmp=D;
	for(int i=1;i<=n;i++) if(a[i]<tmp*2) 
	{
		d[i]=tmp;
		tmp=a[i]>tmp?a[i]-tmp:tmp-a[i];
		if(!tmp) { ed=i; break; }
	}
	if(tmp) for(int i=1;i<=n;i++) ok[i]=1;
	else
	{
		int now=0;
		for(int i=n;i>=1;i--)
		{
			int x=a[i+1];
			if((x-(now+1)<=now)) now+=x;
			if(ed<i) { ok[i]=0; continue; }
			if(d[i]>now) ok[i]=1;
		}
	}
	scanf("%d",&Q);
	while(Q--)
	{
		int x; scanf("%d",&x);
		puts(ok[x]?"YES":"NO");
	}
	
	return 0;
}


Measured memory_bytes: 8576
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <tuple>
#include <queue>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;
typedef tuple<int, int> P;
typedef tuple<ll, int, int> T;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<typename T>
void chmin(T &a, T b) {
    a = min(a, b);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int c, n, m, s, t;
    while (cin >> c >> n >> m >> s >> t, c + n + m + s + t) {
        s--;
        t--;
        vector<vector<P>> G(n);
        REP(i, 0, m) {
            int a, b, f;
            cin >> a >> b >> f;
            a--;
            b--;
            G[a].push_back(make_tuple(b, f));
            G[b].push_back(make_tuple(a, f));
        }
        const ll inf = 1LL << 60;
        auto dist = make_v(n, c + 1, inf);
        priority_queue<T, vector<T>, greater<T>> pq;
        // cost, ticket, vertex
        pq.emplace(0LL, c, s);
        REP(i, 0, c + 1) {
            dist[s][i] = 0;
        }
        while (pq.size()) {
            ll cost;
            int ticket, vertex;
            tie(cost, ticket, vertex) = pq.top();
            pq.pop();
            if (dist[vertex][ticket] < cost) continue;
            dist[vertex][ticket] = cost;
            for (auto p : G[vertex]) {
                int to, f;
                tie(to, f) = p;
                // use ticket
                if (ticket > 0 && dist[to][ticket - 1] > cost + f / 2) {
                    dist[to][ticket - 1] = cost + f / 2;
                    pq.emplace(dist[to][ticket - 1], ticket - 1, to);
                }
                // do not use ticket
                if (dist[to][ticket] > cost + f) {
                    dist[to][ticket] = cost + f;
                    pq.emplace(dist[to][ticket], ticket, to);
                }
            }
        }
        ll ans = inf;
        REP (i, 0, c + 1) {
            chmin(ans, dist[t][i]);
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N  =1e5+10;
const int mod =1e9+7;
const int MAX =1e9;
#define db double
int main() {
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;
    return 0;
}



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

 int main() {
	 int N;
	 double ans = 0.0, A;
	 cin >> N;
	 for (int i = 1; i <= N; ++i) {
		 cin >> A;
		 ans += 1.0 / A;
		
	}
	 ans = 1.0 / ans;
	cout << setprecision(16) << ans << endl;

}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    
    # S余り
    if N >= M//2:
        ans = M // 2
    # C余り
    else:
        p = (M - 2 * N) // 4
        ans = N + p

    print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;

const int N = 2e5 + 10;

int dist[N], a[N];

int main() {
  int k, n;
  scanf("%d %d", &k, &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      dist[0] = k - a[n - 1] + a[0];
      continue;
    }
    dist[i] = a[i] - a[i - 1];
  }
  int ans = k;
  for (int i = 0; i < n; i++) {
    ans = min(ans, k - dist[i]);
  }
  printf("%d\n", ans);
  return 0;
}

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

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;

int main(){
	int n; cin >> n;
	int ans = (n / 2) * ((n + 1) / 2);
	cout << ans << endl;
	return 0;
}

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

int main() {
  string O, E, A;
  cin >> O >> E;
  rep (i, O.size()){
      A.push_back(O.at(i));
    if (i==O.size()-1 && O.size()!=E.size()) break;
    else A.push_back(E.at(i));
  }
  cout << A << endl;
}

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


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll ans, a, b, c;
    ans = 1e9;
    cin>>a>>b>>c;
    ans = min(a+b,ans);
    ans = min(a+c,ans);
    ans = min(b+c,ans);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
ll mx=INT_MAX;
ll mi=INT_MIN;

int main()
{
    ll n,i,j,s=0,p,q;
    cin>>p;
    cin>>q;
    if(p<=q) cout<<"unsafe";
    else cout<<"safe";
}

Measured memory_bytes: 3632
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			lists = new ArrayList[101];
			for (int i = 0; i < 101; i++)
				lists[i] = new ArrayList<Integer>();
			while (n-- > 0) {
				int from = scanner.nextInt();
				int to = scanner.nextInt();
				lists[from].add(to);
				lists[to].add(from);
			}
			ans = 0;
			for (int i = 0; i < 101; i++) {
				if (lists[i].isEmpty())
					continue;
				b = new boolean[101];
				b[i] = true;
				slove(i, 1);

			}
			System.out.println(ans);
		}
	}

	private void slove(int from, int step) {

		ans = Math.max(ans, step);
		for (int to : lists[from]) {
			if (b[to])
				continue;
			b[to] = true;
			slove(to, step + 1);
			b[to] = false;
		}
	}

	int ans;
	boolean[] b;
	List<Integer>[] lists;
}

Measured memory_bytes: 282292
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  ll k, n;
  cin >> k >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  ll q = 0;
  for (int i = 0; i < n - 1; ++i) {
    q = max(q, a[i + 1] - a[i]);
  }
  q = max(q, k - a.back() + a[0]);
  cout << k - q << endl;

  return 0;
}


Measured memory_bytes: 1792
use proconio::fastout;
use proconio::input;

const MOD: usize = 2019;

#[fastout]
fn main() {
    input! { s: String, }
    let mut ss: Vec<_> = s
        .chars()
        .flat_map(|c| c.to_digit(10).map(|d| d as usize))
        .collect();
    ss.reverse();
    let n = ss.len();
    let mut digits = 1;
    let mut total = 0;
    let mut cnt = vec![0; MOD];
    cnt[0] += 1;
    for i in 0..n {
        total += ss[i] * digits;
        total %= MOD;
        cnt[total] += 1;
        digits = (digits * 10) % MOD;
    }
    let ans: usize = cnt
        .iter()
        .filter(|&&x| x != 0)
        .map(|&x| x * (x - 1) / 2)
        .sum();
    println!("{}", ans);
}


Measured memory_bytes: 4064
n = int(input())
a = [int(input()) for _ in range(n)]
a = sorted(a)
la = len(a)

if n % 2 == 0:
    p = la // 2
    ans = (sum(a[p:]) - sum(a[:p])) * 2 + a[p - 1] - a[p]
else:
    p = la // 2
    ans = (sum(a[p:]) - sum(a[:p])) * 2 - a[p] - a[p + 1]

    p = la // 2 + 1
    t = (sum(a[p:]) - sum(a[:p])) * 2 + a[p - 2] + a[p - 1]

    ans = max(ans, t)

print(ans)

Measured memory_bytes: 8284
n,m,x,y=map(int,input().split())
*a,=map(int,input().split())
*b,=map(int,input().split())

for z in range(x+1,y+1):
  if max(a)<z and min(b)>=z:
    print("No War")
    break
else:
  print("War")

Measured memory_bytes: 3060
s = input()
q = int(input())

ans = [" " for n in range(2*q + 1)]
ans[q] = s
frontIndex = q - 1
endIndex = q + 1
isReverse = -1

for i in range(q):
    query = input().split()
    if(query[0] == "1"):
        isReverse *= -1
    else:
        if(query[1] == "1"):
            if(isReverse == 1):
                ans[endIndex] = query[2]  
                endIndex += 1
            else:
                ans[frontIndex] = query[2]
                frontIndex -= 1
        else:
            if(isReverse == 1):
                ans[frontIndex] = query[2] 
                frontIndex -= 1
            else:
                ans[endIndex] = query[2]
                endIndex += 1
ans = "".join(ans).strip()
if(isReverse == -1):
    print(ans)
else:
    print(ans[::-1])

Measured memory_bytes: 7180
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;

//最大公約数
int gcd(int a,int b){
    return b ? gcd(b,a%b):a;
}

//最小公倍数
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

//素数判定
bool isPrime(int x){
    if(x<2)return 0;
    else if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)return 0;
    }
    return 1;
}

//桁ごとの足し算
int digsum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}

//約数列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i=1;i*i<=n;++i){
        if(n%i==0){
            ret.push_back(i);
            if(i*i !=n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//累乗の計算とあまり,0で累乗そのまま出力
long long modpow(long long a,long long n,long long mod){
    if(mod==0)mod=__LONG_LONG_MAX__;
    long long res=1;
    while(n>0){
        if(n & 1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

int X;
int main(){
    cin>>X;
    int ans=8-(X-400)/200;
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
def main():
    n = input()
    p = [int(x) for x in input().split()]
    c = 0
    for i in range(1, len(p)-1):
        if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]:
            c += 1
    print(c)

main()

Measured memory_bytes: 2940
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

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

int main(void) {
    int N;
    vector<int> A(25), B(25), C(25);
    cin >> N;
    for (int i=0;i<N;i++) cin >> A[i];
    for (int i=0;i<N;i++) cin >> B[i];
    for (int i=0;i<N-1;i++) cin >> C[i];

    int ans = 0;
    for (int i=0;i<N;i++) {
        ans += B[A[i]-1];
        if (i>0) {
            if (A[i-1] + 1 == A[i]) ans += C[A[i-1]-1];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


def eratosthenes(n):
    sieve = [True for _ in range(n + 1)]
    sieve[0] = False
    sieve[1] = False

    def _update(p):
        if sieve[p]:
            for i in range(p * 2, n + 1, p):
                sieve[i] = False

    if n > 1:
        _update(2)
    p = 3
    while p * p <= n:
        _update(p)
        p += 2
    return sieve


primes = [x for x, b in enumerate(eratosthenes(55556)) if b and x % 5 == 1]
n = int(input())
print(*primes[:n], sep=' ')

Measured memory_bytes: 3608
#include <stdio.h>

int main(void)
{
    int a, b, c ,d, train, bus;
    scanf("%d%d%d%d", &a, &b, &c, &d);

    if (a >= b) train = b;
    if (a <= b) train = a;
    if (c >= d) bus = d;
    if (c <= d) bus = c;

    printf ("%d\n", train + bus);
}


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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

#define prev(i) (i - 1 + n) % n

int main() {
	fastio;
	
    int n, x; cin >> n >> x;
    vi a(n); forn(i, n) cin >> a[i]; 

    ll mn_cost = 0; forn(i, n) mn_cost += a[i];

    forsn(k, 1, n) {
        ll cost = (ll) k * x;

        forn(i, n) cost += min(a[i], a[prev(i)]); 

        mn_cost = min(mn_cost, cost);

        vi b(n); forn(i, n) b[i] = min(a[i], a[prev(i)]);
        a = b;
    }

    cout << mn_cost << endl;
	
	return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<bool> flag(26,false);
  char tmp;
  
  while(cin>>tmp){
    if(tmp=='a')flag[0]=true;
    if(tmp=='b')flag[1]=true;
    if(tmp=='c')flag[2]=true;
    if(tmp=='d')flag[3]=true;
    if(tmp=='e')flag[4]=true;
    if(tmp=='f')flag[5]=true;
    if(tmp=='g')flag[6]=true;
    if(tmp=='h')flag[7]=true;
    if(tmp=='i')flag[8]=true;
    if(tmp=='j')flag[9]=true;
    if(tmp=='k')flag[10]=true;
    if(tmp=='l')flag[11]=true;
    if(tmp=='m')flag[12]=true;
    if(tmp=='n')flag[13]=true;
    if(tmp=='o')flag[14]=true;
    if(tmp=='p')flag[15]=true;
    if(tmp=='q')flag[16]=true;
    if(tmp=='r')flag[17]=true;
    if(tmp=='s')flag[18]=true;
    if(tmp=='t')flag[19]=true;
    if(tmp=='u')flag[20]=true;
    if(tmp=='v')flag[21]=true;
    if(tmp=='w')flag[22]=true;
    if(tmp=='x')flag[23]=true;
    if(tmp=='y')flag[24]=true;
    if(tmp=='z')flag[25]=true;
  }
  int cnt=27;
  for(int i=0;i<26;i++){
    if(flag[i]==false) {cnt=i; break;}
  }
  if(cnt==0) cout<<'a';
  if(cnt==1) cout<<'b';
  if(cnt==2) cout<<'c';
  if(cnt==3) cout<<'d';
  if(cnt==4) cout<<'e';
  if(cnt==5) cout<<'f';
  if(cnt==6) cout<<'g';
  if(cnt==7) cout<<'h';
  if(cnt==8) cout<<'i';
  if(cnt==9) cout<<'j';
  if(cnt==10) cout<<'k';
  if(cnt==11) cout<<'l';
  if(cnt==12) cout<<'m';
  if(cnt==13) cout<<'n';
  if(cnt==14) cout<<'o';
  if(cnt==15) cout<<'p';
  if(cnt==16) cout<<'q';
  if(cnt==17) cout<<'a';
  if(cnt==18) cout<<'s';
  if(cnt==19) cout<<'t';
  if(cnt==20) cout<<'u';
  if(cnt==21) cout<<'v';
  if(cnt==22) cout<<'w';
  if(cnt==23) cout<<'x';
  if(cnt==24) cout<<'y';
  if(cnt==25) cout<<'z';
  if(cnt==27) cout<<"None";
  cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<deque>
#include<iomanip>
#include<ctime>
#include<bitset>
using namespace std;

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

	swap(A, B);
	swap(A, C);

	cout << A << " " << B << " " << C << endl;

	return 0;
}

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

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

using namespace std;
using ll = long long;

int main(void) {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> vec;
  for (int i = 1; i <= min(a, b); i++) {
    if (a % i == 0 && b % i == 0) {
      vec.push_back(i);
    }
  }
  cout << vec[vec.size() - k] << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mem[25][25][25][25];
int H,W;
char t[20][20];

int solve(int ay,int ax,int by,int bx){
  if(mem[ay][ax][by][bx]!=-1)return mem[ay][ax][by][bx];
  set<int> s;
  for(int i=ay;i<by;i++){
    for(int j=ax;j<bx;j++){
      if(t[i][j]=='X')continue;
      int lu=solve(ay,ax,i,j);
      int ld=solve(i+1,ax,by,j);
      int ru=solve(ay,j+1,i,bx);
      int rd=solve(i+1,j+1,by,bx);
      s.insert(lu^ld^ru^rd);
    }
  }
  int res;
  for(int i=0;;i++){
    if(s.count(i)==0){
      res=i;
      break;
    }
  }
  return mem[ay][ax][by][bx]=res;
}

int main(){
  memset(mem,-1,sizeof(mem));
  cin>>H>>W;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cin>>t[i][j];
  cout<<(solve(0,0,H,W)?"First":"Second")<<endl;
  return 0;
}

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

int main(){
    int  n;
    cin >> n;
    if(n >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main()
{
 string S,T,U;
 cin>>S>>T;

 int A,B;
 cin>>A>>B ;
 cin >> U ;
 if (U==S){
    A=A-1 ;
    cout <<A<<' ' <<B ;
 }
 else{
    B=B-1 ;
    cout<<A<< ' '<<B;
 }
  return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int x[105];
  int y[105];
  rep(i, N) cin >> x[i];
  rep(i, M) cin >> y[i];
  
  int xmax =-10000000;
  int ymin = 10000000;
  
  rep(i, N) xmax = max(xmax, x[i]);
  rep(i, M) ymin = min(ymin, y[i]);
  
  if(xmax<ymin && xmax < Y && X < ymin) cout << "No War" << endl;
  else cout << "War" << endl;
}

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

int main(){
  int n,a,i;
  vector<int> v;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a;
    v.push_back(a);
  }
  while(v.size()){
    cout<<v.back();
    if(v.size()>1)cout<<" ";
    v.pop_back();
  }
  cout<<endl;
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int n;
int sum;


int main(){
	cin>>n;
	
	for(register int i=0; i<n; i++){
		int tmp;
		cin>>tmp;
		
		sum+=(tmp-1);
	}
	
	printf("%d\n", sum);
	return 0;
}


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


void solve(std::string S, std::string T){
    int ans = 0;
    for (int i = 0; i < 3; i++)
        if(S[i] == T[i])
            ans++;

    cout << ans << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int max(int a, int b) { return (a > b)? a : b; } 
  
// Returns the maximum value that can be put in a knapsack of capacity W 
int knapSack(int W, int wt[], int val[], int n) 
{ 
   int i, w; 
   int K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
} 
signed main(){ int n,W,wt[101],val[101];
  cin>>n>>W;
  for(int i=0;i<n;i++){
    cin>>wt[i]>>val[i];}
  cout<<knapSack(W,wt,val,n);}

Measured memory_bytes: 79104
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

int twos(int n) {
	int sum = 0;
	while (true)
	{
		if (n % 2 == 0) {
			sum++;
			n /= 2;
		}
		else {
			break;
		}
	}

	return sum;
	
}



int main() {

	int n;
	cin >> n;

	int sum = 0;

	VI v(n);
	REP(i, n) {
		cin >> v[i];
		if (v[i] % 2 == 0) {
			sum += twos(v[i]);
		}
	}

	ANS(sum);
	
	




	return 0;
}



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

using namespace std;

int main()
{
  int x,a=8;
  cin>>x;
  for(int i=400;i<2000;i+=200){
    if(i<=x&&x<i+200){
      cout<<a<<endl;
      break;
    }
    a--;
  }
}

Measured memory_bytes: 3604
// "static void main" must be defined in a public class.
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int D=in.nextInt();
        int T=in.nextInt();
        int S=in.nextInt();
        double t=(double)(D)/(double)(S);
        if(t<=(double)T)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 27120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 200004
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef pair<int, int> P;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e16;
//__gcd(a,b), __builtin_popcount(a);

ll a[MAX], total;

int solve(ll m, int n){
	int r = 0, l1 = 1, l2 = 1;
	ll sum = 0, s1, s2, s3, t;
	a[0] = 0;
	
	while(r < n){
		while(a[l1]-a[r] < m){
			if(a[l1] == INF)break;
			l1++;
		}
		while(a[l2]-a[l1] < m){
			if(a[l2] == INF)break;
			l2++;
		}
		if(a[l1] == INF || a[l2] == INF)return 1;
		
		if(total-(a[l2]-a[r]) >= m)return 0;
		else{
			r++;sum += a[r];
		}
	}
	
	return 1;
}

int main(){
	int n;
	scanf("%d", &n);
	fill(a, a+MAX, INF);
	rrep(i,n){
		scanf("%lld", &a[i]);
		a[n+i] = a[i];
	}
	for(int i = 2;i <= 2*n;i++){
		a[i] += a[i-1];
	}
	total = a[n];
	
	ll vl = 0, vr = INF;
	while(vr-vl > 1){
		ll mid = (vr+vl)/2;
		int f = solve(mid, n);
		if(f)vr = mid;
		else vl = mid;
	}
	printf("%lld\n", vl);
	return 0;
}

Measured memory_bytes: 4780
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int n, cnt = 0;
void dfs(string x)
{
    if (stoll(x) > n)
    {
        return;
    }
    int c[3] = {};
    rep(i, 0, x.size())
    {
        if (x[i] == '3')
            c[0]++;
        else if (x[i] == '5')
            c[1]++;
        else if (x[i] == '7')
            c[2]++;
    }
    if (c[0] > 0 && c[1] > 0 && c[2] > 0)
        cnt++;
    dfs(x + '3');
    dfs(x + '5');
    dfs(x + '7');
}

int main()
{
    cin >> n;
    dfs("0");
    cout << cnt << endl;
}


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

using namespace std;

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

    for (int i = 1; i <= N; ++i) {
        if ((int) (i * 1.08) == N) {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    n, m, x = map(int, input().split())
    a_list = list(map(int, input().split()))
    left = len([a for a in a_list if a < x])
    right = len([a for a in a_list if a > x])
    print(min(left, right))

if __name__ == '__main__':
    main()

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

int main(){

    int n;

    cin>>n;

    vector<int> p(n);

    int  count = 0;

    for(int i=0; i<n; i++){
        cin>>p.at(i);
    }

    for(int i=1; i<n-1; i++){

        if( p.at(i-1) < p.at(i) && p.at(i) <p.at(i+1) ) count++;

        else if (p.at(i-1) > p.at(i) && p.at(i) > p.at(i+1)) count++;

        else continue;



       }

    cout<<count<<endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    int n;
    cin>>n;
    vector<ll> a(100, 0);
    for(int i=1;i<=n;i++){
	int b = i%10;
	int t = i;
	while( t >= 10 ){
	    t/=10;
	}
	a[t*10+b] ++;
    }
    ll res = 0;
    for(int i=0;i<100;i++){
	int k = i%10*10 + i/10; 
	res += a[i]*a[k];
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
c[2];i;m;main(j,s)char*s;{gets(s);for(gets(s);s[++i];*c&=c[1],m=fmax(__builtin_popcount(*c),m))for(*c=c[1]=j=0;s[j];)c[j<i]|=1<<s[j++]-97;printf("%d",m);}

Measured memory_bytes: 128