akhauriyash/Code-Regression huggingface dataset:
k = list(map(int, input().split() ) )
t = 1
while k[0] > 0 and k[2] > 0:
  if t == 1:
    k[2] -= k[1]
    t=2
  else:
    k[0] -= k[3]
    t=1
if t==2:
  print("Yes")
else:
  print("No")

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

//a^b % MOD
long long mod_pow(ll a,ll b){
	long long ret = 1;
	long long c = a;
	for(int i = 0;i <= 60;i++){
		if(b & (1LL << i))ret = (ret * c) % MOD;
		c = (c * c) % MOD;
	}
	return ret;
}

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

#define MAX_K 333333
vector<long long> fact(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(fact[0] != 1){
		fact[0] = 1;
		for(long long i = 1;i < MAX_K;i++)fact[i] = (fact[i-1] * i) % MOD;
	}
    long long ret = fact[n];
	long long tmp = (fact[r] * fact[n-r]) % MOD;
    return mod_div(ret,tmp);
}

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

	ll n;cin >> n;
	vector<ll> v(n);REP(i, n)cin >> v[i];

	sort(ALL(v), greater<ll>());
	ll ans = 0;
	REP(i, n){
		ll cou = (mod_pow(2, (n - 1)) + mod_pow(2, (n - 2)) * i % MOD) % MOD;
		ans += cou * v[i] % MOD;
		ans %= MOD;
	}

	ans = ans * mod_pow(2, n) % MOD;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	if (A > 9 || B > 9 || A <= 0 || B <= 0) cout << "-1" << endl;
	else cout << A * B << endl;
 }

Measured memory_bytes: 256
from collections import Counter

n, m = map(int, input().split())

MOD = 10 ** 9 + 7

# 素因数分解
power = []
p = 2
mm = m # m をあとで使うので
while mm > 1:
    if mm % p == 0:
        while True:
            if mm % p != 0:
                break
            power.append(p)
            mm //= p
    p += 1

# コンビネーション計算用
fact = [0] * 1100000
invfact = [0] * 1100000

fact[0] = 1
for i in range(1, 1100000):
    fact[i] = fact[i - 1] * i % MOD

# fermat
invfact[1100000 - 1] = pow(fact[1100000 - 1], MOD - 2, MOD)

for i in range(1100000 - 1, 0, -1):
    invfact[i - 1] = invfact[i] * i % MOD

def comb(n, k):
    return fact[n] * invfact[k] * invfact[n - k] % MOD

if m == 1:
    print(1)
else:
    res = 1
    c = Counter(power)
    for k, v in c.items():
        res *= comb(v + n - 1, n - 1)
        res %= MOD
    print(res)


Measured memory_bytes: 85068
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;
template <class T, class U>
void chmin(T& t, const U& u) {
  if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
  if (t < u) t = u;
}

int main(void) {
  int N;
  cin >> N;
  int res = 0;
  for (int i = 1; i <= N; i += 2) {
    int cnt = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) ++cnt;
    }
    if (cnt == 8) ++res;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3624
class NormalInput {
  input: string[];
  pointer: number;
  constructor(raw: string) {
    this.input = raw.split(/ |\n/);
    this.pointer = 0;
  }
  int = (): number => {
    const ret = parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  };
  str = (): string => {
    const ret = this.input[this.pointer];
    this.pointer++;
    return ret;
  };
  strs = (length: number): string[] => {
    let ret: string[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.str());
    }
    return ret;
  };
  ints = (length: number): number[] => {
    let ret: number[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.int());
    }
    return ret;
  };
}
function order(N, K) {
  if (N < 1) return 0;
  else return 1 + order(Math.floor(N / K), K);
}
function Main({ int, str, strs, ints }: NormalInput) {
  const N = int();
  const K = int();

  console.log(order(N, K));
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define VI vector<int>
#define PII pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
#define out(x) cout<<(#x)<<" = "<<x<<endl
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x){return mrand()%x;}
clock_t ac; double TLE(){return (double)(clock()-ac)/CLOCKS_PER_SEC;}

int main(){
 ios::sync_with_stdio(0);
 cin.tie(0);
 int n;
 cin>>n;
 ll u=0;
 for(ll i=1;i<=n;i++){
 	ll c=0;
 	int h = (int)sqrt(i);
 	for(int j=1;j<=h;j++){
      for(int k=j;k<=h;k++){
      	for(int m=k;m<=h;m++){
      	    u = (k*k)+(m*m)+(j*j)+(j*m)+(j*k)+(k*m);
      		if(u==i){
                   if(k==j&&k==m&&m==j){
                        c++;
                   }
      		 else if(k==j||k==m||m==j){
      			c+=3;
      		 }
      		 else{
      		 	c+=6;
      		 }
      		}
      	}
      }
 	}
 	cout<<c<<"\n";
 }
}


