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

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

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.precision(10);

	int N, M;
	cin>>N>>M;
	int a, b;
	vector<int> v(N);
	for(int i=0; i<M; i++){
		cin>>a>>b;
		v[a-1]++;
		v[b-1]++;
	}

	for(int i=0; i<N; i++){
		if(v[i]%2!=0){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;

	return 0;
}



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

using namespace std;

int main(){
    char b; cin>>b;
    if (b == 'A') cout<<"T";
    else if (b == 'C') cout<<"G";
    else if (b == 'G') cout<<"C";
    else if (b == 'T') cout<<"A";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;



int main(int argc, char *argv[])
{
	int p, q, r;

	//input
	cin >> p >> q >> r;



	//calc
	int sum = p + q + r;
	int ans = sum - max(max(p, q), r);


	//ans
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  int a,b;
  cin>>a>>b;
  int p=3*a+b;
  cout<<p/2<<endl;
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cmath>
#include<utility>
using namespace std;
int main(){
    long long n,p,m,ans=1;
    vector<pair<long long,long> >so;
    scanf("%lld %lld",&n,&p);
    if(n==1){
        printf("%lld\n",p);
        return 0;
    }
    m=sqrt(p);

    for(long long i=2;i<m;i++){
        if(p%i==0){
            so.push_back(make_pair(i,0));
        }
        while(p%i==0){
            so[so.size()-1].second++;
            p/=i;
        }
    }
    for(int i=0;i<so.size();i++){
        if(so[i].second>=n){
            for(long long j=0;j<so[i].second/n;j++){
                ans*=so[i].first;
            }
        }
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(char i='a';i<='z';i++)
    {
        if((count(s.begin(),s.end(),i)==0))
           {
           cout << i << endl;
           return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

int main() {
    ll h, w; cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << "\n";
        return 0;
    }
    cout << (((h * w) % 2) ? ((h * w) / 2 + 1) : ((h * w) / 2)) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

#define eps 1e-8
#define mod 1000000007

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
ll power_mod(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
ll power(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, mod - 2);
}

#define MAXFAC 100010

ll fac[MAXFAC];

void initFac() {
    fac[0] = 1;
    for (int i = 1; i < MAXFAC; ++i) {
        fac[i] = i * fac[i - 1] % mod;
    }
}

ll Combine(ll a, ll b) {
    return (fac[a] * inv(fac[b]) % mod) * inv(fac[a - b]) % mod;
}

/******************************** template ********************************/
#define MAXN 100010

int main() {
    int n, a;
    cin >> n;
    int cnt1, cnt4;
    cnt1 = cnt4 = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a);
        if (a % 2) {
            ++cnt1;
        } else if (a % 4 == 0) {
            ++cnt4;
        }
    }

    cout << (cnt1 <= cnt4 || (cnt1 == cnt4 + 1 && cnt1 + cnt4 == n) ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[210];
int main(){
	int n,e=0;
	cin>>n;
	for(int i=1;i<=2*n;i++)
		cin>>a[i];
	sort(a+1,a+2*n+1);
	for(int i=1;i<=2*n;i+=2)
		e+=a[i];
	cout<<e<<'\n';
	return 0;
}

Measured memory_bytes: 256
# AGC017A

def f(n, p, a):
    odd = sum(i % 2 for i in a)
    if odd == 0:
        if p == 0:
            return 2**n
        elif p == 1:
            return 0
    else:
        return 2**(n-1)
        
n, p = map(int, input().split())
a = list(map(int, input().split()))
print(f(n, p, a))


Measured memory_bytes: 9104
import java.util.*;

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

        int ans = Integer.MAX_VALUE;
        for(int i = 0; i <= n; i++){
            ans = Math.min(ans, calc(i, 6) + calc(n - i, 9));
        }
        System.out.println(ans);
    }
    public static int calc (int n, int p)
    {
        if(n == 0){
            return 0;
        }
        int j = 1;
        while(j * p <= n){
            j *= p;
        }
        return 1 + calc(n - j, p);
    }
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    cout << n*(n-1)/2 << endl;
    return 0;
}

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

int main() {
  long long N, x, num = 0;
  std::vector<long long> a;

  std::cin >> N;
  std::cin >> x;
  for(int i = 0; i < N; i++) {
    long long tmp;
    std::cin >> tmp;
    a.push_back(tmp);
  }

  for(int i = 0; i < N - 1; i++) {
    if(a[i] + a[i + 1] > x) {
      num += a[i] + a[i + 1] - x;
      if(a[i] + a[i + 1] - x <= a[i + 1])
        a[i + 1] -= a[i] + a[i + 1] - x;
      else
        a[i + 1] = 0;
    }
  }

  std::cout << num << std::endl;
}


Measured memory_bytes: 1400
package main

import "fmt"

func main() {
	var H, W int
	fmt.Scan(&H, &W)
	ass := make([][]int, H)
	for j := range ass {
		ass[j] = make([]int, W)
		for i := range ass[j] {
			fmt.Scan(&ass[j][i])
		}
	}

	var ans [][4]int

	for j, as := range ass {
		for i := 0; i < W-1; i++ {
			if as[i]%2 == 1 {
				as[i]--
				as[i+1]++
				ans = append(ans, [4]int{j + 1, i + 1, j + 1, i + 2})
			}
		}
	}
	for j := 0; j < H-1; j++ {
		if ass[j][W-1]%2 == 1 {
			ass[j][W-1]--
			ass[j+1][W-1]++
			ans = append(ans, [4]int{j + 1, W, j + 2, W})
		}
	}

	fmt.Println(len(ans))
	for _, a := range ans {
		fmt.Println(a[0], a[1], a[2], a[3])
	}
}


Measured memory_bytes: 23424
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long 
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
const ll mod=998244353;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> data_struct;

int main()
{
	ll s,w;
	cin>>s>>w;
	if(w>=s)
		cout<<"unsafe";
	else
		cout<<"safe";
}

Measured memory_bytes: 3632
n = int(input())
A = [int(input()) for i in range(n)]
max = A[1]-A[0]
min = A[0]

for i in range(1,n):
    if(max < A[i]-min):
        max = A[i]-min
    if(min > A[i]):
        min = A[i]

print(max)


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

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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int h,w,k;
    cin >> h >> w >> k;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    --a,--b,--c,--d;
    int l[h][w];
    memset(l,-1,sizeof l);
    char g[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
            cin >> g[i][j];
    }
    queue <pair <int,int> > q;
    q.push({a,b}),l[a][b]=0;
    while(!q.empty()){
        a=q.front().first,b=q.front().second;
        q.pop();
        for(int i=0;i<4;i++){
            for(int j=1;j<=k;j++){
                int x=a+j*dx[i],y=b+j*dy[i];
                if(x<0 or x>=h or y<0 or y>=w or g[x][y]=='@')
                    break;
                if(l[x][y]==-1){
                    q.push({x,y});
                    l[x][y]=l[a][b]+1;
                }
                if(l[x][y]<l[a][b]+1)
                    break;
                l[x][y]=min(l[x][y],l[a][b]+1);
            }
        }
    }
    cout << l[c][d] ;
}


Measured memory_bytes: 9052
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
vector<int> v;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);
	sort(v.begin(),v.end());
	if(v[0]+v[1]==v[2]){
		printf("Yes");
	}else printf("No");
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

//つねに10億7などの剰余をとる構造体
//参考: https://www.youtube.com/watch?v=L8grWxBlIZ4&t=9858
//参考: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
int mod  = MODA;
struct modint {
	ll x;
	modint (ll x):x(x%mod){}
	modint& operator+=(const modint a){
		(x += a.x ) %= mod;
		return *this;
	}
	modint& operator-=(const modint a){
		(x -= a.x ) %= mod;
		if (x < 0) x += mod;
		return *this;
	}
	modint& operator*=(const modint a){
		(x *= a.x ) %= mod;
		return *this;
	}
	modint& operator/=(modint a){
		ll exp = mod - 2;
		while(exp > 0){
			if(exp & 1) *this *= a.x;
			a *= a.x;
			exp >>= 1;
		}
		return *this;
	}
	modint operator+(const modint a) const{
		modint res(*this);
		return res+=a;
	}
	modint operator-(const modint a) const{
		modint res(*this);
		return res-=a;
	}
	modint operator*(const modint a) const{
		modint res(*this);
		return res*=a;
	}
	modint operator/(const modint a) const{
		modint res(*this);
		return res/=a;
	}
};
modint modpow(modint x, ll n){
	modint res=1;
	while(n > 0){
		if(n & 1) res = res * x.x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

//gcdをユークリッド互除法で求める。O(log n)
ll euclid(ll x, ll y){
    if(min(x, y) ==  0) return max(x, y);
    else return euclid(max(x, y)% min(x, y) , min(x, y));
}
//

int main() {
	modint ans = 1;
	ll tmp = 0;
	modint solo = 0;
	int n; 
	cin >> n;
	ll a, b;
	map<pair<ll, ll>, ll > fi, se;
	REP(i, n){
		cin >> a >> b;
		if(a == 0 && b == 0){
			solo += 1;
			continue;
		}
		ll gc = euclid(abs(a), abs(b) );
		a /= gc;
		b /= gc;
		if(b < 0){
			a *= -1;
			b *= -1;
		}
		else if(b == 0) a = 1;
		else if(a == 0) b = 1; 
		if(a > 0){
			fi[make_pair(a, b)]++;
			se[make_pair(-b,a)];
		}
		else{
			se[make_pair(a, b)]++;
			fi[make_pair(b,-a)];
		}
	}
	pair<ll, ll> now;
	modint p = 1;
	for(auto it = fi.begin(); it != fi.end(); it++){
		now = it->first;
		//cout << now.first << " " << now.second << " " 
		//	<< fi[now] << " " << se[make_pair(-now.second, now.first)] << " " << ans.x << endl;
		p = modpow((ll)2, fi[now]) - 1;
		p += modpow((ll)2, se[make_pair(-now.second, now.first)]) - 1;
		p += 1;
		ans *= p;
	}
	ans += solo;
	ans -= 1;
	cout << ans.x << endl;
}

Measured memory_bytes: 28496
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()

print(1000*(-(-N//1000))-N)


Measured memory_bytes: 10316
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
 int a , b , x;
 cin >> a >> b >> x;
 if(a <= x && (a + b) >= x)cout << "YES" << endl;
 else cout << "NO" << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int count(const string &S) {
    int res = 0;
    for (int i = 0; i+1 < S.size(); ++i) {
        if (S[i] == 'A' && S[i+1] == 'B') ++res;
    }
    return res;
}

int N;
vector<string> S;

long long solve() {
    long long res = 0;
    for (int i = 0; i < N; ++i) res += count(S[i]);

    int a = 0, b = 0, c = 0;
    for (int i = 0; i < N; ++i) {
        if (S[i][0] == 'B' && S[i].back() == 'A') ++a;
        else if (S[i].back() == 'A') ++b;
        else if (S[i][0] == 'B') ++c;
    }
    long long add = 0;
    if (b + c == 0) add = max(0, a-1);
    else add = a + min(b, c);

    res += add;
    return res;
}

int main() {
    while (cin >> N) {
        S.resize(N);
        for (int i = 0; i < N; ++i) cin >> S[i];
        cout << solve() << endl;
    }
}

Measured memory_bytes: 768
#include<vector>
#include<iostream>
using namespace std;
#define df 0
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;


li pow(li a,li k){
  li s=1;
  while(k){
    if(k%2){
      (s*=a)%=MOD;
    }
    (a*=a)%=MOD;
    k/=2;
  }
  return s;
}
li inv(li a){
  return pow(a,MOD-2);
}

li fact(li a){
  li s=1;
  rep(i,a){
    (s*=i+1)%=MOD;
  }
  return s;
}

li nCr(li n,li r){
  li temp=fact(n);
  (temp*=inv(fact(r)))%=MOD;
  return (temp*inv(fact(n-r)))%MOD;
}

int main(){
  if(df) printf("*debug mode*\n");
  int x,y; cin >>x >>y;
  li a=2*y-x,b=2*x-y;
  if(a%3 or b%3){
    cout << 0;
    return 0;
  }
  a/=3; b/=3;
  
  if(a<0 or b<0){
    cout << 0;
    return 0;
  }
  if(df){
    rep(i,10){
      rep(j,i+1){
	printf("%ld ",nCr(i,j));
      }
      printf("\n");
    }
  }
  cout << nCr(a+b,a);
  
}

/// confirm df==0 ///


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define pb push_back
struct P
{
	int a,b,c,d;
	
}k[55];
int ans,m,q,n;
int A[15];
void dfs(int dep,int mx)
{
	if(dep==n+1)
	{
		int p=0;
		rep(i,1,q)
		{
			if(A[k[i].b]-A[k[i].a]==k[i].c)
			{
				p+=k[i].d;
			}
		}
		ans=max(ans,p);
		return ;
	}
	rep(i,mx,m)
	{
		A[dep]=i;
		dfs(dep+1,i);
	}
}
int main(int argc, char** argv) {
		cin>>n>>m>>q;
	rep(i,1,q)
	{
		int a,b,c,d;
		cin>>k[i].a>>k[i].b>>k[i].c>>k[i].d;
		
	}
	dfs(1,1);
	cout<<ans;
	return 0;
}



Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<cstdlib>
#include<string>
#include<cmath>
using namespace std;

struct Dice{
  int num[6];
  int roll[2][4];
};

int main(){
    vector<int> number(6);
    Dice d1;
    for(int i=0; i<6; i++){
        cin>>d1.num[i];
    }
    cin.ignore();
    string str;
    vector<char> dir;
    getline(cin,str);
    for(int i=0; i<str.size(); i++){
        char c = str[i];
        dir.push_back(c);
    }
    int top=1;
    int n=5,e=3,s=2,w=4;
    for(int i=0; i<dir.size(); i++){
        int tmp=top;
        if(dir[i]=='N'){
            n=top;
            top=s;
            s=7-n;
        }else if(dir[i]=='S'){
            s=top;
            top=n;
            n=7-s;
        }else if(dir[i]=='E'){
            e=top;
            top=w;
            w=7-e;
        }else{
            w=top;
            top=e;
            e=7-w;
        }
    }
    cout<<d1.num[top-1]<<endl;
    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define chal ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
    ll x,k,d,p;
    cin>>x>>k>>d;
    if(1){
    p=x/d;
    p=abs(p);
    if(x<0)
        d=-d;
    if(p<=k)
    {
        x-=(p*d);
        k-=p;
    }
    else
    {
        x-=(k*d);
        k-=k;
    }
    k=k%2;
    x-=(k*d);
    cout<<abs(x);
    }

    return 0;
}


Measured memory_bytes: 3672
N = gets.to_i
a = []
a = gets.split.map(&:to_i)
# a = a.sort

# if N==2
#   if a[0]*a[1] > 10**18
#     puts -1
#   else
#     puts a[0]*a[1]
#   end
#   exit
# end

# if N % 2 == 1
#   ans = a[N/2]
# else
#   ans = 1
# end

# (N/2).times do |i|
#   ans = ans * (a[i] * a[N-1-i])
#   if ans == 0
#    puts 0
#    exit
#   end
#   if ans > 10**18
#     puts -1
#     exit
#   end
# end
# puts ans

# aに1個でも0があればかけ算の結果は0確定
a.each do |ai|
  if ai == 0
    puts 0
    exit
  end
end

ans = 1
N.times do |i|
 ans *= a[i]
 if ans > 1e18
  puts -1 
  exit
 end
end

puts ans

Measured memory_bytes: 21552
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};

int main(){
    ll N; cin >> N;
    const ll al = 1e5 + 10;
    map<ll, ll> m;
//    REP(i, al) m[i] = 0;
    REP(i, N){
        ll a; cin >> a; m[a]++;
    }
    
    ll ret = 0;
    REP(i, al - 2){
        ll tmp = m[i] + m[i+1] + m[i+2];
        ret = max(ret, tmp);
    }
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll n,z,w;
vl a;

void input(void){
   cin>>n>>z>>w;
   inputv(a,n);
}

void solve(void){
    if(n==1){
        cout<<labs(a[0]-w)<<endl;
    }
    else{
        cout<<max(labs(a[n-1]-w),labs(a[n-1]-a[n-2]))<<endl;
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define PI 3.14159265
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double a,b,x;
    cout.precision(8);// prints x digits after decimal in val
    cin>>a>>b>>x;
    if(x<=a*a*b/2)
        cout<<90-atan(2*x/(a*b*b))* 180.0 / PI;
    else{
        x = a*a*b-x;
        cout<<90-atan(a*a*a/(2*x))* 180.0 / PI;
    }

    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

int n;
ll t, a[100010];

int main()
{
	cin >> n >> t;
	rep(i, n) cin >> a[i];
	//今迄のa[i]の最小, B=a[i]-min[a1,.,ai-1]の最大, Bの最大値の個数
	ll mina = inf, maxb = -inf, cnt = 0LL;
	for (int i = 0; i < n; i++) {
		mina = min(mina, a[i]);
		if (a[i] - mina > maxb) {
			cnt = 1LL;
			maxb = a[i] - mina;
		}
		else if (a[i] - mina == maxb) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
	int c1, c5, c10, c50, c100, c500, a;
	scanf("%d %d %d %d %d %d", &c1, &c5, &c10, &c50, &c100, &c500);
	a = c1 + 5 * c5 + 10 * c10 + 50 * c50 + 100 * c100 + 500 * c500;
	if (a >= 1000)
		printf("1\n");
	else
		printf("0\n");
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
long long int arr1[3000][3000];
const long long int m=1e9 + 7;
long long int mult[3000][3000];
long long int mult1[3000][3000];
long long int dp[3000],dp1[3000];
void powe(long long int a,long long int B)
{
   if(a==1) return;
   long long int qwer[B][B];
   for (long long int i = 0; i < B; ++i)
   {
      for (long long int j = 0; j < B; ++j)
      {
        qwer[i][j]=arr1[i][j];
      }
   }
   powe(a/2,B);
   
   memset(mult,0,sizeof(mult));
   for(long long int i = 0; i < B; ++i)
        for(long long int j = 0; j < B; ++j)
            for(long long int k = 0; k < B; ++k)
            {
              long long int jkl=(arr1[i][k]%m * arr1[k][j]%m)%m;
                mult[i][j] = (mult[i][j]%m + jkl%m)%m;
            }
    for (long long int i = 0; i < B; ++i)
   {
      for (long long int j = 0; j < B; ++j)
      {
        arr1[i][j]=mult[i][j];
      }
   }        

    if(a%2==1)
    {
        
        memset(mult1,0,sizeof(mult1));
        for(long long int i = 0; i < B; ++i)
        for(long long int j = 0; j < B; ++j)
            for(long long int k = 0; k < B; ++k)
            {
              long long int jkl=(mult[i][k]%m * qwer[k][j]%m)%m;
                mult1[i][j] = (mult1[i][j]%m + jkl%m)%m;
            }
        for ( long long int i = 0; i < B; ++i)
   {
      for (long long int j = 0; j < B; ++j)
      {
        arr1[i][j]=mult1[i][j];
      }
   }

    }

}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    long long int n, k;
    cin >> n >> k;

    for (long long int i = 0; i < n; ++i)
    {
       for (long long int j = 0; j < n; ++j)
       {
          cin >> arr1[i][j];
       }
    }
    
    
    powe(k,n);

    long long int ans = 0;

    for (long long int i = 0; i < n; ++i)
    {
       for (long long int j = 0; j < n; ++j)
       {
          ans += arr1[i][j];
          ans %= m;
       }
    }

    cout << ans;
   
    return 0;
}


Measured memory_bytes: 144768
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	long long ans=0;
	if(a>=k)
	{
		cout<<k<<endl;
		return 0;
	}
	ans+=a;
	k-=a;
	if(b>=k)
	{
		cout<<ans<<endl;
		return 0;
	}
	k-=b;
	cout<<ans-k<<endl;
	return 0;
} 

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define ms memset
#define FOR(i, a, b) for(int i = a; i <= b; i++)

int main()
{
    int a; cin >> a;
    cout << a + a*a + (a*a)*a << '\n';
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
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 / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, m;
vector<int> v[100001];

int main() {
	cin >> n >> m;
	inc(i, n) {
		int a, b;
		cin >> a >> b;
		v[a].PB(b);
	}
	inc1(i, m) { sort(ALL(v[i])); }
	
	multiset<int> ans;
	dec1(i, m) {
		if(SI(v[i]) == 0) { continue; }
		
		multiset<int> ne;
		while(SI(ans) + SI(ne) < m + 1 - i && SI(v[i]) > 0) {
			ne.insert(v[i].back());
			v[i].pop_back();
		}
		
		while(SI(v[i]) > 0 && SI(ans) > 0 && v[i].back() > * ans.begin()) {
			ne.insert(v[i].back());
			v[i].pop_back();
			ans.erase(ans.begin());
		}
		
		RF(e, ne) { ans.insert(e); }
	}
	
	int sum = 0;
	RF(e, ans) { sum += e; }
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 10112
//package practice;

import java.util.*;

import java.io.*;
import java.math.*;

public class Main {
	
	
	public static void main(String args[]) throws Exception {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		String[] split = s.split("");
		String first = "";
		for (int i = split.length - 1; i >= 0; i--) {
			first += split[i];
		}
		List<String> cool = Arrays.asList(split);
		List<String> temp = cool.subList(0,  ((s.length() - 1) / 2));
		Collections.reverse(temp);
		temp = cool.subList(((s.length() + 3) / 2) - 1, s.length());
		Collections.reverse(temp);
		String check = "";
		for (String x : cool) {
			check += x;
		}
		if (check.equals(s) && s.equals(first)) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	
	
		

		
	}
}




Measured memory_bytes: 21972
from fractions import gcd
a,b,c,d = map(int,input().split())

lcm = c*d // gcd(c,d)

cdiv = b//c - (a-1)//c
ddiv = b//d - (a-1)//d

div = b//lcm -(a-1)//lcm

print(b-a+1 - cdiv - ddiv + div)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> p(4, 0);
  bool flg = true;
  for (int i = 0; i < 3; i++){
    int a, b;
    cin >> a >> b;
    p[a - 1]++;
    p[b - 1]++;
    if (p[a - 1] == 3){
      flg = false;
    }
    if (p[b - 1] == 3){
      flg = false;
    }
  }
  cout << (flg ? "YES" : "NO");
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    var (A, B, C, D) = readLine()!!.split(" ").map{it.toInt()}

    while (true){
        C -= B
        if(C <= 0){
            println("Yes")
            break
        }

        A -= D
        if(A <= 0){
            println("No")
            break
        }


    }
}


Measured memory_bytes: 36260
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n,m;
  cin>>n>>m;
  long long ans=0;
  vector<pair<long,long>> drink(n);
  for(int i=0;i<n;i++){
    long a,b;
    cin>>a>>b;
    drink[i]=make_pair(a,b);
  }
  sort(drink.begin(),drink.end());
  int k=0;
  while(m>0){
    ans+=(drink[k].first)*min(m,drink[k].second);
    m-=drink[k].second;
    k++;
  }
  cout<<ans;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<int>vec(N);
	rep(i, 0, N)cin >> vec[i];
	int mn = vec[0], ans = -INF;
	rep(i, 1, N) {
		chmax(ans, vec[i] - mn);
		chmin(mn, vec[i]);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3624
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem (I) in C++
// MAIN IDEA   : max sum of S(X) + S(S(X)) => 100 so brute force
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 1e5 + 5, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
priority_queue<int> pq;
int a[N] = { };
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	int n;
	cin >> n;
	lp(i,1,n)
	{
		int x;
		cin >> x;
		a[x]++;
	}
	for (int i = 1; i <= N; ++i)
		if (a[i])
			pq.push(a[i]);
	int cnt = 0;
	while (pq.top() != 1) {
		int a = pq.top();
		pq.pop();
		cnt++;
		if (a >= 3)
			pq.push(a - 2);
		else if (a == 2) {
			int b = pq.top();
			pq.pop();
			if (b > 1)
				pq.push(b - 1);
			pq.push(a - 1);
		}
	}
	int ans = 0;
	while (!pq.empty()) {
		ans += pq.top();
		pq.pop();
	}
	f(ans);
	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N;
	cin >> N;
	if(N == 0){
		cout << 0 << endl;
		return 0;
	}
	array<int, 64> a;
	for(int j=0;j<64;j++) a[j] = 0;
	
	ll v = N;
	for(int i=0;i<63;i++){
		a[i] = v % 2;
		if(i % 2 == 1) a[i] *= -1;
		v /= 2;
	}
//for(int j=0;j<64;j++) cout << a[j]; cout << endl;
	
	
	for(int i=0;i<62;i++){
//cout << a[i] << a[i+1] << endl;
		if(a[i] < 0){
			int ad = - a[i] * 2;
			a[i] += ad;
			a[i + 1] += ad / 2;
		}
		if(a[i] >= 2){
			a[i + 1] -= a[i] / 2;
			a[i] %= 2;
		}
	}
	
	vector<int> ans;
	for(int i=0;i<64;i++) ans.push_back(a[i]);
//for(int i=0;i<ans.size();i++) cout << ans[i];cout << endl;

	while(ans[ans.size() - 1] == 0) ans.erase(ans.end() - 1);
	reverse(ans.begin(), ans.end());
	
	for(int i=0;i<ans.size();i++) cout << ans[i];
	cout << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

int main(void){
  int c[3][3];
  rep(i, 3)
    rep(j, 3)
    cin >> c[i][j];
  //入力終了

  //下のように足し算をすると，
  //(a1+a2+a3) + (b1+b2+b3) = C
  //の方程式が3つ現れる
  //Cの値がいずれも等しければ題意を満たす組み合わせがある
  
  int p = c[0][0] + c[1][1] + c[2][2];
  int q = c[0][1] + c[1][2] + c[2][0];
  int r	= c[0][2] + c[1][0] + c[2][1];

  if(p == q && q == r)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<char> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  bool y=false;
  for(int i=0;i<n;i++){
    if(vec.at(i)=='Y') y=true;
  }
  if(y) cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(int(i) for i in input().split())
sa = [0] * (n+1)
num_cnt = {}    
for i in range(n):
    sa[i + 1] = sa[i] + a[i]

for num in sa:
    if num in num_cnt:
        num_cnt[num] += 1
    else:
        num_cnt[num] = 1


res = 0
for cnt in num_cnt.values():
    res += cnt*(cnt-1)//2

print(res)


Measured memory_bytes: 41148
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long

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

	int a, b;
	cin >> a >> b;

	if (a + b == 15) {
		cout << '+' << endl;
		return 0;
	}
	if (a * b == 15) {
		cout << '*' << endl;
		return 0;
	}
	cout << 'x' << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong



vector<bool> IsPrime;


void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

signed main(){
    sieve(55555);
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 0; i * 5 + 1 <= 55555 ; i++){
        if(IsPrime[i * 5 + 1]){
            cout << i * 5 + 1 << " ";
            cnt ++;
            if(cnt ==n) break;
        }
    }
    cout << endl;
}

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

//与えられた整数について2で何回割れるかを求める関数
int div2(int x) {
	int sum=0;
	while (true) {
		if (x % 2 == 0) {
			sum++;
			x /= 2;
		}
		else break;
	}
	return sum;
}

int main() {
	int n, a[10001],s=0;
	cin >> n;
	for (int i = 0;i < n;i++) cin >> a[i];
	for (int i = 0;i < n;i++) {
		s += div2(a[i]);
	}
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc149/tasks/abc149_b
//B - Greedy Takahashi
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
  ll A,B,K; cin>>A>>B>>K;
  ll a=A,b=B;
  a = max(A-K,0LL);
  K -= A;  
  if (K>0) {
    b = max(B-K,0LL);
  }
  cout<<a<<" "<<b<<endl;
  return 0;
}

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

int main(){
  
  int N;
  cin >> N;
  int i =0;
  while(i<N){
    string s;
    cin >> s;
    if (s == "Y"){
      
      break;
    }
    i++;
  }
  if (i==N){
    cout << "Three" <<endl;}
  else{
     cout << "Four" <<endl;
  }
}
 

Measured memory_bytes: 256
A,B,K=map(int,input().split())
if B-A+1-2*K>=0:
    for i in range(A,A+K):
        print(i)
    for i in range(B-K+1,B+1):
        print(i)
else:
    for i in range(A,B+1):
        print(i)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
int a,b,c;
//	cout << "test"<<endl;
//A
//       cin>>a>>b>>c;
// cout<<((b-a)==(c-b)?"YES":"NO")<<endl;
//B
string k,g;
cin>>k;
cin>>g;
for(int i=0;i<k.length();i++)
//cout<<k[i]<<((g.length()==k.length())?(char)g[i]:(char)"");cout<<endl;
{cout<<k[i];if(i<g.length())cout<<g[i];}cout<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
V = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

D = [0] * N
for i in range(N):
  D[i] = V[i] - C[i]

S = 0
for i in range(N):
  if D[i] > 0:
    S += D[i]

print(S)

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define INT_MAX INF
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
int main() {
	int N,M;
	cin>>N>>M;
	bool broken[SIZE]={};
	for(int i=0;i<M;i++){
		int a;
		cin>>a;
		broken[a]=1;
	}
	ll DP[SIZE]={};
	DP[0]=1;
	for(int i=0;i<N;i++){
		if(!broken[i+1])
			DP[i+1]=(DP[i+1]+DP[i])%MOD;
		if(!broken[i+2])
			DP[i+2]=(DP[i+2]+DP[i])%MOD;
	}
	cout<<DP[N]<<endl;
    return 0;
}

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

using namespace std;

typedef unsigned long long int ulli;

int main(){
	int n,k;
	cin >> n >> k;
	if(n == 1){cout << 1;exit(0);}
	if(n == k){n++;}
	cout << ceil(log(n)/ (1.0 *log(k)));
	
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    if(a>b)
        cout<<0<<endl;
    else
    {
        if(n==1)
        {
            if(a==b)
                cout<<1<<endl;
            else
                cout<<0<<endl;
        }
        else
            cout<<(b-a)*(n-2)+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	static int N;
	static int[] H;
	static int[] dp;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		H = new int[N+1];
		dp = new int[N];
		for(int i=0;i<N;i++){
			H[i] = sc.nextInt();
			dp[i] = -1;
		}
		sc.close();
		System.out.println(dfs(0));
	}
	// 今の場所からゴールまでの最小コストを返す
	static int dfs(int pos){
		// オーバーしていた場合は、十分大きいコストを返す
		if(pos>=N) return 99999999;
		// ゴールしていたらこれ以上のコストはかからないので0
		if(pos==N-1) return 0;
		// すでにdfs(pos)の結果を計算済みであればそれを返す
		if(dp[pos]!=-1) return dp[pos];
		// 途中であれば、1つ進む場合と2つ進む場合を比較し、
		// 今後の歩数が少なくて済む方を返す
		int step1 = dfs(pos+1) + Math.abs(H[pos+1]-H[pos]);
		int step2 = dfs(pos+2) + Math.abs(H[pos+2]-H[pos]);
		// 値を返す際に、dp配列に答えを保持する
		return dp[pos] = Math.min(step1, step2);
	}
}


Measured memory_bytes: 72452
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n; 
    ll k; cin >> k;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    ll l=0,r=1e10;
    while(r-l>1){
        ll mid=(l+r)/2;
        ll sum=0;
        for(int i=0;i<n;i++){
            sum+=(a[i]+mid-1)/mid-1;
        }
        if(sum<=k){
            r=mid;
        }
        else{
            l=mid;
        }
    }
    cout << r << endl;
}

/*

WWWRRRR

RRRRWWW

*/


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

ll digits(ll a)
{
	ll res = 0;
	while(a > 0)
	{
		a /= 10;
		res++;
	}
	return res;
}

ll F (ll a, ll b)
{
	ll x = digits(a);
	ll y = digits(b);
	
	if (x > y) return x;
	return y;
}

int main()
{
	ll n;
	cin >> n;
	ll min = 100;
	for (ll i = 1; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			ll k = F(n / i, i);
			if (k < min) min = k;
		}
	}
	cout << min << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();

    int[] p = new int[N];

    for (int i = 0; i < N; i++) {
      p[i] = sc.nextInt();
    }

    sc.close();

    Arrays.sort(p);

    int sum = 0;

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

      if (i == N-1) {
        sum += p[i] / 2;
      } else {
        sum += p[i];
      }

    }

    System.out.println(sum);

  }

}

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

using namespace std;

int main(){
  string s;
  cin>>s;
  int n = s.length();
  string s1="",s2="";
  for(int i=0;i<n;i++){
    if(i%2==0) s1+="0";
    else s1+="1";
     
    if(i%2==0) s2+="1";
    else s2+="0";
  }
  int cnt = 0,cnt1=0;
  for(int i=0;i<n;i++){
    if(s[i] != s1[i]) cnt++;
    if(s[i] != s2[i]) cnt1++;
  }
  cout<<min(cnt,cnt1);
  return 0;
}

Measured memory_bytes: 768