akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int n;

int lower_bound(vector<int> &a,int k ){
    if(k == 0 || a[0] > k) return 0;
    int low, mid, high;
    low = 0;
    high = n - 1;
    while(low <= high){
        mid = (low + high) / 2;
        if( k == a[mid]) {
            if( a[mid-1] != k && mid-1 >= 0 ) return mid;
            else if (mid == 0) return 0;
            high = mid - 1;
        } else if ( k < a[mid]){
            high = mid - 1;
        } else if ( k > a[mid]){
            if( a[mid+1] == k) return mid + 1;
            low = mid + 1;
        }
    }
    if(a[mid]>k && a[mid-1]<k && mid-1>=0) return mid;
    if(a[mid]<k && a[mid+1]>k && mid+1<=n-1) return mid+1;
    return n;
}

int upper_bound(vector<int> &a , int k){
    if(a[n-1] <= k ) return n;
    if( k == 0){
        int j=0;
        while( a[j]== 0) ++j;
        return j;
    }
    int low, mid , high;
    low = 0;
    high = n - 1;
    while(low <= high){
        mid = (low + high) / 2;
        if( k == a[mid]){
            if( a[mid+1] > k && mid + 1 <= n - 1) return mid+1;
            if( mid + 1 == n - 1 && k == a[mid+1]) return n;
            low = mid + 1;
        } else if ( k > a[mid]){
            low = mid + 1;
        } else if ( k < a[mid]){
            if( a[mid-1] < k) return mid;
            high = mid - 1;
        }
    }
    if(a[mid]<k && a[mid+1]>k && mid+1<=n-1) return mid+1;
    if(a[mid]>k && a[mid-1]<k && mid-1>=0) return mid;
    return n;
}