Measured memory_bytes: 3608
i=input
n=int(i())
a=eval('[i().split()for _ in"_"*int(i())],'*n)
print(max(all(int(y)==i>>int(x)-1&1for j,t in enumerate(a)if i>>j&1for x,y in t)*bin(i).count('1')for i in range(2**n)))

Measured memory_bytes: 3060
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    int j;
    cin>>j;
    if(i%2==1 && j%2==1)ans++;
  }
  cout<<ans<<endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
#define inf 1e9+7

int main() {

	ll	n, weight;
	cin >> n >> weight;

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


	ll maxV = n * 1000;
	ll ans[n + 1][maxV + 1];

	memset(ans, 0, sizeof(ans));


	for (int i = 0; i <= maxV; i++)
		ans[1][i] = inf;
	ans[1][0] = 0;
	ans[1][v[1]] = w[1];



	for (int i = 2; i <= n; i++) {
		for (int j = 1; j <= maxV; j++) {
			ans[i][j] = ans[i - 1][j];
			if (v[i] <= j) {
				ans[i][j] = min(ans[i][j], ans[i - 1][j - v[i]] + w[i]);
			}
		}
	}

	int lastans = 0;
	for (int i = 0; i <= maxV; i++) {
		if (ans[n][i] <= weight) {
			lastans = i;
		}
	}

	cout << lastans << endl;
	return 0;

}

Measured memory_bytes: 82480
#include<stdio.h>

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

int X[N][N];

void initialize();
void printBoard();
void recursive(int i);

int main(void)
{
  int i,j,k;
  int r,c;
  
  initialize();

  for(i=0;i<N;i++)
    {
      for(j=0;j<N;j++)
	{
	  X[i][j]=0;
	}
    }

  scanf("%d",&k);

  for(i=0;i<k;i++)
    {
      scanf("%d%d",&r,&c);

      X[r][c]=1;
    }

  recursive(0);
}

void initialize()
{
  int i;
  
  for(i=0;i<N;i++)
    {
      row[i]=FREE;
      col[i]=FREE;
    }

  for(i=0;i<2*N-1;i++)
    {
      dpos[i]=FREE;
      dneg[i]=FREE;
    }
}

void printBoard()
{
  int i,j;
  
  for(i=0;i<N;i++)
    {
      for(j=0;j<N;j++)
	{
	  if(X[i][j])
	    {
	      if(row[i]!=j)
		{
		  return;
		}
	    }
	}
    }

  for(i=0;i<N;i++)
    {
      for(j=0;j<N;j++)
	{
	  printf("%s",(row[i]==j)?"Q":".");
	}
      
      putchar('\n');
    }
}

void recursive(int i)
{
  int j;
  
  if(i==N)
    {
      printBoard();
	  
      return;
    }

  for(j=0;j<N;j++)
    {
      if(NOT_FREE==col[j]||NOT_FREE==dpos[i+j]||NOT_FREE==dneg[i-j+N-1])
	{
	  continue;
	}

      row[i]=j;
      col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;

      recursive(i+1);

      row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
    }
}



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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define MAXN 10013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N;
array<int, 3> arr[MAXN];
ll dp[MAXN];
ll ans;

