akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<ll, ll> P;


auto compare = [](P a, P b){
    if (a.first != b.first){
        return a.first > b.first;
    } else {
        return a.second > b.second;
    }
};
priority_queue<P, vector<P>, decltype(compare)> pq(compare); 

int main()
{
    ll n, d, a;
    cin >> n >> d >> a;
    vector<P> xh;
    rep(i, n){ 
        ll tmpx, tmph; 
        cin >> tmpx >> tmph; 
        pq.push(P(tmpx, tmph));
    }

    ll ans = 0;
    ll power = 0;
    while(!pq.empty()){
        //printf("%lld %lld %lld\n", pq.top().first, pq.top().second, power);
        P point = pq.top();
        if (point.second > 0){
            //敵出現
            ll diff = point.second - power;
            if (diff > 0){
                //爆弾の威力が足りない
                ll bom = (diff-1)/a + 1;
                ans += bom;
                power += bom * a;
                pq.push(P((point.first + 2*d + 1), -(bom*a)));
            } 
        } else {
            power += point.second; 
        }
        pq.pop();
    }


    cout << ans << endl;
}



Measured memory_bytes: 6256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

class Edge
{
	public:
	int cost;
	int next;

	Edge(int n,int c)
	{
		next=n;
		cost=c;
	}
};

vector<Edge> g[100000];
ll depth[100000];
ll x[100000];
ll y[100000];

int dfs(int now,ll c)
{
	depth[now]=c;
	for(int i=0;i<g[now].size();i++)
	{
		//cerr<<"dfs"<<endl;
		Edge e=g[now][i];
		if(depth[e.next]==-1)
			dfs(e.next,c+e.cost);
	}
	return 0;
}

int main()
{
	int n,q,k;
	ll ans;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		a--;
		b--;
		g[a].push_back(Edge(b,c));
		g[b].push_back(Edge(a,c));
	}
	cin>>q>>k;
	k--;
	for(int i=0;i<q;i++)
	{
		//cerr<<"loop"<<endl;
		cin>>x[i]>>y[i];
		x[i]--;
		y[i]--;
	}
	fill(depth,depth+100000,-1);
	depth[k]=0;
	dfs(k,0);
	for(int i=0;i<q;i++)
	{
		ll xx=x[i];
		ll yy=y[i];
		ans = depth[xx]+depth[yy];
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 1e5 + 10;
const ll MOD = 1e9 + 7;

string s;
ll dp[MAXN][2];

ll rec(ll idx,ll tight){
    if(idx == s.size()) return 1;

    ll &ans = dp[idx][tight];

    if(ans != -1) return ans;

    if(tight){
        if(s[idx] == '0') ans = rec(idx+1,tight);
        else {
            ans = rec(idx+1,0);
            ans = (ans + 2*rec(idx+1,1))%MOD;
        }
    }else {
        ans = rec(idx+1,0);
        ans = (ans + 2*rec(idx+1,0))%MOD;
    }
    
    return ans;
}

void solve(){
    
    cin>>s;
    MINUS(dp);

    ll ans = rec(0,1);
    cout<<ans<<endl;
}       

signed main(){

   FastRead;    


    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}


Measured memory_bytes: 6736
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll N,K,S;
    cin >> N >> K >> S;
    rep(i,N){
        if(i < K){
            cout << S << endl;
        }else{
            if(S != INF){
                cout << INF << endl;
            }else{
                cout << 7 << endl;
            }
        }
    }
}


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


int main() {
    int max_sum = 0;
    int current_sum = 0;
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == 'I') current_sum++;
        else current_sum--;
        if (current_sum > max_sum) max_sum = current_sum;
    }
    cout << max_sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
