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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi p(n), q(n);
    rep(i,n) cin>>p[i];
    rep(i,n) cin>>q[i];
    vi a;
    rep(i,n) a.pb(i+1);
    ll idx=0;
    ll P, Q;
    do{
        bool png=false, qng=false;
        idx++;
        rep(i,n){
            if (a[i]!=p[i]){
                png = true;
            }
            if (a[i]!=q[i]){
                qng = true;
            }
        }
        if (!png) P = idx;
        if (!qng) Q = idx;
    }while(next_permutation(all(a)));
    cout<<abs(P-Q)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 





int main(void){
    int a,b;
    cin>>a>>b;
    if(a>=13)cout<<b<<endl;
    else{
        if(a>=6)cout<<b/2<<endl;
        else cout<<0<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

class combination{
private:
    vector<mint> fact,inv,finv;
public:
    combination(int N){
        fact = inv = finv = vector<mint>(N+1);
        fact[0] = fact[1] = 1;
        inv[0] = inv[1] = 1;
        finv[0] = finv[1] = 1;
        for(ll i=2;i<=N;i++){
            fact[i] = fact[i-1]*i;
            inv[i] = (mint) mod - inv[mod%i]*(mod/i);
            finv[i] = finv[i-1]*inv[i];
        }
    }
    mint f(int i){
        return fact[i];
    }
    mint comb(int n,int k){
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fact[n]*finv[k]*finv[n-k];
    }
    mint hcomb(int n,int k){
        if(n==0 && k==0) return 1;
        return comb(n+k-1,k);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,K;
    cin >> N >> M >> K;
    mint ans = 0;
    combination C(N);
    for(int i=0;i<=K;i++){
        ans += C.comb(N-1,i)*M*((mint) M-1).pow(N-i-1);
    }
    cout << ans << "\n";
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int num = 0;
  int rem = 1;
  while (rem < b) {
    rem = rem + a - 1;
    num++;
  }
  cout << num << endl;
  return 0;
}

Measured memory_bytes: 3536
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
S = sum(A)
cA = Counter(A)

q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    num_b = cA[b]
    if num_b > 0:
        cA[b] = 0
        cA[c] += num_b
        S += num_b * (c - b)
    print(S)

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

using namespace std;

typedef long long ll;

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

	string s;
	cin >> s;

	int n = s.size();

	string ans;
	rep(i, n){
		if(i % 2 == 0) ans.push_back(s[i]);
	}

	cout << ans << endl;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

const int MAXN = 100;

LL fact[MAXN] = {0}, ifact[MAXN] = {0};
LL ncr[MAXN][MAXN];
void preprocess() {
	ncr[0][0] = 1;
	ncr[1][0] = ncr[1][1] = 1;
	for(int i = 2; i < MAXN; i++) {
		ncr[i][0] = 1;
		for(int j = 1; j <= i; j++) {
			ncr[i][j] = ncr[i-1][j] + ncr[i-1][j-1];
		}
	}
}

pair<LL, LL> sum(LL n) {
	pair<LL, LL> res = {0, 0};
	for(int i = 0; i <= n; i++) {
		if(i % 2 == 0)
			res.F += ncr[n][i];
		else
			res.S += ncr[n][i];
	}
	return res;
}

int main() {
  ios_base::sync_with_stdio(false);
	preprocess();
	LL a;
	LL odd = 0, even = 0;
	LL n, p;
	cin >> n >> p;
	for(int i = 0; i < n; i++) {
		cin >> a;
		if(a % 2) odd++;
		else even++;
	}
	LL res = 0;
	LL A = expo(2ll, even);
	auto temp = sum(odd);
	A *= temp.F;
	LL B = expo(2ll, even);
	B *= temp.S;
	if(p == 0)
		res = A;
	else
		res = B;
	cout << res << endl;
  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    int max1, max2;
    vector<int> a(n), b(n);
    rep(i, n) {
      cin >> a[i];
      b[i] = a[i];
    }
    sort(b.begin(), b.end(), greater<int>());
    max1 = b[0];
    max2 = b[1];
    if (max1 == max2) {
      rep(i, n) {
        cout << max1 << '\n';
      }
    } else {
      rep(i, n) {
        if (a[i] == max1) {
          cout << max2 << '\n';
        } else {
          cout << max1 << '\n';
        }
      }
    }


    return 0;
}


Measured memory_bytes: 3200
#include<stdio.h>
int main(){
  int s,n;
  char c;
  scanf("%d",&s);
  while(1){
    scanf("\n%c",&c);
    if(c=='=')break;
    scanf("%d",&n);
    if(c=='+')s+=n;
    if(c=='-')s-=n;
    if(c=='*')s*=n;
    if(c=='/')s/=n;
  }
  printf("%d\n",s);
  return 0;
}

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

using namespace std;

string  solve(int n,string r) {
    if (n%2!=0) return "No";
    string r2 = r.substr(n/2);
    string r1 = r.erase(n/2);
    return r1==r2 ? "Yes" : "No";
}

int main(){
    int n;
    string r;
    cin >> n;
    cin >> r;
    cout << solve(n,r) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#include <stack>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
using namespace std;
const int MAXN=1e6+50;
const int inf=0x3f3f3f3f;
const int M=5000*4;
char ch[MAXN];
int main()
{
    cin>>(ch+1);
    int f1=0,f2=0;
    for(int i=1;i<=3;i++){
        if(ch[i]=='A')f1++;
        if(ch[i]=='B')f2++;
    }
    if(f1==0||f2==0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}
/*

*/



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<30)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-6
using namespace std;


int main(){
	string ban;
	int nseg=0;
	char pre=0;
	cin>>ban;
	rep(i,ban.length()){
		if(pre!=ban[i])nseg++;
		pre= ban[i];
	}
	if(ban[0]=='o' && ban[ban.length()-1]=='o')nseg--;
	cout<<(nseg%2==0?'o':'x')<<endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll h, w;
	cin >> h >> w;

	ll min_dif = 1e10+100;
	vector<ll> a(3); //temp_area1, temp_area2, temp_area3;
	for(int i= 0; i < h; i++){
		a[0] = i*w; //temp_area1;
		//a[1] = w*((h-i)/2); //temp_area2;
		a[1] = (w/2)*(h-i); //temp_area2;
		a[2] = h*w - (a[1] + a[0]); //temp_area3;
		sort(a.begin(), a.end());
		ll temp_min_dif = abs(a[0] - a[2]);//temp_max - temp_min;
	
		min_dif = min(min_dif, temp_min_dif);
		a[0] = i*w; //temp_area1;
		a[1] = w*((h-i)/2); //temp_area2;
		//a[1] = (w/2)*(h-i); //temp_area2;
		a[2] = h*w - (a[1] + a[0]); //temp_area3;
		sort(a.begin(), a.end());
		temp_min_dif = abs(a[0] - a[2]);//temp_max - temp_min;
		min_dif = min(min_dif, temp_min_dif);
		//cout << "a0, a1, a2: "<< a[0] <<" "<< a[1] << " "<< a[2]<< endl;
	}
	swap(h, w);
	for(int i= 1; i < h; i++){
		a[0] = i*w; //temp_area1;
		//a[1] = w*((h-i)/2); //temp_area2;
		a[1] = (w/2)*(h-i); //temp_area2;
		a[2] = h*w - (a[1] + a[0]); //temp_area3;
		sort(a.begin(), a.end());
		ll temp_min_dif = abs(a[0] - a[2]);//temp_max - temp_min;
		//cout << "a0, a1, a2: "<< a[0] <<" "<< a[1] << " "<< a[2]<< endl;
		min_dif = min(min_dif, temp_min_dif);
		a[0] = i*w; //temp_area1;
		a[1] = w*((h-i)/2); //temp_area2;
		//a[1] = (w/2)*(h-i); //temp_area2;
		a[2] = h*w - (a[1] + a[0]); //temp_area3;
		sort(a.begin(), a.end());
		temp_min_dif = abs(a[0] - a[2]);//temp_max - temp_min;
		//cout << "a0, a1, a2: "<< a[0] <<" "<< a[1] << " "<< a[2]<< endl;
		min_dif = min(min_dif, temp_min_dif);
	}
	cout << min_dif << endl;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Cryptography;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s1 = input.ReadLine();
        var s2 = input.ReadLine();

        StringBuilder sb = new StringBuilder();

        for(int i=0; i<s1.Length; i++) {
            sb.Append(s1[i]);
            if(i < s2.Length) sb.Append(s2[i]);
        }

        return sb;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)

#define INF 100000000000
#define M 1000000007

#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

long H, W;
long A[11][11] = {0};

int main() {
	long i, j;
	long ci, cj;
	long sum = 0;
	long cnt = 1;
	char buf[10];
	
	sl(H); sl(W);
	for(i=1;i<=H;i++) {
		ss(buf);
		for(j=1;j<=W;j++) {
			if(buf[j-1] == '#')  {
				A[i][j] = 1;
				sum++;
			} else {
				A[i][j] = 0;
			}
		}
	}
	
	ci = 0; cj = 0;
	i = 1; j = 1;
	while(1) {
		if(A[i+1][j]) {
			ci = i;
			i++;
			cnt++;
		}
		if(A[i][j+1]) {
			cj = j;
			j++;
			cnt++;
		}
		if(i == H && j == W) {
			if(cnt == sum) printf("Possible\n");
			else printf("Impossible\n");
			return 0;
		}
		if(i == ci && j == cj) break;
		ci = i; cj = j;
	}
	
	printf("Impossible\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
template <typename T>
T gcd(const T x, const T y) {
  if (x == 0) {
    return y;
  } else if (y == 0) {
    return x;
  } else if (x < y) {
    return gcd(x, y % x);
  } else if (y < x) {
    return gcd(y, x % y);
  } else {
    return x;
  }
}

template <typename T>
T lcm(const T x, const T y) {
  if (x == 0 || y == 0) {
    return 0;
  } else {
    return x / gcd(x, y) * y;
  }
}

int main() {
  int n;
  std::cin >> n;
  std::vector<uint64_t> a(n);
  for (auto &i : a) {
    std::cin >> i;
  }

  if (n == 1) {
    std::cout << a[0] << std::endl;
    return 0;
  }
  auto ans = lcm(a[0], a[1]);
  for (int i = 2; i < n; i++) {
    ans = lcm(ans, a[i]);
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int, int>;
const int MOD = 1e9+7;
const double EPS = 1e-9;
const int INFTY = 3e8;

vi path;
vector<bool> seen, finished;

void dfs(const vector<map<int, int>> &G, int v) {
  seen[v] = true;

  for (auto p : G[v]) {
    auto &nv = p.first;
    auto &coin = p.second;

    if (path[nv] == INFTY) continue;

    if (path[v] == INFTY) {
      path[nv] = INFTY;
      dfs(G, nv); continue;
    }

    if (path[nv] < path[v] + coin) {
      if (seen[nv] && !finished[nv]) path[nv] = INFTY;  // loop
      else path[nv] = path[v] + coin;
      dfs(G, nv);
    }
  }

  finished[v] = true;
  return;
}

void solve() {
  int n, m, p; cin >> n >> m >> p;
  vector<map<int, int>> edge(n);
  int a, b, c;
  rep(i,m) {
    cin >> a >> b >> c; --a; --b; c-=p;
    if (!edge[a].count(b)) edge[a][b] = c;
    else edge[a][b] = max(edge[a][b], c);
  }

  path.assign(n, -INFTY);
  path[0] = 0;
  seen.assign(n, false);
  finished.assign(n, false);

  dfs(edge, 0);

  int ans = path[n-1];
  if (path[n-1] == INFTY) ans = -1;
  if (path[n-1] < 0) ans = 0;
  cout << ans << endl;
  return;
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 896
#define M_PI 3.14159265358979
#include <bits/stdc++.h>
#include <map> // pair
#include <cmath>
using namespace std;

int main(){
   double a,b,x;
   double ans;
  cin>>a>>b>>x;
  double d = (2.0*x)/(a*b);
  if(d<=a){
  ans = atan(b/d);
  ans=(((ans)/2/M_PI)*360);
  }else{
  d = 2.0*x/(a*a)-b;
  ans = atan((b-d)/a);
  ans=(((ans)/2/M_PI)*360);
  }
  cout<<setprecision(12)<<ans<<endl;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
a=[]
a.append("."*(W+2))

for _ in range(H):
    a.append("."+input()+".")
a.append("."*(W+2))
    
mod=10**9+7

dp=[[0]*(W+2) for _ in range(H+2)]
dp[1][1]=1

for i in range(1,H+1):
    for j in range(1,W+1):
        if a[i][j]==".":
            add=0
            if a[i-1][j]==".":
                add+=dp[i-1][j]
            if a[i][j-1]==".":
                add+=dp[i][j-1]
            dp[i][j]+=add
            dp[i][j]%=mod
            
print(dp[H][W]%mod)

Measured memory_bytes: 54764
def main():
    n = int(input())

    answers = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
    for _ in range(n):
        result = input()
        answers[result] += 1
    for key, value in answers.items():
        print(f'{key} x {value}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
import java.util.Scanner;

public class Main{
    public static void main(String[] arg){
        int x, i;
        x = 0;
        i = 0;
        Scanner scan = new Scanner(System.in);
        for(;;){
            i++;
        	x = scan.nextInt();
            if(x == 0) break;
            System.out.println("Case "+ i +": "+ x);
        }
        scan.close();
    }
}


Measured memory_bytes: 42776
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
struct E{
  int e,a;
  E(){}
  E(int e,int a):e(e),a(a){}
};
int x,y,z;
int v[55];
E e[66];
//int dp[55][5555];
double dp[55][5555];
//int solve(int n,int m){
double solve(int n,int m){
  if(n >= y) return m;
  if(dp[n][m] >= 0) return dp[n][m];

  double ret = 0;
  for(int i = 0; i < x; i++){
    int nn = n + v[i];
    int nm = m;
    switch(e[nn].e){
    case 1:
      nn += e[nn].a;
      break;
    case 2:
      nm += e[nn].a;
      break;
    case 3:
      nm -= e[nn].a;
    }
    nm = max(nm,0);
    ret += solve(nn,nm);
  }
  return dp[n][m] = ret / x;
}
int main(void){
  while(1){
    scanf("%d%d%d",&x,&y,&z); if(!x) break;
    for(int i = 0; i <= 66; i++) e[i] = E(0,0);
    //memset(dp,-1,sizeof(dp));
    for(int i = 0; i < 55; i++){
      for(int j = 0; j < 5555; j++){
	dp[i][j] = -1;
      }
    }
    for(int i = 0; i < x; i++){
      scanf("%d",v+i);
    }
    for(int i = 0; i < z; i++){
      int a,b,c;
      scanf("%d%d%d",&a,&b,&c);
      e[a] = E(b,c);
    }
    printf("%d\n",(int)solve(0,0));
  }
}

Measured memory_bytes: 3416
def main():
    n = int(input())
    a = list(map(int, input().split()))
 
    section_needed = sum(a)
    ans = 0
    section_count = 1
    total_section = 1
    for i in range(n+1):
        ans += section_count
        section_count -= a[i]
        if section_count <= 0 and i != n:
            print(-1)
            return
        if i == n and total_section != section_needed:
            print(-1)
            return
        next_branch = min(max(0, section_needed - total_section), section_count)
        total_section += next_branch
        section_count += next_branch
 
    print(ans)
 
main()

Measured memory_bytes: 20032
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <numeric>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>

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

  std::vector<int> L(N);
  for (auto& li: L) scanf("%d", &li);

  int D = 0;
  int res = 1;
  for (int i = 0; i < N; ++i) {
    D += L[i];
    if (D <= X) ++res;
  }
  printf("%d\n", res);
}


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

typedef unsigned long long int ulint;
typedef long long int lint;

int main(){
  ulint H, W, N;
  cin >> H >> W >> N;

  ulint v = max(H, W);

  ulint ret = (N - 1) / v + 1;

  cout << ret << endl;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// nCr(n,r)
int nCr(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (nCr(n - 1, r - 1) + nCr(n - 1, r));
}

// gcd(a,b)
int gcd(int a,int b){
	if(a == 0) return b;
	else if(b == 0) return a;
	else return gcd(b,a % b);
}

// lcm(a,b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// swap(&a, &b);
void swap(int *a,int *b){
	int tmp;
	tmp = *a;	*a = *b;	*b = tmp;
	return;
}

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	nongetpop(array,&(*size));
	return temp;
}

int nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[])
{
	int n,point[5000007],pat[5000007] = { 0 };
	int sum = 0,i = 1;
	scanf("%d",&n);
	for (i = 1; (i <= n && sum < n); ++i)
	{
		sum += i;
		point[i] = i;
		pat[i] = 1;
	}
	if(sum == n){
		for (int k = 1; k < i; ++k)
		{
			if(pat[k])	printf("%d\n",point[k]);
		}
	}
	else{
		pat[abs(sum - n)] = 0;
		for (int k = 1; k < i; ++k)
		{
			if(pat[k])	printf("%d\n",point[k]);
		}
	}
	return 0;
}


Measured memory_bytes: 21760
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
#define minn(x,y) x=min(x,y)
#define maxx(x,y) x=max(x,y)
using namespace std;
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d%d",&x,&y);
	printf("%d",max(max(x+y,x-y),x*y));
}


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

int main()
{
	char str[16];
	while(cin >> str)
	{
		int x,y,t,line[8]={0};
		for(int i=0; i<9; i++)
		{
			switch(str[i])
			{
				case 'o': t=+1; break;
				case 'x': t=-1; break;
				case 's': t= 0; break;
			}

			line[i/3] += t;
			line[i%3+3] += t;
			
			if(i/3==i%3)   line[6]+=t;
			if(i/3+i%3==2) line[7]+=t;
		}

		char c='d';
		for(int i=0; i<8; i++)
		{
			if(line[i]==+3){c='o'; break;}
			if(line[i]==-3){c='x'; break;}
		}
		cout << c << endl;
	}	
}

Measured memory_bytes: 0
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

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


Measured memory_bytes: 256
class PrimeChecker:

    def __init__(self):
        self.primes = [2,3]

    def isPrime(self, n):
        if n in self.primes:
            return True
        else:
            for i in self.primes:
                if n % i == 0:
                    return False

        i = 5
        w = 2

        while i * i <= n:
            if n % i == 0:
                return False

            i += w
            w = 6 - w

        self.primes.append(n)

        return True

primeChecker = PrimeChecker()
count = 0
N = int(input())
for _ in range(N):
    if primeChecker.isPrime((int(input()))):
        count += 1
print(count)
        


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

int main()
{
    int N, X, D[1000000] = {0}, i;
    cin >> N >> X;
    D[0] = 0;
    D[1] = 0;
    for (i = 2; i <= N + 1; i++)
    {
        int L;
        cin >> L;
        D[i] = D[i - 1] + L;
        if (D[i] > X)
        {
            break;
        }
    }

    cout << i - 1;
    return 0;
}

Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

    public static void main(String [] args) {
        final Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        for (int i = 0; i < N; ++i) {
            int num = scanner.nextInt();
            if (num % 2 == 1) {
                System.out.println("first");
                return;
            }
        }

        System.out.println("second");

    }
}


Measured memory_bytes: 49792
#include<stdio.h>
int main(void)
{
    int a1,a2,a3,a4;
    int b1,b2,b3,b4;
    int a[4],b[4];
    int i,j;
    int count1,count2;
    while(scanf("%d %d %d %d %d %d %d %d",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4) != EOF){
        a[0] = a1;
        a[1] = a2;
        a[2] = a3;
        a[3] = a4;
        b[0] = b1;
        b[1] = b2;
        b[2] = b3;
        b[3] = b4;
        count1 = 0;
        count2 = 0;
        for(i = 0; i < 4; i++){
            for(j = 0; j < 4; j++){
                if(i == j && a[i] == b[j]) count1++;
                else if(a[i] == b[j]) count2++;
            }
        }
        printf("%d %d\n",count1,count2);
    }

    return 0;
}

Measured memory_bytes: 596
#include <iostream>

constexpr int INF = 0x7fffffff;

int main(void){
    int n; scanf("%d", &n);
    int max_ele = -INF, min_ele = INF; long long int sum = 0;
    while(n--){
        int p; scanf("%d", &p);
        if(max_ele < p) max_ele = p;
        if(min_ele > p) min_ele = p;
        sum += p;
    }
    printf("%d %d %lld\n", min_ele, max_ele, sum);
    return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define N 200005
#define pd push_back
#define ls x<<1,l,mid
#define rs x<<1|1,mid+1,r
using namespace std;
int n,m;
vector<int>s[N];
int t[N<<2],f[N<<2];
void build(int x,int l,int r)
{
    if(l==r){t[x]=l;return ;}
    int mid=(l+r)>>1;build(ls);build(rs);
    t[x]=max(t[x<<1],t[x<<1|1]);
}
void add(int x,int l,int r,int ll,int rr)
{
    if(l>=ll&&r<=rr)
    {
        t[x]++;f[x]++;return ;
    }
    int mid=(l+r)>>1;
    if(ll<=mid)add(ls,ll,rr);
    if(rr>mid)add(rs,ll,rr);
    t[x]=f[x]+max(t[x<<1],t[x<<1|1]);
}
int qur(int x,int l,int r,int ll,int rr)
{
    if(l>=ll&&r<=rr)return t[x];
    int mid=(l+r)>>1;
    if(ll>mid)return f[x]+qur(rs,ll,rr);
    if(rr<=mid)return f[x]+qur(ls,ll,rr);
    return f[x]+max(qur(ls,ll,rr),qur(rs,ll,rr));
}
int main()
{
    scanf("%d%d",&n,&m);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int t1,t2;scanf("%d%d",&t1,&t2);s[t1].pd(t2);
    }
    build(1,0,m+1);
    for(int i=0;i<=m;i++)
    {
        for(auto j:s[i])add(1,0,m+1,0,j);
        ans=max(ans,qur(1,0,m+1,i+1,m+1)-i-m-1);
    }
    printf("%d\n",max(n-m,ans));
    return 0;
}


Measured memory_bytes: 14720
#include <iostream>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <algorithm>
#include <string>

using namespace std;


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


Measured memory_bytes: 3568
import std.stdio, std.algorithm, std.conv, std.array, std.string;

int[9] COLOURS;

void main()
{
    readln;
    auto as = readln.split.to!(int[]);

    foreach (a; as) {
        auto idx = a / 400;
        if (idx > 8) idx = 8;
        COLOURS[idx] += 1;
    }

    auto min = COLOURS[0..8].count!"a != 0";
    auto max = min + COLOURS[8];
    if (min == 0) min = 1;

    writefln("%d %d", min, max);
}

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

int main() {
  int N,K;
  cin >> N >> K;
  int count = 0;
  
  vector<int>h(N);
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
  }

  for (int i = 0; i < N; i++) {
    if (h.at(i) >= K){
      count++;
    }
  }
  cout << count << endl;
}
  
    
  

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> grh(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    grh[--a].push_back(--b);
    grh[b].push_back(a);
  }
  set<int> st;
  vector<int> ret;
  int crr = 0;
  ret.push_back(crr);
  st.insert(crr);
  for (int t = 0; t < 2; t++, crr = 0) {
    for (bool flg = false; ; flg = false){
      for (int nxt : grh[crr]) if (st.insert(nxt).second) {
          if (t == 0) ret.push_back(nxt);
          if (t == 1) ret.insert(ret.begin(), nxt);
          crr = nxt;
          flg = true;
          break;
      }
      if (!flg) break;
    }
  }
  cout << ret.size() << endl;
  for (auto it = ret.begin(); it != ret.end(); it++) {
    cout << *it + 1 << (next(it) == ret.end() ? '\n' : ' ');
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 11384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        
        int total = 0;
        for(int i = 1;i <= N;i++){
            if(i <= K){
                total += X;
            }else{
                total += Y;
            }
        }
        System.out.println(total);
    }
}


Measured memory_bytes: 22996
macro_rules! hashmap {
    ($( $key: expr => $val: expr ),*) => {{
         let mut map = ::std::collections::HashMap::new();
         $( map.insert($key, $val); )*
         map
    }}
}

fn main() {
    let acgt = hashmap!('A' => 0, 'C' => 0, 'G' => 0, 'T' => 0);
    let s: Vec<char> = read::<String>().chars().collect();

    let mut max_len = 0;
    let mut count = 0;
    for c in s.iter() {
        match acgt.get(c) {
            Some(_) => {
                count += 1;
            }
            None => {
                if max_len < count {
                    max_len = count;
                }
                count = 0;
            }
        }
    }
    if max_len < count {
        max_len = count;
    }

    println!("{}", max_len);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 2180
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 310000
using namespace std;

int read_p,read_ca;
inline int read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
int n,m,q,num=0,x,y,C[MN],l[MN];
bool B[MN][11];
struct op{int v,d,c;}O[MN];
struct na{int y,ne;}b[MN<<1];
inline void in(int x,int y){b[++num].y=y;b[num].ne=l[x];l[x]=num;}
long long MMH=0;
void dfs(int x,int d,int c){
	if (B[x][d]) return;
	if (!C[x]) C[x]=c;
	for (int i=0;i<=d;i++) B[x][d]=1;
	if (d==0) return;
	for (int i=l[x],j=0;i;i=b[i].ne)
	dfs(b[i].y,d-1,c);
}
int main(){
	register int i;
	n=read();m=read();
	memset(C,0,sizeof(C));
	for (i=1;i<=m;i++) x=read(),y=read(),in(x,y),in(y,x);
	q=read();
	for (i=1;i<=q;i++) O[i].v=read(),O[i].d=read(),O[i].c=read();
	for (i=q;i;i--) dfs(O[i].v,O[i].d,O[i].c);
	for (i=1;i<=n;i++) printf("%d\n",C[i]);
	return 0;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define int long long
#define double long double
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

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

const int MOD = 1e9 + 7;
const double EPS = 1e-9;

bool can(int a, int b, int k) {
    if (b % 2) {
        b--;
    }
    if (k % 2) {
        return a + b >= k && a > 0;
    } else {
        return a + b >= k;
    }
}

int n, k;
vector<int> arr;
vector<double> pa;
vector<double> pb;
vector<int> ra;
vector<int> rb;

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

    cin >> n >> k;
    arr.resize(n);
    int a = 0;
    int b = 0;
    int z = 0;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        if (arr[i] > 0) {
            a++;
        } else if (arr[i] < 0) {
            b++;
        } else {
            z++;
        }
    }
    sort(arr.begin(), arr.end(), comp);
    if (can(a, b, k)) {
        pa.push_back(0);
        pb.push_back(0);
        ra.push_back(1);
        rb.push_back(1);
        for (int x : arr) {
            if (x > 0) {
               double xy = log(x);
                pa.push_back(pa.back() + xy);
                ra.push_back((ra.back() * x) % MOD);
            } else if (x < 0) {
              double xy = log(-x);
                pb.push_back(pb.back() + xy);
                rb.push_back((rb.back() * -x) % MOD);
            }
        }
        double fin = -1;
        int ans = INT_MIN;
        for (int i = 0; i <= k; i += 2) {
            if (i < pb.size() && k - i < pa.size()) {
                if (pb[i] + pa[k - i] > fin) {
                    fin = pb[i] + pa[k - i];
                    ans = (rb[i] * ra[k - i]) % MOD;
                }
            }
        }
        cout << ans << '\n';
    } else if (z > 0) {
        cout << 0 << '\n';
    } else {
        int res = 1;
        for (int i = n - 1; i >= n - k; i--) {
            res = (((res * arr[i]) % MOD) + MOD) % MOD;
        }
        cout << res << '\n';
    }

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 11756
package main

import (
	"fmt"
	"sort"
)

type Num struct {
	Key   int
	Value int
}
type Nums []Num

func (n Nums) Len() int {
	return len(n)
}

func (n Nums) Less(i, j int) bool {
	return n[i].Value > n[j].Value
}

func (n Nums) Swap(i, j int) {
	n[i], n[j] = n[j], n[i]
}

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := range arr {
		fmt.Scan(&arr[i])
	}
	even := map[int]int{}
	odd := map[int]int{}
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			even[arr[i]]++
		} else {
			odd[arr[i]]++
		}
	}
	var evens Nums
	for k, v := range even {
		evens = append(evens, Num{k, v})
	}
	sort.Sort(Nums(evens))
	if len(evens) < 2 {
		evens = append(evens, Num{})
	}
	var odds Nums
	for k, v := range odd {
		odds = append(odds, Num{k, v})
	}
	sort.Sort(Nums(odds))
	if len(odds) < 2 {
		odds = append(odds, Num{})
	}
	r := 0
	om := 0
	for i := 0; i < len(odds); i++ {
		if odds[i].Key != evens[0].Key {
			om = odds[i].Value
			break
		}
	}
	em := 0
	for i := 0; i < len(evens); i++ {
		if evens[i].Key != odds[0].Key {
			em = evens[i].Value
			break
		}
	}
	l := n / 2
	if evens[0].Value+om >= odds[0].Value+em {
		r = (l - evens[0].Value) + (l - om)
	} else {
		r = (l - odds[0].Value) + (l - em)
	}
	fmt.Println(r)
}

Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,sum[202][202];
int f[202][202][202][17];
char s[303][303];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		sum[i][j]=sum[i-1][j]+(s[i][j]=='.');
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			int ma=n;
			for(int k=j;k<=m;k++)
			{
				while(ma>=i&&sum[ma][k]-sum[i-1][k]!=(ma-i+1)*(s[i][j]=='.'))
				ma--;
				f[i][j][k][0]=ma;
				//cout<<i<<" "<<j<<" "<<k<<" "<<f[i][j][k][3]<<endl;
			}
		}
	for(int k=1;;k++)
	{
		if(f[1][1][m][k-1]==n) return printf("%d\n",k-1),0;
		for(int ln=1;ln<=m;ln++)
			for(int i=1;i<=n;i++)
				for(int l=1,r=ln;r<=m;l++,r++)
				{
					if(f[i][l][r][k-1]==n) f[i][l][r][k]=n;
					else
					{
						f[i][l][r][k]=f[f[i][l][r][k-1]+1][l][r][k-1];
						if(f[i][l][r][k]<n)
						{
							int L=l,R=r-1,ans=0;
							while(L<=R)
							{
								int mid=(L+R)/2;
								ans=max(ans,min(f[i][l][mid][k-1],f[i][mid+1][r][k-1]));
								if(f[i][l][mid][k-1]<f[i][mid+1][r][k-1]) R=mid-1;
								else L=mid+1;
							}
							//cout<<i<<" "<<l<<" "<<r<<" "<<k<<" "<<ans<<endl;
							f[i][l][r][k]=max(f[i][l][r][k],ans);
						}
					}
				//	if(f[i][l][r][k]==n) cout<<i<<" "<<l<<" "<<r<<" "<<k<<endl;
				}
	}
	return 0;
}

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

struct Dice{
    int s[6];
    void roll(char c){
        int now;
        int a;
      
        if(c == 'W'){
            a = s[0];
            s[0] = s[2];
            s[2] = s[5];
            s[5] = s[3];
            s[3] = a;
            
        }else if(c == 'S'){
            a = s[0];
            s[0] = s[4];
            s[4] = s[5];
            s[5] = s[1];
            s[1] = a;
        }else if(c == 'E'){
            a = s[0];
            s[0] = s[3];
            s[3] = s[5];
            s[5] = s[2];
            s[2] = a;
        }else if(c == 'N'){
            a = s[0];
            s[0] = s[1];
            s[1] = s[5];
            s[5] = s[4];
            s[4] = a;
        }
    }
    int top(){
        return s[0];
    }
};
int main(){
    Dice d;
    int front,up,right;
    int q;
    for(int i=0;i<6;i++) cin >> d.s[i];
    cin >> q;
    for(int i=0;i<q;i++) {
        cin >> up >> front;
        if((up == d.s[4] && front == d.s[3]) || (up == d.s[3] && front == d.s[1]) ||(up == d.s[1] && front ==d.s[2]) || (up == d.s[2] && front == d.s[4])){
            right = d.s[0];
        }else if((up == d.s[3] && front == d.s[5]) || (up == d.s[5] && front == d.s[2]) || (up == d.s[2] && front == d.s[0]) ||(up == d.s[0] && front == d.s[3])){
            right = d.s[1];
        }else if((up == d.s[4] && front == d.s[0]) || (up == d.s[0] && front == d.s[1]) || (up == d.s[1] && front == d.s[5]) || (up == d.s[5] && front == d.s[4])){
            right = d.s[2];
        }else if((up == d.s[1] && front == d.s[0]) || (up == d.s[0] && front == d.s[4]) || (up == d.s[4] && front == d.s[5]) || (up == d.s[5] && front == d.s[1])){
            right = d.s[3];
        }else if((up == d.s[0] && front == d.s[2]) || (up == d.s[2] && front == d.s[5]) || (up == d.s[5] && front == d.s[3]) || (up == d.s[3] && front == d.s[0])){
            right = d.s[4];
        }else if((up == d.s[2] && front == d.s[1]) || (up == d.s[1] && front == d.s[3]) || (up == d.s[3] && front == d.s[4]) || (up == d.s[4] && front == d.s[2])){
            right = d.s[5];
        } 
        printf("%d\n",right);
    }
    return 0;
}



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

bool isp(int i) {
	for (int j = 2; j * j <= i; ++j) {
		if (i % j == 0) return false;
	}
	return true;
}	

int main() {
	int x;
	scanf("%d", &x);
	for (int i = x; ; ++i) {
		if (isp(i)) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 256
import collections
a=int(input())
l=[]
c=0
for x in range(a):
    l.append(input())
if len(set(l))!=a:
    print("No")
else:
    k=l.pop(0)[-1]
    for x in l:
        if k==x[0]:
            k=x[-1]
            c+=1
    if c+1==a:
        print("Yes")
    else:
        print("No")


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

typedef long long ll;

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

    int ans=1e8;
    for(int i=0; i<s.size()-t.size()+1; i++){
        int cnt = 0;
        for(int j=0; j<t.size(); j++){
            //cout<<s[i+j]<<" "<<t[j]<<endl;
            if(s[i+j] != t[j]){
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3624
N = int(input())
K = int(input())

min = float('inf')

def dfs(n, total):
    global N,K,min

    if n==N:
        if min>total:
            min = total
        return

    dfs(n+1, total*2)
    dfs(n+1, total+K)

dfs(0, 1)#n回目の操作で合計がtotal
print(min)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

using namespace std;
 
typedef long long int ll;

const ll INF=(ll)1e18;

#define MAX 100000

int s[MAX+1];

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

    REP(i,MAX+1)s[i]=0;

    REP(i,N){
        int a;
        cin >> a;

        s[max(0,a-1)] += 1;
        s[min(MAX,a+2)] -= 1;
    }
    REP(i,MAX)s[i+1] += s[i];

    int ans = 0;

    REP(i,MAX+1)ans = max(ans, s[i]);

    cout << ans << endl;
}

Measured memory_bytes: 640
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
n,k=NM()
l=L()
dp=[]
from itertools import accumulate
for _ in range(min(100,k)):
    tl,l=l,[0]*(n+1)
    for i,j in enumerate(tl):
        l[max(0,i-j)]+=1
        l[min(n,i+j+1)]-=1
    l=list(accumulate(l))
print(" ".join(map(str,l[:n])))

Measured memory_bytes: 240616
#include<stdio.h>
#define prinf printf

void swap(int *x,int *y){
  int a;
  a=*x;
  *x=*y;
  *y=a;
}

int main(){
  int n,a[100],d;
  int i,j,k;
  int min=0,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);

  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++)
      if(a[j]<a[min])
	min=j;
    if(i!=min){
      swap(&a[i],&a[min]);
      count++;
    }
  }

  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i<n-1)
      printf(" ");
  }
  printf("\n%d\n",count);

  return 0;
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define ll long long
 
const int INF = 1e8;
typedef pair<int,int>P;
int w,h;
int s[1001][1001];
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
int ans = 0;
queue<P> que;

int bfs(){
  while(que.size()){
    P p = que.front();que.pop();
    for(int i = 0;i<4;i++){
      int nx = p.first + dx[i];int ny = p.second + dy[i];
      if(nx >= 0 and nx < w and ny >= 0 and ny < h and s[nx][ny] == INF){
        que.push(P(nx,ny));
        s[nx][ny] = s[p.first][p.second] + 1;
        ans = max(ans,s[nx][ny]);
      }
    }
  }
  return ans;
}
 
int main(void){
  cin >> h >> w;cin.ignore();
  for(int i = 0;i<w;i++)for(int j = 0;j<h;j++) s[i][j] = INF;
  for(int i = 0;i<h;i++){
    string st;getline(cin,st);
    for(int j = 0;j<w;j++){
      if(st.at(j) == '#')   {que.push(P(j,i));s[j][i] = 0;}
    }
  }
  //int ans = 0;for(int i = 0;i<w;i++)for(int j = 0;j<h;j++) ans = max(ans,s[i][j]);
  cout << bfs() << endl;
  //for(int i = 0;i<h;i++) {for(int j= 0;j<w;j++){cout << s[j][i] << " ";}cout << endl;}
}

Measured memory_bytes: 12304
#include <iostream>
#include <stdio.h>

using namespace std;

bool check(double x1, double y1, double x2, double y2, double x3, double y3);

int main(void){
  double xa,ya,xb,yb,xc,yc,xd,yd;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF){
    if(check(xa,ya,xb,yb,xc,yc) && check(xb,yb,xc,yc,xd,yd) && check(xc,yc,xd,yd,xa,ya) && check(xd,yd,xa,ya,xb,yb)){
      cout<<"YES"<<endl;
    }
    else if(!check(xa,ya,xb,yb,xc,yc) && !check(xb,yb,xc,yc,xd,yd) && !check(xc,yc,xd,yd,xa,ya) && !check(xd,yd,xa,ya,xb,yb)){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  }
}

bool check(double x1, double y1, double x2, double y2, double x3, double y3){
  double z;
  z=(x1-x2)*(y3-y2)-(x3-x2)*(y1-y2);
  if(z>0){
    return true;
  }
  else{
    return false;
  }
}



Measured memory_bytes: 3224
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>

using namespace std;

int main(){
	int rk=0, sk=0, len=0;
	char in;
	bool check=false;
	vector<char> st;
	st.push_back(' ');
	while(true){
		scanf("%c", &in);
		if( in == '\n' ) continue;
		if( in == '.' && len == 0 ) break;
		len++;
		if( in == '(' ){ rk++; st.push_back('('); }
		if( in == '[' ){ sk++; st.push_back('['); }
		if( in == ')' ){
			if( --rk < 0 || st.empty() || st.back() != '(' ){
				check=true;
				st.push_back(' ');
			}
			st.pop_back();
		}
		if( in == ']' ){
			if( --sk < 0 || st.empty() || st.back() != '[' ){
				check=true;
				st.push_back(' ');
			}
			st.pop_back();
		}
		if( in == '.' ){
			if( rk != 0 || sk != 0 )
				check = true;
			cout << (check?"no":"yes") << endl;
			rk = 0;
			sk = 0;
			len = 0;
			check = false;
			st.clear();
			st.push_back(' ');
		//	while(st.empty()) st.pop();
		//	st.push(' ');
		}
	}
	return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<string>
using namespace std;
int main() {
  string flg ="true";
    int N;
    cin >> N;
    int A[210];
    int count = -1;

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

while(true){
  ++count;
    for (int i = 0; i < N; i++)
    {
        if (A[i] % 2 == 1) flg ="false";
        else {A[i] = A[i] / 2;  }
    }
        
  if(flg =="false") break;
}

  
    cout << count << endl;


}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int m,f,r;
    while(1){
        scanf("%d %d %d",&m,&f,&r);
        if(m==-1 && f==-1 && r==-1){
            break;
        }else if(m==-1 ||f==-1){
            printf("F\n");
        }else if(m+f>=80){
            printf("A\n");
        }else if(m+f>=65 && m+f<80){
            printf("B\n");
        }else if(m+f>=50 && m+f<65){
            printf("C\n");
        }else if(m+f>=30 && m+f<50){
            if(r>=50){
                printf("C\n");
            }else{
                printf("D\n");
            }
        }else if(m+f<30){
            printf("F\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2052
N = int(input())
ans = 0

def make_div1(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i-1)
            if i != n // i:
                divisors.append(n//i-1)

    return divisors

if N > 1:
	divisors = make_div1(N)
	for i in divisors[1:]:
		if N // i == (N % i):
			ans += i
	print(ans)
else:
	print(0)

Measured memory_bytes: 3316