bool cmp(array<int, 3> a, array<int, 3> b)
{
	return a[0] + a[1] < b[0] + b[1];
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	FOR(i, 0, N)
	{
		cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
	}
	//weight, solidness, value
	//when do you want to swap two guys? x + weight[i] > solid[j] => weight[i] - solid[j] > x x + weight[j] < solid[i], weight[i
	sort(arr, arr + N, cmp);
	//dp[weight] maximum value you can get!
	FOR(i, 0, N)
	{
		// cerr << arr[i][0] << endl;
		FORD(j, arr[i][1] + 1, 0)
		{
			ckmax(ans, dp[j] + arr[i][2]);
			if (j + arr[i][0] >= MAXN) continue;
			ckmax(dp[j + arr[i][0]], dp[j] + arr[i][2]);
		}
		// FOR(j, 0, 10)
		// {
		// 	cerr << dp[j] << ' ';
		// }
		// cerr << endl;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 384
from fractions import gcd


def lcm(x, y):
    return (x * y) // gcd(x, y)


a, b, c, d = map(int, input().split())
count = b-a+1

div_c = b//c - (a-1)//c
div_d = b//d - (a-1)//d
cd = lcm(c, d)
div_cd = b//cd - (a-1)//cd

count -= div_c + div_d - div_cd
print(count)


Measured memory_bytes: 5076
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
const int INF = 0x3f3f3f3f;
const int maxn = 1e2 + 7;
const int mod = 1e9 + 7;

LL exp_mod(LL a, LL b, LL p)
{
	LL res = 1;
	while (b != 0)
	{
		if (b & 1) res = (res * a) % p;
		a = (a*a) % p;
		b >>= 1;
	}
	return res;
}

//C(n,m)=n!/(m!*(n-m)!)=n!*qpow(m!*(n-m)!,MOD-2)%MOD
LL Comb(LL a, LL b, LL p)
{
	if (a < b)   return 0;
	if (a == b)  return 1;
	if (b > a - b)   b = a - b;

	LL ans = 1, ca = 1, cb = 1;
	for (LL i = 0; i < b; ++i)
	{
		ca = (ca * (a - i)) % p;//n!/(n-m)!
		cb = (cb * (b - i)) % p;//m!
	}
	ans = (ca*exp_mod(cb, p - 2, p)) % p;
	return ans;
}

LL Lucas(int n, int m, int p)
{
	LL ans = 1;
	while (n&&m&&ans)
	{
		ans = (ans*Comb(n%p, m%p, p)) % p;
		n /= p;
		m /= p;
	}
	return ans;
}


int main() {
    int x,y;
    while(~scanf("%d%d",&x,&y)) {
        if((x + y) % 3 != 0) printf("0\n");
        else {
            int n = (2 * y - x) / 3;
            int m = (2 * x - y) / 3;
            if(n < 0 || m < 0 || (2 * y - x) % 3 != 0 || (2 * x - y) % 3 != 0) {
                printf("0\n");
            } else {
                printf("%lld\n",Lucas(n+m,n,mod));
            }
        }
    }
    return 0;
}


Measured memory_bytes: 384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::min;

fn main() {
    input!{
        n: usize,
        v: [i64; n]
    }
    let s: i64 = v.iter().sum();
    let mut ans = s;
    let mut t = 0;
    for i in 0..n {
        t += v[i];
        ans = min(ans, (s - 2 * t).abs());
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define N 101
using namespace std;
int h,w,A;
string mp[101];
int dx[]={0,0,1,-1};//V^><
int dy[]={1,-1,0,0};

int ans=1e9,used[101][101][10][10][4];
void dfs(int x,int y,int p,int q,int dir){
  int &u=used[x][y][p][q][dir];
  if(ans<=2*A-(p+q)||(u!=-1&&u<=2*A-(p+q)))return;
  u=2*A-(p+q);
  
  vector<int> X,Y,ch;
  while(1){
    x+=dx[dir];
    y+=dy[dir];
    if(x<0||y<0||x>=w||y>=h||mp[y][x]=='#')break;
    if(mp[y][x]=='S')continue;
    if(mp[y][x]=='G')ans=min(ans,2*A-(p+q));
    X.push_back(x);
    Y.push_back(y);
    ch.push_back(mp[y][x]);
    mp[y][x]='#';
    if(p){
      if(dir==0)dfs(x,y,p-1,q,2); //>
      if(dir==1)dfs(x,y,p-1,q,3); //<
      if(dir==2)dfs(x,y,p-1,q,0); //V
      if(dir==3)dfs(x,y,p-1,q,1); //^
    }
    if(q){
      if(dir==0)dfs(x,y,p,q-1,3); //>
      if(dir==1)dfs(x,y,p,q-1,2); //<
      if(dir==2)dfs(x,y,p,q-1,1); //^
      if(dir==3)dfs(x,y,p,q-1,0); //V
    }
  }
  for(int i=0;i<X.size();i++)mp[Y[i]][X[i]]=ch[i];
}

int main(){
  cin>>h>>w>>A;
  for(int i=0;i<h;i++)cin>>mp[i];

  memset(used,-1,sizeof(used));
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(mp[i][j]=='S')dfs(j,i,A,A,0);

  cout<<(ans==1e9? -1:ans)<<endl;
  return 0;
}

Measured memory_bytes: 19172
import sys
import heapq

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)

N = ini()
A = inl()
assert len(A) == N


def solve():
    if N == 1:
        return True
    asum = sum(A)
    k = N * (N + 1) // 2
    if asum % k != 0:
        return False
    t = asum // k  # how many times we operate

    B = [None] * N
    for i in range(N - 1):
        B[i] = A[i + 1] - A[i]
    B[N - 1] = A[0] - A[N - 1]
    if sum(B) != 0:
        return False
    bmax = max(B)
    B.sort()
    s = 0
    for b in B:
        if (bmax - b) % N != 0:
            return False
        s += (bmax - b) // N
    return s == t


print("YES" if solve() else "NO")


Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
using llong = long long;

void fnInput(int& rnMaxNum)
{
  cin >> rnMaxNum;
}

llong fnToInt(const vector<char>& cnrvcNum)
{
  const vector<int> cnvnDgt = {0, 3, 5, 7};
  llong nRtn = 0;
  int nNumPos = 0;

  for (int i = cnrvcNum.size() - 1; i >= 0; i--)
  {
    if (cnrvcNum[i] == '0') break;
    nRtn += cnvnDgt[ cnrvcNum[i] - '0' ] * pow(10.0, nNumPos++);
  }

  return nRtn;
}

int fnDgt753_Check(const vector<char>& cnrvcNum)
{
  int nDgt3 = 0, nDgt5 = 0, nDgt7 = 0;

  for (int i = 0; i < cnrvcNum.size(); i++)
    if      (cnrvcNum[i] == '1') nDgt3++;
    else if (cnrvcNum[i] == '2') nDgt5++;
    else if (cnrvcNum[i] == '3') nDgt7++;

  if (nDgt3 && nDgt5 && nDgt7)
    return 1;
  else
    return 0;
}

int fnDgt753_Count(int nMaxNum)
{
  int nDgt753Cnt = 0;
  int nDgtSiz = to_string(nMaxNum).size();
  vector<char> vcNum(nDgtSiz + 1, '0');

  while (fnToInt(vcNum) <= nMaxNum) 
  {
    if (fnDgt753_Check(vcNum)) nDgt753Cnt++;

    vcNum[vcNum.size() - 1]++;
    for (int i = vcNum.size() - 1; i > 0; i--)
      if (vcNum[i] > '3')
      {  
        vcNum[i - 1]++;
        vcNum[i] = '1';
      }
      else
        break;
  }

  return nDgt753Cnt;
}

int main()
{
  int nMaxNum;

  fnInput(nMaxNum);
  cout << fnDgt753_Count(nMaxNum) << endl;

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

using namespace std;
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    if(m==n)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    char ch = getchar(); ll x = 0, f = 1;
    while(ch < '0' || ch > '9') {
        if(ch == '-') f = -1;
        ch = getchar();
    } while('0' <= ch && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    } return x * f;
}
const int kcz=1000000007;
#define jia(a,b) a+=b;if (a>=kcz) a-=kcz
const int maxn=3005;
int n,m,f[maxn][maxn][2];
int main(){
	n=read();m=read();f[0][0][1]=1;	
	for (int i=1;i<=n;i++) f[0][i][0]=1;
	for (int i=0;i<m;i++)
	for (int j=0;j<=n;j++)
	for (int k=0;k<=1;k++)
	if (f[i][j][k])
	{
		if (j) {jia(f[i+1][j-1][k|(j==1)],f[i][j][k]);}
		if (n-j) {jia(f[i+1][j+1][k],f[i][j][k]);}
		if (j){jia(f[i+1][j][k|(j==1)],f[i][j][k]);}
		if (n-j) {jia(f[i+1][j][k],f[i][j][k]);}
	}
	int ans=0;
	for (int i=0;i<=n;i++)
	{	jia(ans,f[m][i][1]);} 
	printf("%d\n",ans);
}
		

Measured memory_bytes: 70656
#include<iostream>
#include<vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {

    int d, g; cin >> d >> g;
    vector<int> p(d), c(d);
    rep(i, d) cin >> p[i] >> c[i];

    int ans = 1e9;

    rep(mask, 1<<d) {
        int sum = 0, cnt = 0, num = -1;

        rep(i, d){
            if(mask & 1<<i){
                sum += (i+1) * 100 * p[i] + c[i];
                cnt += p[i]; 
            }
            else num = i;
        }

        if (sum < g) {
            int n = (num+1) * 100;
            int tmp = (g - sum + n - 1) / n ;
            if (tmp >= p[num]) continue;
            cnt += tmp;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

import static java.lang.Integer.parseInt;

/**
 * Brave Force Story
 */
public class Main {

	static final int MAX = 30;
	static final int[] H = new int[]{1, 1, 0, -1, -1, 0};
	static final int[] V = new int[]{1, 0, -1, -1, 0, 1};

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		Main main = new Main();

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int t, n;
			t = parseInt(line.substring(0, line.indexOf(' ')));
			n = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((t | n) == 0) break;

			boolean[][][] obs = new boolean[4][MAX * 3][MAX * 3];
			for (int i = 0; i < n; i++) {
				line = br.readLine();
				int x, y;
				int[] q;
				x = parseInt(line.substring(0, line.indexOf(' ')));
				y = parseInt(line.substring(line.indexOf(' ') + 1));
				q = quadrant(x, y);
				obs[q[0]][q[1]][q[2]] = true;
			}

			line = br.readLine();
			int sx, sy;
			int[] sq;
			sx = parseInt(line.substring(0, line.indexOf(' ')));
			sy = parseInt(line.substring(line.indexOf(' ') + 1));
			sq = quadrant(sx, sy);

			Deque<int[]> queue = new ArrayDeque<>();
			int count = 0;

			queue.offer(new int[]{0, sq[0], sq[1], sq[2]});
			obs[sq[0]][sq[1]][sq[2]] = true;
			count++;

			while (!queue.isEmpty()) {
				int[] pq = queue.poll();
				int[] p = dequadrant(pq[1], pq[2], pq[3]);
				for (int i = 0; i < H.length; i++) {
					int nx, ny;
					int[] nq;
					nx = p[0] + H[i];
					ny = p[1] + V[i];
					nq = quadrant(nx, ny);
					if (pq[0] < t && !obs[nq[0]][nq[1]][nq[2]]) {
						queue.offer(new int[]{pq[0] + 1, nq[0], nq[1], nq[2]});
						obs[nq[0]][nq[1]][nq[2]] = true;
						count++;
					}
				}
			}
			System.out.println(count);
		}//end while
	}//end main

	//quadrant I:    x >= 0, y >= 0
	//quadrant II:   x <  0, y >= 0
	//quadrant III:  x <  0, y <  0
	//quadrant IV:   x >= 0, y <  0
	static int[] quadrant(int x, int y) {
		int o = 0;
		if (0 <= x && 0 <= y) {
			o = 0;
		} else if (x < 0 && 0 <= y) {
			o = 1;
		} else if (x < 0 && y < 0) {
			o = 2;
		} else {
			o = 3;
		}
		x = Math.abs(x);
		y = Math.abs(y);
		return new int[]{o, x, y};
	}

	static int[] dequadrant(int o, int x, int y) {
		if (o == 1) {
			x = -x;
		} else if (o == 2) {
			x = -x;
			y = -y;
		} else if (o == 3) {
			y = -y;
		}
		return new int[]{x, y};
	}

	class Point {
		int x, y;
		int o, ox, oy;

		Point(int x, int y) {
			if (0 <= x && 0 <= y) {
				o = 0;
			} else if (x < 0 && 0 <= y) {
				o = 1;
			} else if (x < 0 && y < 0) {
				o = 2;
			} else {
				o = 3;
			}
			ox = Math.abs(x);
			oy = Math.abs(y);
		}

		Point(int o, int ox, int oy) {
			if (o == 1) {
				x = -x;
			} else if (o == 2) {
				x = -x;
				y = -y;
			} else if (o == 3) {
				y = -y;
			}
		}
	}
}

Measured memory_bytes: 65920
import queue
from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 9)

def main():
    N,M = [int(x) for x in input().split()]
    C = defaultdict(list)
    for _ in range(M):
        a,b = [int(x) for x in input().split()]
        C[a-1].append(b-1)
    
    # bfs
    q = queue.Queue()
    # ステップ数
    V = [0]*N
    V[0] = 0
    # 始点
    s = 0
    while True:
        # print(s)
        for u in C[s]:
            # print(u,V[u])
            if V[u] == 0:
                q.put(u)
                V[u] = V[s]+1 # ステップ数
        if q.empty() or V[N-1] > 0:
            break
        s = q.get()
    # print(V[N-1])
    
    if 0 < V[N-1] and V[N-1] <= 2:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 132116
#include <iostream>

using namespace std;

int main()
{
    int a,h,m,s;
    cin>>a;
    h=a/3600;
    m=(a%3600)/60;
    s=(a%3600)%60;
    cout<<h<<":"<<m<<":"<<s;
    cout<<"\n";
    return 0;
}



Measured memory_bytes: 3116
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//mint型にキャスト
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(int n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
int main(){
 init();
 int n;
 cin>>n;
 V<int> d(n+1,-1);
 int p;
 for(int i=0;i<n+1;i++){
   int a;cin>>a;
     if(d[a]==-1)d[a]=i;
     else{
        p=d[a]+n-i;
     }
 }
 for(int i=1;i<=n+1;i++){
   cout<<COM(n+1,i)-COM(p,i-1)<<"\n";
 }
}

Measured memory_bytes: 48512
fun main(args: Array<String>) {
    val INF = 1001001001
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val keys = mutableListOf<Pair<Int, Int>>()

    val ABC = Array(M) {

        val (A, B) = readLine()!!.split(" ").map(String::toInt)

        // 鍵の集合をBITで表す
        var s = 0
        readLine()!!.split(" ").map(String::toInt).forEach {
            val c = it - 1
            // 論理和で鍵の集合を計算する
            s = s or (1 shl c)
        }
        keys.add(s to A)
    }

    // BIT DP
    // 配るDP
    val dp = IntArray(1 shl N) { INF }

    dp[0] = 0
    for (s in 0 until (1 shl N)) {
        // 鍵
        for (k in keys) {
            // 鍵の組み合わせを論理和
            val t = s or k.first
            val cost = dp[s] + k.second
            dp[t] = Math.min(dp[t], cost)
        }
    }

    val ans = dp.last()
    if (ans == INF) {
        println(-1)
    } else {
        println(ans)
    }
}

Measured memory_bytes: 42576
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main(void){
  int a, b, c;
  cin >> a >> b >> c;
  if(a >= b + c){
    cout << 0 << endl;
    return 0;
  }
  cout << b + c - a << endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            long N = cin.ReadLong;
            long[] X= new long[N];
            long[] Y= new long[N];
            double ans = 0;
            for(long i = 0; i < N; i++)
            {
                long[] A = cin.ReadLongArray(2);
                X[i] = A[0];
                Y[i] = A[1];
            }
            for(long i = 0; i < N; i++)
            {
                for(long j = i + 1; j < N; j++)
                {
                    ans += Distance(X[i], Y[i], X[j], Y[j]);
                }
            }
            WriteLine(ans * 2 / N);
        }

        public double Distance(double x1,double y1,double x2,double y2)
        {
           return Sqrt(Pow((x1 - x2), 2) + Pow((y1 - y2), 2));
        }
    }  
            


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std ;

typedef long long ll ;
int N , M ;
int P [100010] , Y [100010];
vector <int> yd [100010];
int main (){
	scanf("%d%d",&N,&M);
	for (int i=0;i<M;i++){
      scanf("%d%d",&P[i],&Y[i]);
      yd[P[i]].push_back(Y[i]);
    }
  
	for (int i=0;i<N;i++)sort(yd[i+1].begin(),yd[i+1].end());
  
	for (int i=0;i<M;i++){
      long long int a = lower_bound(yd[P[i]].begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin()+1;
      printf ("%012lld\n",ll(P[i])*1000000+a);
    }
}


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

using namespace std;

int main(){
    int n, m, x, y, s = 0, _s, p;
    vector<int> vx, vy;

    cin >> n >> m;
    for(int i = 0; i < n + m; i++){
        cin >> x >> y;
        vx.emplace_back(x);
        vy.emplace_back(y);
    }

    for(int i = 0; i < n; i++){
        for(int j = n; j < n + m; j++){
            _s = abs(vx[i] - vx[j]) + abs(vy[i] - vy[j]);
            if(s > _s || j == n){
                s = _s;
                p = j - n + 1;
            }
        }
        cout << p << endl;
    }
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
using namespace std;
bool flag;
long long solve(const string s,long long I)
{
	//cout<<s<<" "<<I<<endl;
	long long cnt=0;
	for(int f=0;!flag&&f<s.size();f++)
	{
		if(s[f]>='A'&&s[f]<='Z')
		{
			while(!flag&&f<s.size()&&s[f]>='A'&&s[f]<='Z')
			{
				f++,cnt++;
				if(I==cnt)
				{
					cout<<s[f-1]<<endl;
					flag=true;
				}
			}
			f--;
		}
		else if(s[f]>='0'&&s[f]<='9')
		{
			long long now=0;
			while(s[f]>='0'&&s[f]<='9')now=now*10+s[f]-'0',f++;
			if(s[f]>='A'&&s[f]<='Z')
			{
				cnt+=now;
				if(I<=cnt&&!flag)
				{
					cout<<s[f]<<endl;
					flag=true;
				}
			}
			else
			{
				int l=f+1;
				int d=1;
				while(d)
				{
					if(s[l]=='(')d++;
					else if(s[l]==')')d--;
					l++;
				}
				l--;
				long long A=solve(s.substr(f+1,l-f-1),I-cnt);//(I-cnt+now-1)%now+1);
				if(I<=cnt+A*now&&!flag)
				{
					solve(s.substr(f+1,l-f-1),(I-cnt+A-1)%A+1);
				}
				cnt+=A*now;
				f=l;
			}
		}
	}	
	return cnt;
}
main()
{
	string s;long long I;
	while(cin>>s>>I,s!="0")
	{
		flag=false;
		solve(s,I+1);
		if(!flag)cout<<0<<endl;
	}
}



Measured memory_bytes: 3200
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        char[] s = in.ns().toCharArray();
        boolean[] alp = new boolean['z'-'a'+1];
        for(char c: s) alp[c-'a'] = true;
        String ans = "None";
        for (int i = 0; i < alp.length; i++) {
            if(!alp[i]){
                ans = String.valueOf((char)('a'+i));
                break;
            }
        }
        out.println(ans);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    int n;
    cin >> n;
    vector<int> v, v2;
    for (int i = 0; i < n; ++i) {
        int k;
        scanf("%d", &k);
        v.emplace_back(k); v2.emplace_back(k);
    }
    sort(v.begin(), v.end());

    if(v[n/2] != v[n/2-1]) for (auto &&x : v2) {
        if(lower_bound(v.begin(), v.end(), x)-v.begin() < n/2){
            cout << v[n/2] << "\n";
        }else {
            cout << v[n/2-1] << "\n";
        }
    }
    else for (int i = 0; i < n; ++i) cout << v[n/2] << "\n";
    return 0;
}


Measured memory_bytes: 3948
import java.util.Scanner;

public class Main{
	
	int tate;
	int yoko;
	
	public void solve(){
		Scanner sc=new Scanner(System.in);
		tate = sc.nextInt();
		yoko = sc.nextInt();
		
		int men=tate*yoko;
		int syu=(tate+yoko)*2;
		
		System.out.println(men+" "+syu);
	}
	
	public static void main(String[]args){
		Main obj=new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17156
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N;
  in<string> c;
  ll ws =0, rs = 0;
  for (auto i: c) {
    if (i=='W') ws++;
    else rs++;
  }
  
  ll l = 0, r = N-1, i = 0;
  for (;;) {
  while(l < N) {
    if (c[l] == 'W') break;
    l++;
  }
  while(r >= 0) {
    if (c[r] == 'R') break;
    r--;
  }
    if (l >= r)
      return i;
    else {
      swap(c[l], c[r]);
      i++;
    }
  }



  return 0LL;
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 3720
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextFloat64() float64 {
	sc.Scan()
	f, _ := strconv.ParseFloat(sc.Text(), 64)
	return f
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func expectedValue(x float64) float64 {
	s := (x + float64(1)) * (x / float64(2))
	return s / x
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()
	evs := make([]float64, n)
	for i := 0; i < n; i++ {
		p := nextFloat64()
		evs[i] = expectedValue(p)
	}

	// initialize
	var ev float64
	for i := 0; i < k; i++ {
		ev += evs[i]
	}

	maxEv := ev
	left := 0
	for i := k; i < n; i++ {
		ev = ev - evs[left] + evs[i]
		left++
		if ev > maxEv {
			maxEv = ev
		}
	}
	fmt.Printf("%0.7f\n", maxEv)
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
#endif

	int n;
	cin>>n;
	vector<int> a(n);
	map<int,int> st;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		st[a[i]]+=1;
	}

	int count=0;

	for(int i=0;i<n;i++)
	{
		bool flag=1;
		st[a[i]]--;
		for(int j=1;j<=sqrt(a[i]);j++)
		{
			if(a[i]%j==0)
			{
				if(st[j]!=0 || st[a[i]/j]!=0)
				{
					flag=0;
					break;
				}
			}
		}
		if(flag)
			count++;
		st[a[i]]++;
	}

	cout<<count<<endl;

	return 0;
}

Measured memory_bytes: 32900
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin >> a >> b >> c >>d;
    ll l = c*d/__gcd(c,d);
    ll ans = b - (b/c + b/d - b/l);
    ans -= (a-1) - ((a-1)/c + (a-1)/d - (a-1)/l);
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n,m;
  cin >> n >> m;
  ll ans=0;
  ll a = min(n,m);ll b = max(n,m);
  if(a==1&&b==1){
    ans ++;
  }else if(a==1){
    ans += b-2;
  }else{
    ans += (n-2)*(m-2);
  }
    

  cout << ans <<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll MAX = 1e4;

ll fac[MAX],finv[MAX],inv[MAX]; 

void COMinit(){
    fac[0]=fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2; i<MAX;i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod; 
    }
}

long long COM(int n, int k){
    if (n<k) return 0;
    if (n<0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}
 
int main() {
    COMinit();
    int n;
    ll ans = 0;
    cin >> n;
    for (int i=1; i<n;i++){
        ans = (ans+COM(n-3*i+i-1,i-1))%mod; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 3908
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip>
using namespace std;


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

	vector<double> v(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	sort(v.begin(), v.end());

	double ans = v[0];
	for(int i=1;i<n;i++){
		ans = (ans+v[i]) / 2;
	}
	cout << fixed << setprecision(6) << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int H, A, result = 0;
  cin >> H >> A;
  while (H > 0) {
    H -= A;
    result++;
  }
  cout << result << endl;
  return 0;
}


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

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

    int n;
    cin >> n;
    int sum = 0;
    rep(i, n) {
        int a;
        cin >> a;
        sum += a - 1;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
#!/usr/bin/env python
# coding: utf-8

N, A, B, C = list(map(int, input().split()))
ll = []
for _ in range(N):
    ll.append(int(input()))

def dfs(n, a, b, c):
    if n == N:
        if a == 0 or b == 0 or c == 0: return float('inf')
        return abs(A-a) + abs(B-b) + abs(C-c)
    ca = dfs(n+1, a+ll[n], b, c)
    if a > 0: ca += 10
    cb = dfs(n+1, a, b+ll[n], c)
    if b > 0: cb += 10
    cc = dfs(n+1, a, b, c+ll[n])
    if c > 0: cc += 10
    cn = dfs(n+1, a, b, c)
    return min(ca, cb, cc, cn)


def main():
    print(dfs(0, 0, 0, 0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;


long long int N, M, K, H, W, L, R;

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

	cin >> N;
	if (N == 0) cout << 1 << endl;
	else if (N == 1)cout << 2 << endl;
	else if (N == 2)cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3148
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265359
using namespace std;
 


int main()
{
    SYNC
    //clock_t tStart = clock();
    
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n; in(n);
    ll temp;
    vl v;
    set<ll>s;
    l(i,0,n)
    {
        in(temp);
        v.pb(temp);
        s.insert(temp);
    }
    if(s.size()<3)
    {
        o("0")<<endl;
        return 0;
    }
    ll count=0;
    sort(all(v));
    for(ll i=0; i<n-2; i++)
    {
        for(ll j=i+1; j<n-1; j++)
        {
            for(ll k=j+1; k<n; k++)
            {
                if(v[i]+v[j] > v[k] && v[i]!=v[j] && v[i]!=v[k] && v[j]!=v[k])
                {
                    count++;
                }
            }
        }
    }
    o(count)<<endl;








    //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);   
}


Measured memory_bytes: 3644
S = input()
ans = 0
ans_lis = [0]
for x in S:
    if x == 'A' or x == 'C' or x == 'G' or x == 'T':
        ans += 1
    else:
        ans_lis.append(ans)
        ans = 0
ans_lis.append(ans)
print(max(ans_lis))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define INF 1000100010001000100
using namespace std;
long long int p[100010],ans[100010],dire[100010],n,t,q,x[100010],mm,s1;


int main(){

    for(int i=0;i<100010;i++)ans[i]=INF;
    mm=INF;
    cin >> n >> t >> q;
    for(int i=1;i<=n;i++)cin >> x[i] >> dire[i];

    for(int i=1;i<=n;i++){
        if(dire[i]==1&&dire[i+1]==2){
            mm=(x[i]+x[i+1])/2;
            ans[i]=mm,ans[i+1]=mm;

            for(int j=i-1;j>0;j--){
                if(dire[j]==1)ans[j]=mm;
                else break;
            }
        }else if(dire[i]==2)ans[i]=mm;
    }

    for(int i=0;i<q;i++){
        cin >> mm;
        s1=x[mm]-ans[mm];
        if(s1<0)s1=-s1;
        //cout << "??????????????? " << x[mm] << "  ?????????????????? "  << x[mm]-t << "  ??¶????????£?????´??? " << ans[mm] << endl;
        if(t<s1){
            if(dire[mm]==1)cout << x[mm]+t << endl;
            else cout << x[mm]-t << endl;
        }else cout << ans[mm] << endl;
    }

return 0;
}

Measured memory_bytes: 5440
#include <iostream>

using namespace std;

int n, a[100];

void printArray() {
    for (int i = 0; i < n; ++i) {
        cout << a[i];
        if (i < n - 1)
            cout << " ";
    }
    cout << endl;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    for (int i = 1; i < n; ++i) {
        printArray();
        int v = a[i], j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
    }
    printArray();

    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define int long long
int h;
void maxHeapify(int *A,int i){
  int l=i*2+1;
  int r=i*2+2;
  int largest;
  if(l<h&&A[l]>A[i]) largest=l;
  else largest=i;
  if(r<h&&A[r]>A[largest]) largest=r;
  if(largest!=i){
    swap(A[i],A[largest]);
    maxHeapify(A,largest);
  }
}
void insert(int *A,int x){
  int i=h++;
  A[i]=x;
  while(i&&A[(i-1)/2]<A[i]){
    swap(A[(i-1)/2],A[i]);
    i=(i-1)/2;
  }
}
int extract(int *A){
  int res=A[0];
  A[0]=A[--h];
  maxHeapify(A,0);
  return res;
}
int A[2222222];
signed main(){
  string s;
  while(cin>>s,s!="end"){
    if(s=="insert"){
      int x;
      cin>>x;
      insert(A,x);
    }
    if(s=="extract") cout<<extract(A)<<endl;
  }
  return 0;
}



Measured memory_bytes: 10880