ll mod =1e9;
int main() {
    ll n;
    cin>>n;
    vl a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    cout<<a[n/2]-a[n/2-1]<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int

using namespace std;

void solve()
{
  int n;
  cin>>n;
  long double pro=1;
  int flag=1;
  int input;
  vector<int> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  sort(v.begin(), v.end());

  for(int i=0;i<n;i++)
  {
    
    if(pro*v[i] > 1e18)
      {
        cout<<-1<<endl;
        return;
      }
      else
        pro*=v[i];

  }
  
    cout<<fixed<<setprecision(0)<<pro<<endl;




}
signed main()

{
  FAST_IO;
  int t = 1;

  // cin>>t;

  while(t--)
  {
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 3972
#include<bits/stdc++.h>
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define forb(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,x;
	cin >> n >> x;
	int arr[n+1];
	vi v;
	for(int i=0;i<n;i++){
		cin >> arr[i];
		v.push_back(arr[i]);
	}
	int  sum = 0;
	for(int i=0;i<n;i++){
		sum += arr[i];
	}
	x -= sum;
	int r = x / *min_element(v.begin(),v.end());
	
	cout << n + r << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define N 200001
#define ll long long
#define int ll
#define pi pair<int, int>
#define pip pair<pair, int>
#define mp make_pair
#define f first
#define s second
#define mod 998244353
int dp[1002][5][2];
int k;
string str;
int n;
int solve(int pos, int cnt, bool tight)
{
    if (pos == n && cnt == k)
        return 1;
    else if (pos == n && cnt != k)
        return 0;
    if (dp[pos][cnt][tight] != -1)
        return dp[pos][cnt][tight];
    ll ret = 0;
    ll en = tight ? (str[pos] - '0') : 9;
    for (int i = 0; i <= en; i++)
    {
        ll cntupd = cnt + (i > 0);
        if (cntupd <= k)
        {
            ret += solve(pos + 1, cntupd, (tight & (i == en)));
        }
    }
    return (dp[pos][cnt][tight] = ret);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> str;
    n = str.length();
    cin >> k;
    memset(dp, -1, sizeof dp);
    ll ans = solve(0, 0, true);
    cout << ans << endl;
}


Measured memory_bytes: 384
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i32 = input();
    let b: i32 = input();
    let c: i32 = input();
    println!(
        "{}",
        if a + b == c || b + c == a || c + a == b {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(vector<T> & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(vector<T>& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(vector<T>& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(vector<T>& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>T Sum(vector<T> a, T init = 0) { return accumulate(a.begin(), a.end(), init); }

//INPUT//
void CINPUT() {}
template<class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define in(...) int __VA_ARGS__; CINPUT(__VA_ARGS__);
#define In(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define Vin(T,name,n) int n; cin>>n; vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn(T,name,n) vector<T> name(n); rep(i,n)cin>>name[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template<class T>void out(T n) { cout << n << endl; }
template<class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

//回文判定
bool PalinCheck(string s) {
	bool ret = true; int size = (int)s.size();
	for (int i = 0; i < size / 2; ++i) {
		if (s[i] != s[size - i - 1]) {
			ret = false;
			break;
		}
	}
	return ret;
}

int main() {
	in(a, b);
	int ans = 0;
	FOR(i, a, b + 1) {
		ans += PalinCheck(to_string(i));
	}
	out(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
//void ckmax(int &x,int y){
//	if (x<y)
//		x=y;
//}
//void ckmin(int &x,int y){
//	if (x>y)
//		x=y;
//}
const int N=100005;
int n,m,v,p;
LL a[N],b[N];
int check(int k){
	For(i,1,n)
		b[i]=a[i];
	int cnt=v-1-(n-k);
	if (cnt>0){
		LL tot=(LL)cnt*m;
		For(i,1,k-1){
			if (b[i]>a[k]+m)
				continue;
			LL d=max(0LL,a[k]+m-b[i]);
			tot-=d;
			b[i]+=d;
		}
		For(i,1,k-1){
			LL d=min(a[i]+m-b[i],tot);
			tot-=d;
			b[i]+=d;
		}
	}
	int c=p;
	For(i,1,k-1)
		if (b[i]>a[k]+m)
			c--;
	return c>0;
}
int main(){
	n=read(),m=read(),v=read(),p=read();
	For(i,1,n)
		a[i]=read();
	sort(a+1,a+n+1,greater <int>());
	int ans=p,L=p+1,R=n;
	while (L<=R){
		int mid=(L+R)>>1;
		if (check(mid))
			L=mid+1,ans=mid;
		else
			R=mid-1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define all(x)     (x).begin() , (x).end()
typedef long long int ll;
using namespace std;

const ll     mod = 1e9+7;
const double eps = 1e-9;


int n;
const int N=1e5+10;
int a[N][3],dp[N][4];

int rec(int ind,int p) {
    if(ind==n)
        return 0;
    int &cur=dp[ind][p+1];
    if(cur!=-1)return cur;
    int ans=0;
    ans=max({ans,(p!=0)*(a[ind][0]+rec(ind+1,0)),(p!=1)*(a[ind][1]+rec(ind+1,1)),(p!=2)*(a[ind][2]+rec(ind+1,2))});
    return cur=ans;
}

void solve(){
    cin >> n;
    for(int i=0;i<n;++i)
        for(int j=0;j<4;++j)
            dp[i][j]=-1;
    for(int i=0;i<n;++i)
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    cout << rec(0 , -1) << "\n";
}


int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--)
        solve();
    return  0;
}


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

const int MAX=1<<17;

int bit[MAX+1]={},n;//[1,n]

int sum(int i)//[1,i]
{
	int s=0;
	while(i>0)
	{
		s+=bit[i];
		i&=i-1;//i-=i&-i
	}
	return s;
}

void add(int i,int x)
{
	while(i<=n)
	{
		bit[i]+=x;
		i+=i&-i;
	}
	return;
}

int main()
{
	int q;cin>>n>>q;
	int a,b,c;
	for(int i=0;i<q;i++)
	{
		cin>>c>>a>>b;
		if(c)
		{
			cout<<sum(b)-sum(a-1)<<endl;
		}
		else add(a,b);
	}
	return 0;
}

Measured memory_bytes: 3472
#include <iostream>

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

    for(int i = 1; i < 10; i++) {
        for(int j = 1; j < 10; j++) {
            if(N == i * j) {
                std::cout << "Yes" << std::endl;
                return 0;
            } else if(N < i * j) {
                break;
            }
        }
    }

    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false



int main() {
	int N, K;
	cin >> N >> K;
	int ans = 1;
	REP(i, N) {
		ans = min(ans * 2, ans + K);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    auto XY = new double[2][](N);
    foreach (i; 0 .. N)
        scan(XY[i][0], XY[i][1]);
    auto dist = new double[][](N, N);
    foreach (i; 0 .. N)
        foreach (j; i .. N)
        {
            dist[i][j] = dist[j][i] = sqrt((XY[i][0] - XY[j][0]) ^^ 2 + (XY[i][1] - XY[j][1]) ^^ 2);
        }
    auto ord = iota(N).array();
    double ans = 0;
    long cnt = 0;
    do
    {
        double sum = 0;
        foreach (i; 1 .. N)
        {
            sum += dist[ord[i]][ord[i - 1]];
        }
        ans += sum;
        cnt++;
    }
    while (nextPermutation(ord));
    writefln("%.10f", ans / cnt);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
		int N,M,C;
		cin >> N >> M >> C;
		int B[M];
		int ans = 0;
		for (int i=0; i<M; i++) {
				cin >> B[i];
		}
		for (int i=0; i<N; i++) {
				int sum=0;
				for (int j=0; j<M; j++) {
						int a;
						cin >> a;
						sum += a*B[j];
				}
				if ((sum+C)>0) {
						ans++;
				}
		}
		cout << ans << endl;
		return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int sosuu_num;
int sosuu_list[1000000];

void make_sosuu_list(void) {
	char is_sosuu[1000001];
	int i,j;
	for(i=0;i<=1000000;i++)is_sosuu[i]=1;
	is_sosuu[0]=is_sosuu[1]=0;
	sosuu_num=0;
	for(i=2;i<=1000000;i++) {
		if(is_sosuu[i]) {
			sosuu_list[sosuu_num++]=i;
			for(j=i+i;j<=1000000;j+=i)is_sosuu[j]=0;
		}
	}
}

int main(void) {
	int a,b;
	int i;
	int first;
	int a_sum,b_sum;
	make_sosuu_list();
	while(1) {
		scanf("%d%d",&a,&b);
		if(a==0 && b==0)break;
		a_sum=0;first=1;
		for(i=sosuu_num-1;i>=0;i--) {
			if(a%sosuu_list[i]==0) {
				if(first){a_sum=sosuu_list[i];first=0;}
				else a_sum-=sosuu_list[i];
			}
		}
		b_sum=0;first=1;
		for(i=sosuu_num-1;i>=0;i--) {
			if(b%sosuu_list[i]==0) {
				if(first){b_sum=sosuu_list[i];first=0;}
				else b_sum-=sosuu_list[i];
			}
		}
		puts(a_sum>=b_sum?"a":"b");
	}
	return 0;
}

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

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

  if (400 <= X &&  X <= 599) {
    cout << 8 << endl;
  }
  else if (600 <= X &&  X <= 799) {
    cout << 7 << endl;
  }
  else if (800 <= X &&  X <= 999) {
    cout << 6 << endl;
  }
  else if (1000 <= X &&  X <= 1199) {
    cout << 5 << endl;
  }
  else if (1200 <= X &&  X <= 1399) {
    cout << 4 << endl;
  }
  else if (1400 <= X &&  X <= 1599) {
    cout << 3 << endl;
  }
  else if (1600 <= X &&  X <= 1799) {
    cout << 2 << endl;
  }
  else {
    cout << 1 << endl;
  }

}

Measured memory_bytes: 3648
n = int(input())

scores = []
for i in range(0, n):
  a, b, c = [int(elem) for elem in input().split()]
  if not scores == []:
    prev_a, prev_b, prev_c = scores[-1] # 最後が a, b, c のときの最大値
    if max(prev_b, prev_c) == prev_b:
      if max(prev_a, prev_c) == prev_a:
        if max(prev_a, prev_b) == prev_b:
          scores.append((a + prev_b, b + prev_a, c + prev_b))
        else:
          scores.append((a + prev_b, b + prev_a, c + prev_a))
      else:
        if max(prev_a, prev_b) == prev_b:
          scores.append((a + prev_b, b + prev_c, c + prev_b))
        else:
          scores.append((a + prev_b, b + prev_c, c + prev_a))
    else:
      if max(prev_a, prev_c) == prev_a:
        if max(prev_a, prev_b) == prev_b:
          scores.append((a + prev_c, b + prev_a, c + prev_b))
        else:
          scores.append((a + prev_c, b + prev_a, c + prev_a))
      else:
        if max(prev_a, prev_b) == prev_b:
          scores.append((a + prev_c, b + prev_c, c + prev_b))
        else:
          scores.append((a + prev_c, b + prev_c, c + prev_a))      
  else:
    scores.append((a, b, c))

print(max(scores[-1]))

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

int main()
{
  int n;
  cin >> n;
  int M = -1000001, m = 1000001;
  long sum = 0;
  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    M = max(M, a);
    m = min(m, a);
    sum += a;
  }
  cout << m << " " << M << " " << sum << endl;
}


Measured memory_bytes: 3120
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;


int main(){
    string s,t;
    cin>>s>>t;
    int S[110],T[110];
    
    rep(i,0,s.size()){
        S[i]=s.at(i)+'0';
    }
    rep(i,0,t.size()){
        T[i]=t.at(i)+'0';
    }
    sort(S,S+s.size());
    sort(T,T+t.size(),greater<>());
    
    rep(i,0,s.size()){
        s.at(i)=S[i]-'0';
    }
    rep(i,0,t.size()){
        t.at(i)=T[i]-'0';
    }
    if(s<t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    

}

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

int gcd(int a, int b) {
  int tmp;
  while ( a%b != 0 ) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

int main() {
  int n;
  cin >> n;
  int a[n];
  for ( int i = 0; i < n; i++ ) { cin >> a[i]; }
  
  int ans = a[0];
  for ( int i = 1; i < n; i++ ) { ans = gcd(ans, a[i]); }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;

void solve()
{ll t,n,m,x,y,z,d,p=0,b=0,q,l=INT_MAX,k,mini=0,prev;
  cin>>n>>k;
  vector<ll> v(n+1,0),dp(n+1,INT_MAX);
  for(ll i=1;i<=n;i++)
  cin>>v[i];
  dp[0]=0;
  dp[1]=0;

  		for(ll j=1;j<=n;j++)
  		{
  			for(ll r=1;r<=k&&(j-r)>=1;r++)
  			dp[j]=min(dp[j],dp[j-r]+abs(v[j]-v[j-r]));
		}
  
  cout<<dp[n]<<" ";

}

int main()
{

ll t=1;

while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

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

int main() {
	string s1,s2;
	cin >> s1 >> s2;
	if((s1[0]==s2[2])&&(s1[1]==s2[1])&&(s1[2]==s2[0])){
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
	return 0;
}

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

ll mod = 1000000007;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int ans = 1;
    int n,a;
    int s[100003] = {};
    Scd(n);
    Rep(i,n){
        Scd(a);
        s[a]++;
    }

    int odd = n%2;
    Repe(i,n,1){
        if( i%2 != odd ){
            if( s[i] == 2 ){
                ans = ans * 2 % mod;
            }else{
                ans *= 0;
            }
        }
    }

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

    return 0;
}



Measured memory_bytes: 640
n=int(input())
l=['AC','WA','TLE','RE']
d=[0,0,0,0]
for i in range(n):
    s=input()
    if(s=='AC'):
        d[0]+=1
    elif(s=='WA'):
        d[1]+=1
    elif(s=='TLE'):
        d[2]+=1
    else:
        d[3]+=1
for i in range(4):
    print(l[i],'x',d[i])


Measured memory_bytes: 74868
def comb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n, k = map(int, input().split())
i = 1
for i in range(1, k+1):
  if n - k + 1 >= i:
    print((comb(n - k + 1, i, mod) * comb(k-1, i-1, mod) ) % mod)
  else:
    print(0)

Measured memory_bytes: 68560
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, p, res = 0;
    cin>>n;
    int mn = INF;
    rep(i, n) {
        cin>>p;
        if(mn >= p) res++;
        chmin(mn, p);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	ans := a + b
	if ans < a - b {
		ans = a - b
	}
	if ans < a * b {
		ans = a * b
	}
	fmt.Println(ans)
}

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

int main() {
  string str ;
  cin >> str ;
  
  string a ;
  
  for(int i=0; i<str.size(); i++){
    if(str.at(i)=='0'){
      a.push_back('0');
    }
    
    else if(str.at(i)=='1'){
      a.push_back('1');
    }
    
    else if(str.at(i)=='B'&&a.size()!=0){
      a.pop_back();
    }
  }
  
  cout << a <<endl ;

  
  
}

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

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::array<int, 4> ns;
  for (auto& n : ns) {
    std::cin >> n;
  }
  std::sort(ns.begin(), ns.end());
  if (ns[0] == 1 && ns[1] == 4 && ns[2] == 7 && ns[3] == 9) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (){
	int a;
	long long int jumlah = 0;
	scanf ("%d", &a);
	for (int i = 1; i<=a; i++){
		if (i%3 == 0 && i%5==0){
			continue;
		}else if (i%3==0){
			continue;
		}else if(i%5==0){
			continue;		
		}else{
			jumlah+=i;
		}
	}
	printf("%lld\n", jumlah);
	return 0;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  int x[N], tmp[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", x + i);
    tmp[i] = x[i];
  }

  sort(tmp, tmp + N);
  int l = tmp[N/2-1];
  int r = tmp[N/2];
  
  for (int i = 0; i < N; i++) {
    if (x[i] <= l) {
      cout << r << endl;
    } else {
      cout << l << endl;
    }
  }
  return 0;
}


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

using namespace std;


int main()

{

    int n,x,m;
    cin>>n>>x;
    vector<int>v;
    int sum=0,a=n;
    while(n--)
    {
        cin>>m;
        v.push_back(m);
        sum=sum+m;
    }
    sort(v.begin(),v.end());
    int rem=x-sum;
    int an=rem/v[0];
    cout<<an+a<<endl;
    return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector <int> a(n),h(100005,0);
    for(int i=0;i<n;i++){
        cin >> a[i];
        h[a[i]]++;
    }
    int ans=0;
    for(int i=1;i<100004;i++){
        ans=max(ans,h[i-1]+h[i]+h[i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
class priorityQueue {
  constructor() {
    this.keys = [];
    Number.prototype.parentIdx = function() { return Math.ceil(this/2 - 1); };
    Number.prototype.leftIdx = function() { return this * 2 + 1; };
    Number.prototype.rightIdx = function() { return this * 2 + 2; };
  }

  insert(key) { this.heapIncrease(this.keys.push(key) - 1); }

  heapIncrease(idx) {
    const keys = this.keys;
    for (let i=idx, p=idx.parentIdx(); i > 0 && keys[i] > keys[p]; i=p, p=i.parentIdx()) {
      keys[p] = [keys[i], keys[i] = keys[p]][0];
    }
  }

  extract() {
    const res = this.keys[0];
    this.keys[0] = this.keys.pop();
    this.maxHeapify(0);
    return res;
  }

  maxHeapify(idx) {
    const keys = this.keys, n = keys.length;
    const innerMaxHeapify = (i) => {
      let left, right, largest = i;
      left = i.leftIdx();
      right = i.rightIdx();
      if (left < n && keys[left] > keys[largest]) largest = left;
      if (right < n && keys[right] > keys[largest]) largest = right;
      if (largest != i) {
        keys[largest] = [keys[i], keys[i] = keys[largest]][0];
        innerMaxHeapify(largest);
      }
    };
    innerMaxHeapify(idx);
  }
}

(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n').slice(0, -1);
  const queue = new priorityQueue();
  let str = '';
  lines.forEach(function(cmd) {
    switch(cmd.charAt(0)) {
      case 'i': queue.insert(Number(cmd.split(' ')[1])); break;
      case 'e': str += `${queue.extract()}\n`; break;
    }
  });
  process.stdout.write(str);
})();




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

int main(){
    using namespace std;

    constexpr unsigned long N{200000}, register_length{100}, reg{N - register_length + 1}, one_reg{reg - 1};

    const auto& cmp = [](unsigned long i, unsigned long j, unsigned long k) -> void {
        cout << "< " << i << " " << j << " " << k << endl;
    };
    const auto& add = [](unsigned long i, unsigned long j, unsigned long k) -> void {
        cout << "+ " << i << " " << j << " " << k << endl;
    };
    const auto& set_one = [&cmp, &add]() -> void {
        add(0, 1, one_reg);
        cmp(2, one_reg, one_reg);
    };
    const auto& bit_and_add = [&cmp, &add](unsigned long i, unsigned long j, unsigned long k) -> void {
        add(i, j, reg);
        cmp(one_reg, reg, reg + 1);
        add(k, reg + 1, k);
    };
    const auto& binary_mul = [&add, &bit_and_add](unsigned long i, unsigned long i_len, unsigned long j, unsigned long j_len, unsigned long k) -> void {
        for(unsigned long itr{0}; itr < i_len + j_len - 1; ++itr){
            if(itr)add(k, k, k);
            for(unsigned long jtr{0}; jtr <= itr; ++jtr)if(jtr < j_len && jtr + i_len > itr)bit_and_add(i + itr - jtr, j + jtr, k);
        }
    };
    const auto& int_to_bin = [&cmp, &add](unsigned long idx, unsigned long i, unsigned long len, unsigned long j) -> void {
        for(unsigned long itr{0}; itr < len; ++itr){
            if(itr)add(j + itr - 1, j + itr - 1, j + itr);
            add(j + itr, one_reg, j + itr);
            for(unsigned long jtr{itr}; jtr + 1 < len; ++jtr)add(j + jtr, j + jtr, j + jtr + 1);
            cmp(j + len - 1, idx, i + itr);
            add(j + itr - 1, j + itr - 1, j + itr);
            add(j + itr, i + itr, j + itr);
        }
    };

    cout << 3930 << endl;
    set_one();
    add(0, one_reg, 3);
    add(1, one_reg, 4);
    int_to_bin(3, 100, 30, 130);
    int_to_bin(4, 130, 30, 230);
    binary_mul(100, 30, 130, 30, 2);
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm> //min
typedef long long ll;

using namespace std;

int main() {

	ll L, R; //範囲が
	cin >> L >> R;

	//余りは最大でも2018
	int mod_min = 2018;

	//余りは2019周期でパターンが同じなのでRの範囲を縮める
	R = min(R, L + 4038);

	for (ll i = L; i < R; i++)
	{
		for (ll j = i + 1; j <= R; j++)
		{

			int mod = (i * j) % 2019;
			//cout << mod << "\n";

			mod_min = min(mod_min, mod);
			//if (mod < mod_min) {
			//	mod_min = mod;
			//}
		}
	}

	cout << mod_min << endl;

	return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d%d", &a, &b);
    if( a > b ){
        printf("a > b\n");
    }else if( a < b ){
        printf("a < b\n");
    }else{
        printf ("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
/*
* @Author: _dp95
* @Date:   2019-07-01 22:07:39
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

double dp[ MAX ] ;

int main( ){
  timesaver ;
  int n ;
  cin >> n ;
  dp[ 0 ] = 1 ;
  for( int i = 0 ; i < n ; i++ ){
    double coin ;
    cin >> coin ;
    for( int j = i + 1 ; j >= 0 ; j-- ){
        if( j == 0 )
            dp[ j ] = dp[ j ] * ( 1 - coin ) ;
        else
            dp[ j ] = dp[ j - 1 ] * coin + dp[ j ] * ( 1 - coin ) ;
    }
  }
  double ans = 0 ;
  for( int i = 0 ; i <= n ; i++ ){
    int tail = n - i ;
    if( tail < i ){
        ans += dp[ i ] ;
    }
  }
  deci( 10 ) ;
  cout << ans << nl ;
}

Measured memory_bytes: 256
"""
author : dokueki
1000 8
1 3 4 5 6 7 8 9
"""
def check(x,arr):
    c=0
    s = [int(i) for i in str(x)]
    for i in s:
        if i in arr:
            c+=1
    if c==len(s):
        return True
    return False


n, k = map(int, input().split())
a = list(map(int, input().split()))
use,f = [],0
for i in range(0, 10):
    if i not in a:
        use.append(i)
#print(use)
paid = [int(i) for i in str(n)]
for i in paid:
    if i in use:
        f+=1
if f==len(paid):
    print(n)
else:
    while True:
        n+=1
        if check(n,use)==True:
            print(n)
            break


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

int main(){
  int H,N;
  cin >> H >> N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i) >> B.at(i);
  }
  const int64_t INF=1e9;
  vector<int64_t> dp(H+1, INF);
  dp.at(0)=0;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=H;j++){
      if(j>=A.at(i-1)){
        dp.at(j)=min(dp.at(j),dp.at(j-A.at(i-1))+B.at(i-1));
      }else{
        dp.at(j)=min(dp.at(j),(int64_t)B.at(i-1));
      }
    }
  }
  cout << dp.at(H) << endl;
  return 0;
}


Measured memory_bytes: 3716
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }

    let ans = a.into_iter().fold(1u64, |s, a| s.saturating_mul(a));

    if ans > 10u64.pow(18) {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 4488
N, Q = map(int, input().split())
S = str(input())
LR = []
for i in range(Q):
    LR.append(list(map(int, input().split())))

num_list = []
cnt = 0
for i in range(N-1):
    if S[i:i+2] == 'AC':
        cnt += 1
    num_list.append(cnt)

for i in range(Q):
    if LR[i][0] == 1:
        l = 0
    else:
        l = num_list[LR[i][0]-2]
    if LR[i][1] == N:
        r = num_list[N-2]
    else:
        r = num_list[LR[i][1]-2]
    print(r-l)

Measured memory_bytes: 30992
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	String[] str=line.split(" ");
            	int a=Integer.parseInt(str[0]);
            	int b=Integer.parseInt(str[1]);
            	int c=Integer.parseInt(str[2]);
            	if(a<b&&b<c){
            		System.out.println("Yes");
            	}else{
            		System.out.println("No");
            	}
            	
            	break;
            }
        }
    }
}

Measured memory_bytes: 24276
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n;
	cin >> n;
	int m = n / 2;
	if (n % 2 == 1)m++;
	cout << (double)m / n << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll n, a, b; cin >> n >> a >> b;
    if ((b - a) % 2 == 0)cout << (b - a) / 2 << "\n";
    else {
        ll x = a, y = b;
        ll ans = 0, sum = 0;
        ans += a;
        b -= a;
        ans += b / 2;


        sum += n - y + 1;
        x += n - y + 1;
        sum += (n - x) / 2;

        cout << min(ans, sum) << "\n";
    }
}


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

int main() {
  int n;
  string s,t,u;
  cin >> n >> s >> t;
  rep(i,n) cout << s[i] << t[i];
  cout << endl;
  return 0;
}


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

int main() {
  int n;
  cin>>n;
  double x;string u;
  double ans = 0;
  rep(i,n){
    cin>>x>>u;
    if(u == "JPY") ans += x;
    if(u == "BTC") ans += x * 380000.0;
  }
  cout<<setprecision(10)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DB double
#define LL long long

#define MST(a,b) memset((a),(b),sizeof(a))
#define MRK() cout<<"Mark"<<endl;
#define WRT(x) cout<<#x<<" = "<<(x)<<endl;

#define MAXN 210000
#define MAXM 410000
#define MOD 998244353
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-5

#define _ 0
using namespace std;

int gcd(int x,int y)
{
	if (!y)
		return x;
	return gcd(y,x%y);
}

int n;
int mx;
int x;
int k;
int gc;

int main()
{
	cin>>n>>k;
	for (int i=0;i<n;i++)
	{
		scanf("%d",&x);
		mx=max(mx,x);
		gc=gcd(gc,x);
	} 
	if (mx<k)
	{
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	if (k%gc)
	{
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	cout<<"POSSIBLE"<<endl;
	
	return ~~(0^_^0);
}



Measured memory_bytes: 384
import java.util.Scanner;

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

		int[] t = new int[sc.nextInt()];

		int sum = 0;
		for (int i = 0; i < t.length; i++) {
			sum += t[i] = sc.nextInt();
		}

		int m = sc.nextInt();
		for (int i = 0; i < m; i++) {
			int p = sc.nextInt(), x = sc.nextInt();
			System.out.println(sum - (t[p - 1] - x));
		}
		sc.close();
	}
}

Measured memory_bytes: 21716
l = input()

dp = [[0 for i in range(2)] for j in range(len(l)+1)]

mod = 10**9+7

dp[0][0] = 1

for i in range(len(l)):
    #a+b=0
    if l[i] == '0':
        dp[i+1][0] += dp[i][0]
        dp[i+1][0] %= mod
        dp[i+1][1] += dp[i][1]
        dp[i+1][1] %= mod
    else:
        dp[i+1][1] += (dp[i][0] + dp[i][1])%mod
        dp[i+1][1] %= mod
    #a+b=1
    if l[i] == '0':
        dp[i+1][1] += (dp[i][1] * 2) %mod
        dp[i+1][1] %= mod
    else:
        dp[i+1][0] += (dp[i][0] * 2)%mod
        dp[i+1][0] %= mod
        dp[i+1][1] += (dp[i][1]*2)%mod
        dp[i+1][1] %= mod
        
print((dp[len(l)][0]+dp[len(l)][1])%mod)
#print(dp)

Measured memory_bytes: 21196
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

typedef pair<int, int> P;

const int INF = 1e9;
const int di[] = { -1,0,1,0 };
const int dj[] = { 0,1,0,-1 };

int main() {
	int h, w; cin >> h >> w;
	vector<string>s(h);
	for (int i = 0; i < h; i++)cin >> s[i];
	int ans = 0;
	for (int si = 0; si < h; si++)for (int sj = 0; sj < w; sj++) {
		if (s[si][sj] == '#')continue;
		vector<vector<int>>dist(h, vector<int>(w, INF));
		queue<P>q;
		auto update = [&](int i, int j, int x) {
			if (dist[i][j] != INF)return;
			dist[i][j] = x;
			q.push(P(i, j));
		};
		update(si, sj, 0);
		while (!q.empty()) {
			int i = q.front().first;
			int j = q.front().second;
			q.pop();
			for (int dir = 0; dir < 4; dir++) {
				int ni = i + di[dir], nj = j + dj[dir];
				if (ni < 0 || ni >= h || nj < 0 || nj >= w)continue;
				if (s[ni][nj] == '#')continue;
				update(ni, nj, dist[i][j] + 1);
			}

		}
		for (int i = 0; i < h; i++)for (int j = 0; j < w; j++) {
			if (dist[i][j] == INF)continue;
			ans = max(ans, dist[i][j]);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main()
{
  string s;
  cin >> s;
  REP(i, s.size())
  {
    if ((i + 1) % 2 == 1)
    {
      if (s[i] == 'L')
      {
        cout << "No" << endl;
        return 0;
      }
    }
    else
    {
      if (s[i] == 'R')
      {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

// Main Code

vector<int> a;
vector<vector<int>> dp;

int rec(int idx, int t) {
    if (dp[idx][t] != -1) return dp[idx][t];
    if (!t) {
        int res = -1;
        rng(i, idx + 1, sz(a)) {
            if (i == sz(a) - 1) chmax(res, abs(a[idx] - a[i]));
            else chmax(res, rec(i, 1));
        }
        return dp[idx][t] = res;
    } else {
        int res = inf;
        rng(i, idx + 1, sz(a)) {
            if (i == sz(a) - 1) chmin(res, abs(a[idx] - a[i]));
            else chmin(res, rec(i, 1));
        }
        return dp[idx][t] = res;
    }
}

int main() {
    int n, z, w;
    cin >> n >> z >> w;
    a.pb(z);
    a.pb(w);
    rep(i, n) {
        int a_;
        cin >> a_;
        a.pb(a_);
    }
    
    dp = vector<vector<int>>(n + 1, vector<int>(2, -1));
    cout << rec(1, 0) << "\n";
    return 0;
}


Measured memory_bytes: 3892
#include <bits/stdc++.h>
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef long long int64;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
template<class T,class U>bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>void vcin(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    VI vi;
    cii(n);
    vcin(vi, n);
    int ans = 0;
    rep(i, n-1){
        for (int j = i + 1; j < n; ++j) {
            ans += vi[i] * vi[j];
        }
    }
    co(ans);
    return 0;
}

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

int main(){
    long long a,b,c=0;
    cin>>a;
    a=a%10;
    if(a==2 || a==4 || a==5 || a==7 || a==9){cout<<"hon";return 0;}
    if(a==0 || a==1 || a==6 || a==8){cout<<"pon";return 0;}
    if(a==3){cout<<"bon";}
    return 0;
}


Measured memory_bytes: 3552