int main(){
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int q; cin >> q;
    rep(i ,q){
        int k; cin >> k;
        cout << lower_bound(a , k) << " " << upper_bound(a , k) << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>


using namespace std;


int main() {
    int S;
    cin >> S;
    std::cout << (S / 100) + (S % 100 / 10) + (S % 100 % 10) << '\n';
    return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int a, b;
	string s;
	cin >>a >>b >>s;
	bool ok=true;
	if(sz(s) != a+b+1 || s[a] !='-') ok=false;
	rep(i, a+b+1){
		if(i != a ){
			if(s[i] <'0' || s[i] >'9') ok=false;
		}
	}
	puts(ok? "Yes":"No");
	return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T{
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
  	.bytes()
  	.map(|c| c.expect("failed") as char)
  	.skip_while(|c| c.is_whitespace())
  	.take_while(|c| !c.is_whitespace())
  	.collect();
  token.parse().ok().expect("failed")
}

fn main(){
  let s: String = read();
  let t: String = read();
  if s == t[0..t.len()-1]{
    println!("Yes");
  } else {
    println!("No");
  }
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << min({ a + b, b + c, a + c }) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
const double PI = 3.14159265359;

int main(void) {
	ll n, k; cin >> n >> k;
	ll ans = k;
	k--;
	for (ll i = 1; i < n; i++) {
		ans *= k;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    cout << (n > 12 ? m : (n > 5 ? m / 2 : 0)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

namespace
{
	ll fun(int i, int Ai, int N, int M, int Q, vi& A, vi& a, vi& b, vi& c, vi& d)
	{
		if(i == N)
		{
			ll sum = 0;
			for (int k = 0; k < Q; ++k)
			{
				if(A[b[k]] - A[a[k]] == c[k])
				{
					sum += d[k];
				}
			}
			return sum;
		}
		ll ret = 0;
		for (int j = Ai; j <= M; ++j)
		{
			A[i] = j;
			ll s = fun(i + 1, j, N, M, Q, A, a, b, c, d);
			if (ret < s)
				ret = s;

		}
		return ret;
	}
}

void ABC165C()
{
	int N, M, Q;
	cin >> N >> M >> Q;
	vi a(Q), b(Q), c(Q), d(Q);
	for (int i = 0; i < Q; ++i)
	{
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		--a[i];
		--b[i];
	}
	vi A(N);
	cout << fun(0, 1, N, M, Q, A, a, b, c, d) << endl;
}


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



Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

	if (A >= K) {
		cout << K;
	}
	else if (A + B >= K) {
		cout << A;
	}
	else {
		cout << A - (K - A - B);
	}

	return 0;
}

Measured memory_bytes: 3624
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll a,b;cin>>a>>b;
  ll ans=0;
  bitset<40>bita(a), bitb(b);
  if(a%2==0&&b%2==1){
    cout<<(b-a+1)/2%2<<endl;
  }
  else if(a%2==0&&b%2==0){
    ans+=(b-a)/2%2;
    bitset<40>bitans(ans);
    cout<<(bitb^bitans).to_ullong()<<endl;
  }
  else if(a%2==1&&b%2==1){
    ans=(b-a)/2%2;
    bitset<40>bitans(ans);
    cout<<(bita^bitans).to_ullong()<<endl;
  }
  else {
    bitset<40>bitans=bita^bitb;
    ll k=(b-a)/2%2;
    bitset<40>bitk(k);
    cout<<(bitk^bitans).to_ullong()<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

ll n;
vector<ll> g,v[111111];

bool dfs(int x,int p) {
  if(x==n-1) {
    g.pb(x);
    return 1;
  }
  bool f=0;
  rep(i,v[x].size()) {
    int y=v[x][i];
    if(y!=p) f|=dfs(y,x);
  }
  if(f) g.pb(x);
  return f;
}

int k;
int dfs2(int x,int p) {
  int cnt=1;
  rep(i,v[x].size()) {
    int y=v[x][i];
    if(y!=p&&y!=k) cnt+=dfs2(y,x);
  }
  return cnt;
}

void Main() {
  R n;
  rep(i,n-1) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    v[x].pb(y);
    v[y].pb(x);
  }
  dfs(0,-1);
  reverse(all(g));
  k=g[g.size()/2+g.size()%2];
  int cnt=dfs2(0,-1);
  if(cnt>n-cnt) pr("Fennec");
  else pr("Snuke");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 16504
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;

typedef long long int ll;
typedef string str;

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

void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main ()
{
	ll t,n,m,k,i,a,b,j;
	str s;
	cin >> n >> k;
	ll arr[n+3],c[n+3];
	for(i=1;i<=n;i++)
	{
		cin >> arr[i];
	}
	for(i=1;i<=n;i++)
	{
		cin >> c[i];
	}
	ll ans=-10000000000000000;
	for(i=1;i<=n;i++)
	{
		bool h[n+2]={0};
		vector <ll> v;
		v.pb(0);
		j=arr[i];
		while(h[j]==0)
		{
			h[j]=1;
			v.pb(c[j]);
			j=arr[j];
		}
		m=v.size()-1;

		ll val=-10000000000000000;
		for(j=1;j<=m;j++)
		{
			v[j]+=v[j-1];
		}
		
		if((k>m && v[m]>0))
		{
			a=k/m;
			b=k%m;
			ll x=a*v[m];

			ll y=(a-1)*v[m];
			ll p=0,q=0;
			for(j=1;j<=b;j++)
			{
				p=max(v[j],p);
			}
			x+=p;
			for(j=1;j<=m;j++)
			{
				q=max(v[j],q);
			}
			y+=q;
			val=max(x,y);
		}
		else if(v[m]<0 && k>m)
		{
			for(j=1;j<=m;j++)
			{
				val=max(v[j],val);
			}
		}
		else if(k<=m)
		{
			for(j=1;j<=k;j++)
			{
				val=max(v[j],val);
			}
		}
		ans=max(val,ans);
	}
	cout << ans << "\n";
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back


vec fac(210000), finv(210000), inv(210000);

ll modpow(ll a, ll n, ll m)
{
    if(n == 0) return 1;
    ll t = modpow(a, n >> 1, m);
    t = t * t % m;
    if(n & 1) t = t * a % m;
    return t; 
}

void combinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    REP(i,2,210000) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
 
ll combmod(ll n, ll r)
{
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    ll c = 1;
    REP(i,0,r) c = c * (n-i) % MOD;
    c = c * finv[r] % MOD;
    return c;
}

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

//    vec inv(200010, 0);
//    inv[1] = 1;
//    REP(i,2,200010) inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;

    combinit();

    ll nCa = 1, nCb = 1, c;
    //REP(i,1,a+1) nCa = (nCa * (n-i+1) % MOD) * inv[i] % MOD;
    //REP(i,1,b+1) nCb = (nCb * (n-i+1) % MOD) * inv[i] % MOD;
    nCa = combmod(n, a);
    nCb = combmod(n, b);
    c = (modpow(2, n, MOD) - 1- nCa - nCb) % MOD;
    c = (c < 0) ? c + MOD : c;
    PR(c); 

    return 0;
}

/*

nC1 + ... + nCn - nCa - nCb
= 2^n - 1 - nCa - nCb

*/

Measured memory_bytes: 5120
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws ClassNotFoundException, IOException {
		FastScanner sc = new FastScanner();
		int P = sc.nextInt(); //AB間片道時間
		int Q = sc.nextInt(); //BC間片道時間
		int R = sc.nextInt(); //CA間片道時間

		int answer = P + Q;
		if(answer > Q + R) {
			answer = Q + R;
		}
		if(answer > P + R) {
			answer = P + R;
		}

		System.out.println(answer);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    string a,b,c;
    cin>>a>>b>>c;
    cout<<(char)toupper(a[0])<<(char)toupper(b[0])<<(char)toupper(c[0])<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n, k;
	cin >> n >> k;
	Vec a(n);
	rep(i, n) cin >> a[i];

	Vec cur(n + 1), nxt(n + 1);
	rep(i, n) cur[i] = a[i];

	rep(i, k){
		ll cnt = 0;
		rep(j, n){
			nxt[max(0LL, j - cur[j])]++;
			nxt[min(n, j + cur[j] + 1)]--;
		}
		repn(j, n) nxt[j] += nxt[j - 1];
		swap(cur, nxt);
		nxt.assign(n, 0);
		rep(j, n) if (cur[j] == n) cnt++;
		if (cnt == n) break;
	}
	rep(i, n) cosp(cur[i]);
	co();

	return 0;
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define mod 1000000007
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

const i64 maxn = (i64)1e6 + 1000;
i64 x, y, pre[maxn];
 

i64 fac[maxn],inv[maxn];
i64 pow_mod(i64 a,i64 n)
{
    i64 ret =1;
    while(n)
    {
        if(n&1) ret=ret*a%mod;
          a=a*a%mod;
          n>>=1;
    }
    return ret;
}
void init()
{
    fac[0]=1;
    for(i64 i=1;i<maxn;i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
}
i64 Cc(i64 x, i64 y)
{
    return fac[x]*pow_mod(fac[y]*fac[x-y]%mod,mod-2)%mod;
}


int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif
/*	
	pre[1] = 1;
	fore(i, 2, 1000000) {
		pre[i] = pre[i - 1] * i;
//		cerr << i << " " << pre[i] << endl;
		if (pre[i] > mod) pre[i] %= mod;
	}*/
	init();
	cin >> x >> y;
	if (x < y) swap(x, y);
	if (((x % 3) + (y % 3)) % 3 != 0) {
		cout << 0 << '\n';
		return 0;
	}
	i64 more = abs(x - y);
	i64 m1 = more;
	x -= 2 * more;
	y -= more;
	if (x < 0 || y < 0 || x != y) {
		cout << 0 << '\n';
		return 0;
	}
	i64 m2 = (x / 3);
	i64 n = m1 + 2 * m2;
	i64 m = m2;
	i64 ans = Cc(n, m);
	if (ans > mod) ans %= mod;
	cout << ans << endl;

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 10496
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  vvl ans = VV(100000, 2, 0, ll);

  if(n%2){
    ll max_m = n/2;
    ll ld = 0, rd = 0;
    for(int w=max_m;w>0;w--){
      if(w%2==1){
        ld++;
        ans[w][0] = (max_m%2?n/2+ld:ld);
        ans[w][1] = (max_m%2?n+1-ld:n/2+1-ld);
      }else{
        rd++;
        ans[w][0] = (max_m%2?rd:n/2+rd);
        ans[w][1] = (max_m%2?n/2+1-rd:n+1-rd);
      }
    }
  }else{
    ll max_m = n/2 - 1;
    ll ld = 0, rd = 0;
    for(int w=max_m;w>0;w--){
      if(w%2==1){
        ld++;
        ll l = ld, r = n/2+1-ld;
        ans[w][0] = l, ans[w][1] = r;
      }else{
        rd++;
        ll l = n/2+rd, r = n - rd;
        ans[w][0] = l, ans[w][1] = r;
      }
    }
  }
  for(int i=1;i<=m;i++) std::cout << ans[i][0] << " " << ans[i][1] << '\n';
  return 0;
}


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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    string S;
    cin >> S;
    int first = stoi(S.substr(0, 2));
    int second = stoi(S.substr(2, 2));

    string ans;
    if (first >= 1 && first <= 12 && second >= 1 && second <= 12) {
        ans = "AMBIGUOUS";
    } else if (first >= 0 && first <= 99 && second >= 1 && second <= 12) {
        ans = "YYMM";
    } else if (first >= 1 && first <= 12 && second >= 0 && second <= 99) {
        ans = "MMYY";
    } else {
        ans = "NA";
    }

    cout << ans << endl;
}

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

int main(){
  int N,M; cin >> N >> M;
  int ball[100000];
  bool red[100000];
  for(int i=0; i<N; i++){
    ball[i]=1; red[i]=false;
  }
  red[0]=true;
  
  for(int i=0; i<M; i++){
    int x,y; cin >> x >> y;
    x--; y--;
    ball[x]--; ball[y]++;
    if(red[x]==true) red[y]=true;
    if(ball[x]==0) red[x]=false;
  }
  
  int result=0;
  for(int i=0; i<N; i++) if(red[i]==true) result++;
  cout << result << endl;
}

Measured memory_bytes: 768
N = int(input())
a = list(map(int, input().split()))

ans = 0
num = 1
flag = False

for i in range(N):
    if a[i] == num:
        num += 1
        flag = True
    else:
        ans += 1

if flag:
    print(ans)
else:
    print(-1)

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

#define ll long long

typedef pair< int, int > ii;
typedef vector< ii > vii;

string ask(int num){
	cout<<num<<endl;
	string ans; cin>>ans;
	return ans;
}

void solve(){
	int x; cin>>x;
	for(int i = 1; ; i++){
		if((i * x)%360 == 0){
			cout<<i<<endl;
			return;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}



Measured memory_bytes: 3660
#include<iostream>
using namespace std;
const int N=1002020;
int n,a[N],b[N];
void print(){
	puts("Yes");
	for(int i=1;i<=n;i++)
		cout<<b[i]<<" ";cout<<endl;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=n;i>=1;i--)cin>>b[i];
	int l=n,r=0;
	for(int i=1;i<=n;i++)
		if(a[i]==b[i])l=min(l,i),r=max(r,i);
	if(!r){print();return 0;}
	int nw=l;
	for(int i=1;i<l && nw<=r;i++)
		if(b[nw]!=a[i] && b[nw]!=b[i])
			swap(b[nw],b[i]),++nw;
	for(int i=r+1;i<=n && nw<=r;i++)
		if(b[nw]!=a[i] && b[nw]!=b[i])
			swap(b[nw],b[i]),++nw;
	int fl=0;
	for(int i=1;i<=n;i++)
		if(b[i]==a[i]){fl=1;break;}
	if(fl)puts("No"); else print();
	return 0;
}

Measured memory_bytes: 5204
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
vector<int> prime;
bool used[MAX_N];

void solve() {
	cin >> N;
	rep(i, 2, 55555 + 1) {
		if(!used[i]) {
			prime.pb(i);
			for(int j = i; j <= 55555; j += i) {
				used[j] = true;
			}
		}
	}
	int at = 0;
	rep(i, 0, N) {
		while(prime[at] % 5 != 1) at++;
		cout << prime[at] << " ";
		at++;
	}
	cout << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

constexpr int M = 2000;
bool ab[30000], ac[30000], bc[30000];

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

    string a, b, c;
    cin >> a >> b >> c;
    int A = a.length(), B = b.length(), C = c.length();

    auto check = [&](char ch1, char ch2) -> bool {
        if(ch1 == '?' || ch2 == '?' || ch1 == ch2)  return true;
        else    return false;
    };

    for(int i = 0; i < A; ++i){
        for(int j = 0; j < B; ++j){
            if(!check(a[i], b[j]))  ab[i - j + 10000] = true;
        }
    }
    for(int i = 0; i < A; ++i){
        for(int j = 0; j < C; ++j){
            if(!check(a[i], c[j]))  ac[i - j + 10000] = true;
        }
    }
    for(int i = 0; i < B; ++i){
        for(int j = 0; j < C; ++j){
            if(!check(b[i], c[j]))  bc[i - j + 10000] = true;
        }
    }

    int ans = 3 * M;
    for(int i = -2 * M; i <= 2 * M; ++i){
        for(int j = -2 * M; j <= 2 * M; ++j){
            if(ab[i + 10000] || ac[j + 10000] || bc[j - i + 10000]) continue;
            int L = min({0, i, j});
            int R = max({A, B + i, C + j});
            chmin(ans, R - L);
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define loop(i,n) for(ll i=0;i<(ll)(n);i++)
#define change(a,b) do{ll c=a; a=b; b=c;}while(0)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        change(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll a;
  cin>>a;
  cout<<(a+1)/2<<endl;
}

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

int main(void) {
    int i,sum,temp;
    char digit[1002];
    while (1) {
        fgets(digit,sizeof(digit),stdin);
        sscanf(digit,"%d\n",&temp);
        if (temp==0) break;
        sum=0;
        for (i=0; i<strlen(digit)-1; i++) sum+=digit[i]-'0';
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 616
//
// Created by Rea1 on 2020/2/22.
//
#pragma comment(linker, "/STACK:1024000000,1024000000")

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1

int main() {
    int n;
    cin >> n;
    vector<int> x(n + 1);
    int maxn = 0;
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
        if (x[i] > maxn) maxn = x[i];
    }
    ll minn = 1e18;
    for (int i = 1; i <= maxn; i++) {
        ll ans = 0;
        for (int j = 1; j <= n; j++) {
            ans += (x[j] - i) * (x[j] - i);
        }
        minn = min(minn, ans);
    }
    cout<<minn;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h,a[500001];
void maxHeapify(int );
void buildMaxHeap();

int main(){
  cin>>h;
  for(int i=0;i<h;i++)cin>>a[i];
  buildMaxHeap();
  for(int i=0;i<h;i++)cout<<" "<<a[i];
  cout<<endl;
  return 0;
}
void maxHeapify(int i){
  int l=i*2+1,r=i*2+2,la;
  if(l<=h && a[l]>a[i])la=l;
  else la=i;
  if(r<=h && a[r]>a[la])la=r;
  if(la!=i){
    swap(a[i],a[la]);
    maxHeapify(la);
  }
}
 
void buildMaxHeap(){
  for(int i=h/2-1;i>=0;i--)maxHeapify(i);
}



Measured memory_bytes: 5048
A,B,C = map(int,input().split())
K = int(input())

ab = 0
while A >= B:
    ab += 1
    B *= 2
bc = 0
while B >= C:
    bc += 1
    C *= 2
if ab + bc <= K:
    print('Yes')
else:
    print('No')    

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

int main(void)
{
    double x1,x2,x3,y1,y2,y3;
    double xp,yp;
    double z1,z2,z3;

    while(~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)) { 
        z1 = (x3 - x2) * (yp - y2) - (y3 - y2) * (xp - x2);
        z2 = (x1 - x3) * (yp - y3) - (y1 - y3) * (xp - x3);
        z3 = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1);

        if((z1>0 && z2>0 && z3>0) || (z1<0 && z2<0 && z3<0))
            puts("YES");
        else
            puts("NO");
    }


    return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll N;
	cin >> N;
	VLL C(N);
	for (ll n = 0; n < N; n++)cin >> C[n];
	sort(C.begin(), C.end(), [](ll a, ll b) {
		return a < b;
	});
	ll ans = 1;
	for (ll t = 0; t < 2*N-2; t++)ans = (ans * 2) % MOD;
	ll sum = 0;
	for (ll n = 0; n < N; n++) {
		sum = (sum + (N+1-n)*C[n]) % MOD;
	}
	cout << ans * sum % MOD << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    double r;
    double pi = 3.141592653589;
    cin >> r;
    
    double l = 2 * pi * r;
    double S = pi * r * r;

    printf("%1f %1f\n", S, l);
    return 0;
    
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B > C + D) {
        prints()("Left");
    }
    else if (A + B == C + D) {
        prints()("Balanced");
    }
    else {
        prints()("Right");
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define maxn 200100
#define ll long long
using namespace std;
int n,a[maxn];
int main()
{
    scanf("%d",&n);
    ll sum=0;
    for(int i=1;i<=n;++i)
    {
        scanf("%d",&a[i]);
        a[i]-=i;
    }
    sort(a+1,a+1+n);
    int b=a[(n+1)/2];
    for(int i=1;i<=n;++i) sum+=abs(b-a[i]);
    cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 1024
h, w = gets.split.map(&:to_i)
n = gets.to_i
colors = gets.split.map(&:to_i)
tmp = []
remain = w
reverse = false
colors.each_with_index do |color, i|
  while(color > 0) do
    count = [remain, color].min
    tmp += [i + 1] * count
    remain -= count
    color -= count
    if remain == 0
      puts reverse ? tmp.reverse.join(' ') : tmp.join(' ')
      tmp = []
      remain = w
      reverse = !reverse
    end
  end
end


Measured memory_bytes: 2940
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();    
        String s = r.s();
        int K = r.i(),
            len = s.length();
        SortedSet<String> sub = new TreeSet<>();
        for(int i = 0; i < len; i++){
            int limit = Math.min(K, len-i);
            for(int j = 0; j < limit; j++)
                sub.add(s.substring(i, i+j+1));            
        }
        print(new ArrayList<>(sub).get(K-1));
    }
    static void print(Object o){
        System.out.println(o.toString());
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int Int(String s){
            return Integer.parseInt(s);
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
    }
}

Measured memory_bytes: 24020
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  string N;
  cin>>N;
  string ans="No";
  if(N[0]=='7')ans="Yes";
  if(N[1]=='7')ans="Yes";
  if(N[2]=='7')ans="Yes";
  cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	if (A <= C && C <= B)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n,ans,r;
ll a[100005];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll b=-1,s=0;
    for(int i=0;i<n;i++){
        s+=a[i];
        if(b<0){
            if(s<=0){
                ans+=abs(s)+1;
                s=1;
            }
            
        }else{
            if(s>=0){
                ans+=s+1;
                s=-1;
            }
        }
        b*=(-1);
    }
    b=1;
    s=0;
    for(int i=0;i<n;i++){
        s+=a[i];
        if(b<0){
            if(s<=0){
                r+=abs(s)+1;
                s=1;
            }
        }else{
            if(s>=0){
                r+=s+1;
                s=-1;
            }
        }
        b*=(-1);
    }
    cout<<min(r,ans)<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long int ll;

string N;
ll ans;

ll calc(int n,int isupper,int f,int l){
    if(n==N.size()-1){
        if(isupper==1)return 0;
        if(isupper==2&&N[N.size()-1]-'0'<l)return 0;
        else return 1;
    }
    ll res=0;
    for(int i=0;i<=9;++i){
        if(n==0)if(i!=f)continue;
        int _isupper;
        if(isupper==0)_isupper=0;
        else if(isupper==2&&i==N[n]-'0')_isupper=2;
        else if(isupper==2&&i<N[n]-'0')_isupper=0;
        else _isupper=1;
        if(i==l)res+=calc(n+1,_isupper,f,l)+1;
        else res+=calc(n+1,_isupper,f,l);
    }
    return res;
}

int main(){
    cin>>N;
    for(int a1=1;a1<=9;++a1){
        for(int a2=1;a2<=9;++a2){
            ans+=calc(0,2,a1,a2)*calc(0,2,a2,a1);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc154/tasks/abc154_b
//B - I miss you...
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#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() {
    string S; cin>>S;
    for(auto&& c:S){
        c='x';
    }
    cout<<S<<endl;    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
typedef long long  ll;

int main() {
	ll x;
	cin >> x;
	ll temp = 0;
	for (ll i = 0; i <= x; i++)
	{
		temp += i;
		if (temp >= x) {
			cout << i << endl;
			return 0;
		}
	}
}

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

int main() {
 int N,K,X,Y;
 cin >> N >> K >> X >> Y;
  
 if(N>K){
  cout << (K)*X+(N-K)*Y;
 }
 else {
  cout << (N)*X;
 } 
}


Measured memory_bytes: 256
s = input()
ans = "TBD"
if int(s[0:4]) <= 2018:
    ans = "Heisei"
elif int(s[0:4]) <= 2019 and int(s[5:7]) <= 3:
    ans = "Heisei"
elif int(s[0:4]) <= 2019 and int(s[5:7]) <= 4 and int(s[8:10]) <= 30:
    ans = "Heisei"
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include<cstdio>
using namespace std;
int main(){
	int n,m,p,q,r,x,y,t;
	vector<int>::iterator itx,ity,it;
	for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){
		vector<int> v1,v2;
		v1.push_back(0);
		v1.push_back(r);
		
		for(;m--;v2.clear()){
			cin>>x>>y;
			itx=upper_bound(v1.begin(),v1.end(),x);
			ity=upper_bound(v1.begin(),v1.end(),y);
			
			if( ity-v1.begin()+1 & 1 )v2.push_back(0);
			v2.push_back(0);
			for(it=ity;it!=v1.end();++it)
				v2.push_back(*it - y);
			
			if(v1.end()-itx & 1)v2.push_back(n-y);
			for(it=itx;it!=ity;++it)
				v2.push_back(*it-x+n-y);
			
			it = v1.begin();
			if(ity-v1.begin() & 1)++it;
			if(!it[1]){++it;++it;}	//d¡r
			if(*it+n-x==v2.back()){++it;v2.pop_back();}	//d¡r
			for(;it!=itx;++it)
				v2.push_back(*it+n-x);
			
			v1.swap(v2);
			
/*			for(it=v1.begin();it!=v1.end();++it)
				cout<<*it<<'\t';
			cout<<'\n';
*/		}
		v1.insert( upper_bound(v1.begin(),v1.end(),p-1), 2, p-1);
		v1.insert( lower_bound(v1.begin(),v1.end(),q), q );
		v1.push_back(n);
		it = upper_bound(v1.begin(),v1.end(),p-1);
		if(it-v1.begin() & 1) --it;
/*
for(itx=v1.begin();itx!=v1.end();++itx)
	cout<<*itx<<'\t';
cout<<'\n';

		printf("%d\t%d\n",it-v1.begin(),*it);
*/		for(x=0;*it<q;++it){
			m=*it;
			++it;
			x+=*it-m;
		}
	}
}

Measured memory_bytes: 964
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"




def main():
    a,b,c = mi()
    if c-a-b<=0:
        print(no)
        exit()
    else:
        if (c-a-b)**2 > 4*a*b:
            print(yes)#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "YES"
no = "NO"




def main():
    a,b = mi()
    if a == 1 or b == 1:
        print(1)
        exit()
    ans = 0
    ans+=((a+1)//2)*((b+1)//2)
    ans+=(a//2)*(b//2)
    print(ans)

        
    


main()



Measured memory_bytes: 5688
#include<bits/stdc++.h>
using namespace std;
int main()
{ long long a,b,k,sum=0;
   cin>>a>>b>>k;
    sum=a+b;
    if(sum<=k)
     a=b=0;
    else if(a<=k)
     { b=b-(k-a); a=0;
     }
    else 
     a=a-k;
     cout<<a<<' '<<b;
    
}

Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int k,s;
    cin>>k>>s;
    int cnt=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(s-(i+j)>=0 && s-(i+j)<=k)    cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
# import itertools
# import numpy as np

n, s = list(map(int, input().split()))
a = list(map(int, input().split()))

mod = 998244353

dp = [[0]*(s+1) for _ in range(n+1)]

dp[0][0] = 1

for i in range(0, n):
    for j in range(0, s+1):
        dp[i+1][j] += dp[i][j]*2 % mod

        if j+a[i] <= s:
            dp[i + 1][j + a[i]] += dp[i][j] % mod


print(dp[n][s] % mod)


Measured memory_bytes: 139076
n, m = map(int, input().split())
adjacent_list = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    adjacent_list[a].append(b)
    adjacent_list[b].append(a)
ans = 0
def dfs(node,f):
    global ans
    if len(f) == n:
        ans += 1
    else:
        for i in adjacent_list[node]:
            if i not in f:
                k = f | set([i])
                dfs(i,k)
dfs(1,set([1]))
print(ans)

Measured memory_bytes: 41948
import sys

N, M = (int(i) for i in input().split())
P = [None for i in range(N+1)]
Graph = [list() for i in range(N+1)]
for index in range(M):
	L, R, D = (int(i) for i in input().split())
	Graph[L].append((R, D))
	Graph[R].append((L,-D))

def determine(i):
	if P[i] is not None:
		return
	P[i] = 0
	stack = [i]
	while len(stack) != 0:
		I = stack.pop()
		for j, d in Graph[I]:
			if P[j] is None:
				P[j] = P[I] + d
				stack.append(j)

def check(i):
	for j, d in Graph[i]:
		if P[j] - P[i] != d:
			print("No")
			exit(0)

for i in range(1,N+1):
	determine(i)

for i in range(1,N+1):
	check(i)

print("Yes")

Measured memory_bytes: 65992
s = input()
t = input()

l = len(s)
d1 = dict()
d2 = dict()

for i in range(l):
    if s[i] not in d1:
        d1[s[i]] = t[i]
    elif d1[s[i]] != t[i]:
        print("No")
        exit()

for i in range(l):
    if t[i] not in d2:
        d2[t[i]] = s[i]
    elif d2[t[i]] != s[i]:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 3632
package main

import (
	"fmt"
)

func main() {
	var k, n int
	fmt.Scan(&k, &n)
	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}
	maxd := k - as[n-1] + as[0]
	for i := 0; i < n-1; i++ {
		d := as[i+1] - as[i]
		if d > maxd {
			maxd = d
		}
	}
	fmt.Println(k - maxd)
}


Measured memory_bytes: 6784