akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x)     		(x).begin(),(x).end()
#define ub    			upper_bound
#define lb 				lower_bound
#define int 			long long
#define endl			'\n'
#define ff              first
#define ss              second
#define ull		unsigned long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define si 				set<int>		
#define mii             map<int,int>
#define umii			unordered_map<int ,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,a,n)		for(int i=a;i<n;++i)
#define repd(i,a,n)		for(int i=a;i>n;--i)
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define deb(x)			cout<<#x <<"="<<x<<endl;
#define deb2(x,y)		cout<<#x<<"="<<x<<"  "<<#y<<"="<<y<<endl;
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int Pow(int a,int b){int res=1;while(b>0){if(b&1)res*=a;a*=a;b/=2;}return res;}
int MPow(int a,int  b){int res=1;while(b>0){if(b&1)res=(res*a)%Mod;a=(a*a)%Mod;b/=2;}return res%Mod;}
int log(int x){return 64-__builtin_clzll(x)-1;}



void c_p_p()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
struct Node
{
	int a,b,c,d;
	
};
const int Max=1e5+1;

int32_t main()
{
	c_p_p();
	int n;
	cin>>n;
	int A[n+1][4];
	rep(i,1,n+1)
	{
		rep(j,1,4)cin>>A[i][j];
	}
	int Dp[n+1][4];
	memset(Dp,0,sizeof(Dp));
	rep(i,n,n+1)
	{
		rep(j,1,4)Dp[i][j]=A[i][j];
	}
	repd(i,n-1,0)
	{
		rep(j,1,4)
		{
			if(j==1)Dp[i][j]=A[i][j]+max(Dp[i+1][j+1],Dp[i+1][j+2]);
			else if(j==2)Dp[i][j]=A[i][j]+max(Dp[i+1][j+1],Dp[i+1][j-1]);
			else
			Dp[i][j]=A[i][j]+max(Dp[i+1][j-1],Dp[i+1][j-2]);
		}
	}
	cout<<max(Dp[1][1],max(Dp[1][2],Dp[1][3]));
	return 0;
}
	

Measured memory_bytes: 9884
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

while True:
    n = input()
    if n == 0:
        break
    A = map(int, raw_input().split())
    m = {}
    for i in A:
        if i in m:
            m[i] += 1
        else:
            m[i] = 1
    ans = [key for key in m if m[key] * 2 > len(A)]
    print ans[0] if len(ans) > 0 else "NO COLOR"


Measured memory_bytes: 103608
# AtCoder Beginner Contest 064C

n = gets.to_i
array = gets.split.map(&:to_i)
flag = Array.new(8,0)
flag2 = 0
cnt = 0

length =  array.length
length.times do |i|
	if array[i] >= 3200
		flag2 += 1
	else
		flag[ array[i] / 400 ] = 1
	end
end

cnt = flag.inject(:+)

if flag2 == 0
	puts "#{cnt} #{cnt}"
elsif cnt == 0
	if flag2 + cnt <= 8
		puts "1 #{cnt + flag2}"
	else
		puts "1 8"
	end
else
	puts "#{cnt} #{cnt + flag2}"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;

void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	string n;
	cin >>n;
	bool ans=false;
	string F="YAKI";
	solve(equal(F.begin(),F.end(),n.begin()));
}

Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>) {
  var counter0 = 0
  var counter1 = 0
  for (char in Scanner(System.`in`).next().toCharArray()) {
    if (char == '0') counter0++ else counter1++
  }
  print(Math.min(counter0, counter1) * 2)
}

Measured memory_bytes: 32292
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;

int main() {
  int A,B,C;
  cin >> A>>B>>C;
  if(A!=B){
  	if(A!=C){
  		ce(A);
  	}else{
  		ce(B);
  	}
  }else{
  	ce(C);
  }
}

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

int main()
{
	int x,y,z;
	cin >> x >> y >> z;
	x -= z;
	cout << x/(y+z) << endl;
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

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

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    long long R;
    std::cin >> R;

    if (R < 1200)
        cout << "ABC" << endl;
    else if (R < 2800)
        cout << "ARC" << endl;
    else
        cout << "AGC" << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}
#[allow(unused_imports)]
use std::io::{stdout, Write};
fn main() {
    let n: usize = read();
    let v: Vec<i64> = read_vec();
    let mut p1 = 0usize;
    let mut p2 = n - 1;
    let mut v1_value = 0i64;
    let mut v2_value = 0i64;
    for _i in 0..n {
        if v1_value > v2_value {
            v2_value += v[p2];
            p2 -= 1;
        } else {
            v1_value += v[p1];
            p1 += 1;
        }
    }
    println!("{}", (v2_value - v1_value).abs())
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<ll, ll> ll_ll;
struct edge { int v, w; };
const int INF = INT_MAX / 2;
const int MOD = 1e9 + 7;
const ll e18 = 1e18;

int main() {
	int N; cin >> N;
	vector<int> t(N + 1), x(N + 1), y(N + 1);
	for (int i = 1; i <= N; i++)
		cin >> t[i] >> x[i] >> y[i];
	rep(i, N) {
		int dt = t[i + 1] - t[i];
		int dx = abs(x[i + 1] - x[i]);
		int dy = abs(y[i + 1] - y[i]);
		if (dx + dy > dt || (dx + dy + dt) % 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 1408
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

vector<ll> num;
multiset<ll> s1, s2;
ll b1[300005], b2[300005], N;

int main() {
    cin >> N; num.resize(3*N+1);
    FOR(i,1,3*N+1) cin >> num[i];
    FOR(i,1,3*N+1) {
        b1[i] = b1[i-1]+num[i];
        s1.insert(num[i]);
        if (s1.size() > N) {
            b1[i] -= (*s1.begin());
            s1.erase(s1.begin());
        }
    }
    FORd(i,1,3*N+1) {
        b2[i] = b2[i+1]+num[i];
        s2.insert(num[i]);
        if (s2.size() > N) {
            b2[i] -= (*prev(s2.end()));
            s2.erase(prev(s2.end()));
        }
    }
    ll ans = -(ll)MOD*MOD;
    FOR(i,N,2*N+1) ans = max(ans,b1[i]-b2[i+1]);
    cout << ans;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
/*freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);*/
#define ll long long
const int inf=0x3f3f3f3f;
const int maxc=500010;
#define mod 1000000007
int main()
{
    int a,b,t;
    cin>>a>>b>>t;
    cout<<t/a*b;
    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;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC076C - Dubious Document2
  string S; cin >> S;
  string T; cin >> T;
  int sizeS = S.size(), sizeT = T.size();
  if(sizeS < sizeT){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  
  int idx = -1; // Tが入る位置（適当な値）
  for(int i = sizeS - sizeT; i >= 0; i--){
    if(S[i] == '?' || S[i] == T[0]){ // 先頭の文字
      bool flag = true;
      for(int j = 1; j < sizeT; j++){
        if(S[j+i] != '?' && S[j+i] != T[j]){
          flag = false;
          break;
        }
      }
      if(flag){
        idx = i;
        break;
      }
    }
  }
  
  if(idx == -1){
    cout << "UNRESTORABLE" << endl;
  }else{
    REP(i, sizeS){
      if(S[i] != '?' && (i < idx || i >= idx + sizeT)){
        cout << S[i];
      }else if(i == idx){
        cout << T;
      }else if(S[i] == '?' && (i < idx || i >= idx + sizeT)){
        cout << "a";
      } 
    }
    cout << endl;
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,x,i,j,z;
    cin>>x;
    for(i=-120;i<=120;i++){
        a=pow(i,5);
       
        z=a-x;
        for(j=-120;j<=120;j++){
            if(pow(j,5)==z){
                
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3988
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <complex>
#include <cmath>
using namespace std;


int main(int argc, char const *argv[]) {
    int n;cin>>n;
    cout<<"Christmas"<<" ";
    for(;n<25;n++)cout<<"Eve ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
l = [0] * n
for x in a:
    l[x] += 1
for i in range(n):
    if l[i] > 2:
        print(0)
        exit()
    if l[i] > 0 and (i + n) % 2 == 0: 
        print(0)
        exit()
if n % 2 == 1 and l[0] > 1:
    print(0)
    exit()
print(pow(2, n // 2, 10 ** 9 + 7))

Measured memory_bytes: 20516
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;

int main(){
    int n;
    cin>>n;
    map<int,int> mp_o,mp_e;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        if(i%2==0){
            if(mp_o.count(tmp)){
                mp_o[tmp]++;
            }else{
                mp_o[tmp]=1;
            }
        }else{
            if(mp_e.count(tmp)){
                mp_e[tmp]++;
            }else{
                mp_e[tmp]=1;
            }
        }
    }
    int max_o=-1,i_o,max_e=-1,i_e;
    for(auto itr=mp_o.begin();itr!=mp_o.end();itr++){
        max_o=max(max_o,itr->second);
        if(max_o==itr->second){
            i_o=itr->first;
        }
    }
    for(auto itr=mp_e.begin();itr!=mp_e.end();itr++){
        max_e=max(max_e,itr->second);
        if(max_e==itr->second){
            i_e=itr->first;
        }
    }
    int ans=0;
    if(i_o!=i_e){
        ans+=(n/2-max_o)+(n/2-max_e);
    }else{
        int max_o2=-1,i_o2,max_e2=-1,i_e2;
        for(auto itr=mp_o.begin();itr!=mp_o.end();itr++){
            if(itr->second<=max_o && itr->first!=i_o){
                max_o2=max(max_o2,itr->second);
                if(max_o2==itr->second){
                    i_o2=itr->first;
                }
            }
        }
        for(auto itr=mp_e.begin();itr!=mp_e.end();itr++){
            if(itr->second<=max_e && itr->first!=i_e){
                max_e2=max(max_e2,itr->second);
                if(max_e2==itr->second){
                    i_e2=itr->first;
                }
            }
        }
        int ans1=(n/2-max_o)+(n/2-max_e2),ans2=(n/2-max_o2)+(n/2-max_e);
        if(mp_o.size()==1){
            ans1=n/2;
        }
        if(mp_e.size()==1){
            ans2=n/2;
        }
        ans=min(ans1,ans2);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4992
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pair<ll,ll> >   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pair<int,int> >   vpi;
typedef    vector<pair<double,double> >   vpd;
typedef    pair<double,double>   pd;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}


int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{

ll n,m;
cin>>n>>m;
int mi;
cin>>mi;
int ma;
cin>>ma;
m--;
while(m--)
{
	int a,b;
	cin>>a>>b;
	mi=max(mi,a);
	ma=min(ma,b);
}
if(ma>=mi)
cout<<ma-mi+1;
else
cout<<0;







}return 0;}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Slimes
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

char s[MAX_N + 4];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d%s", &n, s);

  int cnt = 0;
  for (int i = 0; i < n;) {
    int j = i + 1;
    while (j < n && s[i] == s[j]) j++;
    cnt++;
    i = j;
  }

  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 384
while True:
    m, f, r = map(int, raw_input().split())
    p = ""
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        p = "F"
    else:
        s = m + f
        if s >= 80:
            p = "A"
        elif s >= 65:
            p = "B"
        elif s >= 50:
            p = "C"
        elif s >= 30:
            p = "C" if r >= 50 else "D"
        else:
            p = "F"
    print(p)

Measured memory_bytes: 4232
#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979
int main(){
double a,b,c;
double s,hen,r;
scanf("%lf %lf %lf",&a,&b,&c);
r=c/180*PI; s=a*b*sin(r)/2;
hen=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(r))+a+b;
printf("%lf\n",s);
printf("%lf\n",hen);
printf("%lf\n",s*2/a);
return 0; }


Measured memory_bytes: 2112
#include <algorithm>
#include <iostream>
#include <string>

#include <vector>
#include <cmath>
#include <limits>
#include <functional>
using namespace std;

int f(long long A, long long B)
{
    int a = 1, b = 1;

    while (A >= 10)
    {
        a++;
        A = A / 10;
    }
    while (B >= 10)
    {
        b++;
        B = B / 10;
    }
    if (a > b)
        return a;
    else
        return b;
}

int main()
{
    long long N, x;
    int ans;
    int min = 11;
    

    cin >> N;

    for (long long i = 1; i <= sqrt(N); i++)
    {
        if (N % i == 0)
        {
            x = N / i;
            ans = f(x, i);
            if (ans < min)
                min = ans;
        }
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {
     public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int X = scanner.nextInt();

        int [][] A = new int[12][12];
        int [] C = new int[N];

         int ans = 1000000000;

        for (int i = 0; i < N; i++) {
            C[i] = scanner.nextInt();
            for (int j = 0; j < M; j++) {
                A[i][j] = scanner.nextInt();
            }
        }

        for (int i = 0; i < (1 << N); i++) {
            int cost = 0;
            int [] D = new int[M];
            for (int j = 0; j < N; j++) {
                if (((i >> j) & 1) != 0) {
                    cost += C[j];
                    for (int k = 0; k < M; k++) {
                        D[k] += A[j][k];
                    }
                }
            }
            boolean ok = true;
            for (int k = 0; k < M; k++) {
                if (D[k] < X) {
                    ok = false;
                }
            }
            if (ok) {
                ans = Math.min(ans, cost);
            }
        }
        if (ans == 1000000000) {
            System.out.println(-1);
        } else  {
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 28484
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 1000000007;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
  int N,M;
  cin >> N >> M;
  int sum = (M*1900)+(N-M)*100;
  cout << sum * pow(2, M) << endl;
  return 0;
}


Measured memory_bytes: 256
# 6
# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN

import itertools
import copy
from collections import deque

n = int(input())
s = input()

ans = 0
iter = itertools.product("0123456789", repeat=3)

for it in iter:
    _s = copy.deepcopy(s)
    for i in it:
        try:
            _idx = _s.index(i)
            _s = _s[_idx+1:]
        except:
            break
    else:
        ans += 1
    
print(ans)

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

int main() {
  int N,M;
  int i;
  cin >> N;
  int D[N];
  for(i=0;i<N;i++) cin >> D[i];
  cin >> M;
  int T[M];
  for(i=0;i<M;i++) cin >> T[i];
  sort(D,D+N);
  sort(T,T+M);
  string s="YES";

  int j=0;
  while(j<M) {
    if(upper_bound(T,T+M,T[j])-lower_bound(T,T+M,T[j])>upper_bound(D,D+N,T[j])-lower_bound(D,D+N,T[j])) {
	s="NO";
	break;
    }
    else j+=upper_bound(T,T+M,T[j])-lower_bound(T,T+M,T[j]);
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define sd(x)   scanf("%g",&x)
#define ss(s)	scanf("%s",s)
#define pd(x)   printf("%g\n",x)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define nline   printf("\n")
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define fitr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int main()
{
 string in;
 int i;
 cin>>in;
 int s = 0;
 fo(i,in.length())   
 {
    s += (int)(in[i] - '0');
 }
 if(s%9==0)
 printf("Yes");
 else
 {
     printf("No");
 }
 
}

Measured memory_bytes: 3848
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.remove(list.indexOf(a));
        list.remove(list.indexOf(b));
        System.out.println(list.get(0));
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------

/// problem's variable---------------



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


int main()
{
    Phuong_;
    string s;
    cin >> s;
    int t;
    cin >> t;
    string a,b;
    a="";
    b="";
    bool flip= false;
    while (t--)
    {
        int u;
        cin >> u;
        if (u&1) flip=!flip; else
        {
            int id;
            char v;
            cin >> id >> v;
            if (flip) id++;
            if (id&1) a=v+a;
            else b=b+v;
        }
    }
    if (flip)
    {
        reverse(s.begin(),s.end());
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        swap(a,b);
    }
    cout << a<<s << b;
    return 0;
}



Measured memory_bytes: 1144
#include <stdio.h>

int main(void)
{
  int i, make_n;
  int total;
  int donutt[1000];
  int min = 1000000;
  int madenum = 0;
  
  scanf("%d%d", &make_n, &total);
  for (i = 0; i < make_n; i++){
    scanf("%d", &donutt[i]);
    total -= donutt[i];
    if (min > donutt[i])
        min = donutt[i];
  }
   
  while(1) {
    total -= min;
    if (total >= 0)
       madenum++;
    else
       break;
  };
  printf("%d", madenum + make_n);
  return 0;
}

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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int k, x;
	cin >> k >> x;
	cout << (500 * k >= x ? "Yes" : "No") << endl;
    
    return 0;
}



Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
	int a=0,b=0,c=0,x,d,y=0;

	scanf("%d %d %d",&a,&b,&c);


	for(x=a;x<=b;x++)
	{
		d=c%x;
		if(d==0)
		{
			y=y+1;
		}
	}

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

	return 0;

}

Measured memory_bytes: 1028
def insert(A,N):
    for i  in range(1,N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v 
        print(*A)
        

N = int(input())
A = list(map(int,input().split()))
print(*A)
insert(A,N)


Measured memory_bytes: 5980
<?php
fscanf(STDIN, "%s %s %s", $N, $A, $B);
$total = 0;
for($i = 1; $i <= $N; $i++) {
  if($i < 10) {
    $new = $i;
  } elseif ($i < 100) {
    $str = str_split($i);
    $new = $str[0] + $str[1];
    // var_dump($i);
    // echo "$new\n";
  } elseif ($i < 1000) {
    $str = str_split($i);
    $new = $str[0] + $str[1] + $str[2];
  } else {
    $str = str_split($i);
    $new = $str[0] + $str[1] + $str[2] + $str[3];
  }
  if(($new >= $A) && ($new <= $B)) {
    $total += $i;
    // echo "$total\n";
  }

}
echo "$total\n";
exit;
?>


Measured memory_bytes: 4728
// Undone
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0;i<(n);++i)
#define LL long long
using namespace std;
int gcd(int, int);
int gcd(vector<int>);
int lcm(int, int);

int main(void) {
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<LL> A(X), B(Y), C(Z), P(X*Y);
  REP(i,X) cin>>A[i];
  REP(i,Y) cin>>B[i];
  REP(i,Z) cin>>C[i];
  for (int i = 0, k = 0; i < X; i++) {
    for (int j = 0; j < Y; j++, k++) {
      P[k] = A[i] + B[j];
    }
  }
  sort(P.begin(), P.end(), greater<LL>());
  vector<LL> Q(min(K, X*Y) * Z);
  for (int i = 0, k = 0; i < min(K, X*Y); i++) {
    for (int j = 0; j < Z; j++, k++) {
      Q[k] = P[i] + C[j];
    }
  }
  sort(Q.begin(), Q.end(), greater<LL>());
  REP(i,K) cout << Q[i] << endl;
}


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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

string solve(int N, const vector<int>& xs)
{
    int h = xs[0] - 1;

    for (int i = 1; i < N; ++i)
    {
        if (xs[i] < h)
            return "No";

        h = max(h, xs[i] - 1);
    }

    return "Yes";
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i];

    auto ans = solve(N, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 640
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 100005;


int go(char c) {
    if(c == 'L') {
        return 2;
    }
    if(c == 'R') {
        return 0;
    }
    if(c == 'U') {
        return 3;
    }
    return 1;
}

int h, w;
bool out(int x, int y) {
    if(x <= 0 || x > h || y <= 0 || y > w) {
        return 1;
    }
    return 0;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, r, c;
    string s, t;
    cin >> h >> w >> n;
    cin >> r >> c >> s >> t;
    int dirx[] = {0, 1, 0, -1};
    int diry[] = {1, 0, -1, 0};
    bool ans = 0;
    rep(i, 0, 4) {
        int j = (i + 2) % 4;
        int cr = r, cc = c;
        rep(k, 0, n) {
            if(go(s[k]) == i) {
                int nr = cr + dirx[i], nc = cc + diry[i];
                if(out(nr, nc)) {
                    ans = 1;
                    break;
                }
                cr = nr;
                cc = nc;
            }
            if(go(t[k]) == j) {
                int nr = cr + dirx[j], nc = cc + diry[j];
                if(!out(nr, nc)) {
                    cr = nr;
                    cc = nc;
                }
            }
        }
    }
    if(ans) {
        cout << "NO";
    } else {
        cout << "YES";
    }
    cout << endl;
}

Measured memory_bytes: 920
n,i;
ea[2<<17],eb[2<<17],next[2<<17],first[1<<17];
long M,dp1[1<<17],dp2[1<<17],L[2<<17],R[2<<17]={1};
dfs1(u,p,id)
{
	dp1[u]=1;
	id=first[u];
	while(id)
	{
		if(eb[id]!=p)
		{
			dfs1(eb[id],u);
			dp1[u]=dp1[u]*-~dp1[eb[id]]%M;
		}
		id=next[id];
	}
}
make();
dfs2(u,p,x,id)
{
	dp2[u]=dp1[u]*x%M;
	make(first[u],p,x);
	id=first[u];
	while(id)
	{
		if(eb[id]!=p)
		{
			dfs2(eb[id],u,L[id]*R[next[id]]%M+1);
		}
		id=next[id];
	}
}
make(i,p,x,t)
{
	if(i)
	{
		L[i]=x;
		t=eb[i]!=p?-~dp1[eb[i]]:1;
		make(next[i],p,t%M*x%M);
		R[i]=R[next[i]]*t%M;
	}
}
main(u,v)
{
	/*for(scanf("%d%d",&n,&M);~scanf("%d%d",&u,&v);)
	{
		i++;
		ea[i]=u;
		eb[i]=v;
		i++;
		ea[i]=v;
		eb[i]=u;
	}*/
	for(;~scanf("%d%d",&u,&v);)
	{
		if(i++){
			ea[i]=u;
			eb[i]=v;
			i++;
			ea[i]=v;
			eb[i]=u;
		}
		else n=u,M=v;
	}
	for(;i;i--)
	{
		next[i]=first[ea[i]];
		first[ea[i]]=i;
	}
	dfs1(1,0);
	dfs2(1,0,1);
	for(i=1;i<=n;i++)printf("%d\n",dp2[i]);
}

Measured memory_bytes: 13056
#include <stdio.h>
#include <stdlib.h>
long long n,ans,l[100005],r[100005];
int cmp(const void*a,const void*b)
{
	return*(int*)a-*(int*)b;
}
int main()
{
	scanf("%lld",&n);
	for (int i=1;i<=n;++i)
	{
		scanf("%lld%lld",&l[i],&r[i]);
	}
	qsort(l,n+1,sizeof(l[0]),cmp);
	qsort(r,n+1,sizeof(r[0]),cmp);
	for (int i=0;;i++)
	{
		long long d=l[n-i]-r[i];
		if (d>0)
		{
			ans+=d;
		}
		else break;
	}
	printf("%lld\n",ans*2);
	return 0;
}

Measured memory_bytes: 2556
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>

// type alias
using lint = long long;
using ldouble = long double;
template <class T>
using greater_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T>>;


/* ----- class ----- */

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;


/* ----- debug ----- */

#if __has_include("../setting/source/debug.hpp")
#include "../setting/source/debug.hpp"
#endif


/* ----- short functions ----- */

template <class T>
inline T sq(T a) { return a * a; }

template <class T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <class T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        std::swap(a, b);
    }
    return a;
}

template <class T, class U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

// 0-indexed
template <class T, class U>
inline T kthbit(T a, U k) { return (a >> k) & 1; }

template <class T, class U>
inline T mask(T a, U k) { return a & ((1 << k) - 1); }

template <class T>
std::map<T, int> compress(std::vector<T>& v) {
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::map<T, int> rev;
    for (int i = 0; i < v.size(); ++i) rev[v[i]] = i;
    return rev;
}

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}


/* ----- constants ----- */

// const int INF = std::numeric_limits<int>::max() / 3;
// const lint INF = std::numeric_limits<lint>::max() / 3;
// const ldouble PI = acos(-1);
// const ldouble EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));


using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> W(N);
    for (auto& w : W) cin >> w;

    int sum = accumulate(W.begin(), W.end(), 0);
    int ans = sum, acc = 0;
    for (auto w : W) {
        acc += w;
        ans = min(ans, abs(acc - (sum - acc)));
    }

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


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

const int N = 2e5 + 5;

int n;
int A[N], B[N];

vector < int > a[2];
int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> A[i] >> B[i];
		a[0].push_back(A[i]);
		a[1].push_back(B[i]);
	}

	sort(a[0].begin(), a[0].end());
	sort(a[1].begin(), a[1].end());

	if(n % 2){
		int mn = a[0][(n - 1)/2];
		int mx = a[1][(n - 1)/2];
		cout << mx - mn + 1 << endl;
	} else{
		int mn = (a[0][n/2] + a[0][(n/2) - 1]);
		int mx = (a[1][n/2] + a[1][(n/2) - 1]);
		cout <<  (mx - mn) + 1 << endl;
	}
}

Measured memory_bytes: 6592
import java.util.*;class Main{public static void main(String[]z){int[]c;List<Long>l;for(Scanner s=new Scanner(System.in);s.hasNext();System.out.println(c[4]>3?"four card":c[2]==2&&c[3]==3?"full house":c[1]>4&&c[0]==5*l.get(2)||l.equals(Arrays.asList(1L,10L,11L,12L,13L))?"straight":c[3]>2?"three card":c[2]>3&&c[1]<2?"two pair":c[2]<3&&c[1]==3?"one pair":"null")){l=new Stack<Long>();for(String x:s.next().split(","))l.add(new Long(x));Collections.sort(l);c=new int[6];for(long a:l){c[0]+=a;for(int i=0;i++<5;c[i]+=Collections.frequency(l, a)==i?1:0);}}}}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>

// MARK: - header
namespace {
using namespace std;
using ll = long long;
using ull = unsigned long long;
}

// MARK: - answer

ll X, Y, Z, K;
vector<ll> A, B, C;

void input() {
    cin >> X >> Y >> Z >> K;
    A.resize(X);
    for (auto& a : A)
        cin >> a;
    B.resize(Y);
    for (auto& b : B)
        cin >> b;
    C.resize(Z);
    for (auto& c : C)
        cin >> c;
}

bool cut_search(ll p, vector<ll>* sums = nullptr) {
    ll cnt = 0;
    for (auto a : A) {
        for (auto b : B) {
            for (auto c : C) {
                auto sum = a+b+c;
                if (sum < p)
                    break;
                cnt++;
                if (sums)
                    sums->push_back(sum);
                else if (cnt >= K)
                    return true;
            }
        }
    }
    return false;
}

void solve() {
    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());
    ll l = 0, r = 3e10;
    ll p = 0;
    while (l <= r) {
        ll c = (l+r)/2;
        if (cut_search(c)) {
            p = c;
            l = c + 1;
        } else {
            r = c - 1;
        }
    }
    vector<ll> sums;
    cut_search(p, &sums);
    sort(sums.rbegin(), sums.rend());
    for (int i = 0; i < K; i++)
        cout << sums[i] << endl;
}

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



Measured memory_bytes: 132192
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

n, k = list(map(int, input().split()))

if k % 2 == 1:
    h = int(n / k)
    print(h ** 3)
else:
    h = int(n / k)
    he = h
    if (h + 0.5) * k <= n:
        he += 1
    print(h ** 3 + he ** 3)


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
    // Your code here!
    char s[11],t;
    int N;
    int K;
    scanf("%d",&N);
    scanf("%s",s);
    scanf("%d",&K);
    t = s[K-1];
    for(int i = 0; i < N; i++)
    {
        if(s[i] != t)
        {
            s[i] = '*';
        }
    }
    printf("%s\n",s);
}


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

using namespace std;

int main() {
    int N=0,K=0;
    cin>>N>>K;

    vector<int> height(N);
    for(int I=0; I<N; I++) {
        int temp=0;
        cin>>temp;
        height[I] = temp;
    }

    vector<int> cost(N);

    cost[1] = abs(height[0]-height[1]);

    for(int I=2; I<N; I++) {
       int minm = cost[I-1] + abs(height[I]-height[I-1]);
       for(int J=1; J<=K && (I-J) >= 0 ; J++) {
            minm = min(cost[I-J] + abs(height[I] - height[I-J]), minm);
       }
       cost[I] = minm;
    }

    cout<<cost[N-1]<<endl;

    return 0;
}

Measured memory_bytes: 1024
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


long solve(long X, long Y, long K) {
  const limArea = K + max(X, Y);
  long ans;
  foreach (x; 1 .. X) {
    const limY1 = min((2 * limArea) / x, Y - 1);
    auto g0 = new long[limY1 + 1];
    auto g1 = new long[limY1 + 1];
    foreach (y; 0 .. limY1 + 1) {
      g0[y] = gcd(x, y);
      g1[y] = gcd(X - x, y);
    }
    foreach (y; 1 .. limY1 + 1) {
      if (((X * y) - (g0[y] + g1[y] + X)) / 2 + 1 <= K) {
        ans += 1;
      }
    }
    foreach (d; 1 .. limY1) {
      const g2 = gcd(X, d);
      long lo = 0, hi = limY1 - d + 1;
      for (; lo + 1 < hi; ) {
        const mid = (lo + hi) / 2;
        ((((X * (mid + d) - (X - x) * d) - (g0[mid] + g1[mid + d] + g2)) / 2 + 1 <= K) ? lo : hi) = mid;
      }
      ans += 2 * lo;
    }
  }
  
  debug {
    if (X <= 100 && Y <= 100) {
      long brt;
      foreach (x; 1 .. X) foreach (y0; 1 .. Y) foreach (y1; y0 .. Y) {
        if (((X * y1 - (X - x) * (y1 - y0)) - (gcd(x, y0) + gcd(X - x, y1) + gcd(X, y1 - y0))) / 2 + 1 <= K) {
          brt += (y0 == y1) ? 1 : 2;
        }
      }
      writeln("brt = ", brt, ", ans = ", ans);
      assert(brt == ans);
    }
  }
  
  return ans;
}

void main() {
  try {
    for (; ; ) {
      const W = readInt();
      const H = readInt();
      const K = readInt();
      
      long ans;
      ans += solve(W, H, K);
      ans += solve(H, W, K);
      ans *= 2;
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 8216
A,B,C,D=map(int,input().split())
A-=1
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
lCD=C*D//gcd(C,D)
print(B-B//C-B//D+B//lCD-(A-A//C-A//D+A//lCD))

Measured memory_bytes: 38384
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
struct W
{
	long A, B;
};

int main(int, char**)
{
	int N;
	cin >> N;
	vector<W> w(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> w[i].A >> w[i].B;
	}
	sort(w.begin(), w.end(), [](W l, W r)
		{
			if (l.B == r.B)
			{
				return (l.B - l.A) > (r.B - r.A);
			}
			else
			{
				return l.B < r.B;
			}
		}
	);
	long now = 0;
	for (int i = 0; i < N; ++i)
	{
		now += w[i].A;
		if (now > w[i].B)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3328
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {n:usize, x:usize, t:usize}
    let mut time = 0;
    let mut sum = 0;
    loop {
        time += t;
        sum = sum + x;

        if sum >= n {
            println!("{}", time);
            break;
        }
    }
}


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

#define ll long long int
#define ld long double
#define clr(arr) memset(arr,0,sizeof(arr))
#define nn '\n'

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

    int t = 1;
//    cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        ll arr[n];
        for(ll i=0; i<n; i++) cin>>arr[i];
        for(ll i=k; i<n; i++)
        {
            if(arr[i]>arr[i-k]) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }

    return 0;
}




Measured memory_bytes: 5132
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,m; cin>>n>>m;
    vector<tuple<int,int,int>> v(m);
    vector<string> ans(m,"");
    rep(i,m){
        int p,y; cin>>p>>y;
        v[i]=make_tuple(p,y,i);
    }
    sort(al(v));
    int pr=-1,cnt=1;
    string ps,cnts;
    rep(i,m){
        int p,y,idx;
        tie(p,y,idx)=v[i];
        if(p!=pr) cnt=1;
        else cnt++;
        pr=p;
        ps=to_string(p);
        cnts=to_string(cnt);
        rep(j,6-ps.size()) ans[idx]=ans[idx]+"0";
        ans[idx]=ans[idx]+ps;
        rep(j,6-cnts.size()) ans[idx]=ans[idx]+"0";
        ans[idx]=ans[idx]+cnts;
    }
    rep(i,m) cout<<ans[i]<<endl;
}

Measured memory_bytes: 9088
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

class Restaurant
{
public:
    string city;
    int score;
    int num;

    Restaurant(string c, int s, int n)
    {
        this->city = c;
        this->score = s;
        this->num = n;
    }


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

    int N;
    cin >> N;

    vector<Restaurant> v;

    rep(i, N)
    {
        string s;
        int p;
        cin >> s >> p;
        v.emplace_back(s, p, i + 1);
    }

    sort(all(v), [](Restaurant& lhs, Restaurant& rhs)
        {
            if (lhs.city != rhs.city)
            {
                return lhs.city < rhs.city;
            }
            else
            {
                return lhs.score > rhs.score;
            }
        });

    for (auto p : v)
    {
        cout << p.num << endl;
    }

    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<n;i++)
#define test(a) cout << "*" << a << endl;
int main(){
  string s;
  bool existAC = false;
  int i;
  int existC=false;
  int placeC;
  
  cin >> s;
  
  if(s[0]=='A'){
    for(i=2;i<s.size()-1;i++){
      if(s[i]=='C'){
        if(existC==true){ 
          existC=false;
          break;  
        }
        placeC=i;   
        existC = true;
      }
    }
    if(existC==true){
      rep1(i,s.size()){
        if(i==placeC){
          continue;   
        }
        if('a'<=s[i] && s[i]<='z'){
          if(i==s.size()-1){
            existAC = true;
          }
        }
        else{
          break; 
        }
      }
    }
  }
    
    if(existAC==true)
      cout << "AC" << endl;
    else
      cout << "WA" << endl;
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
const int MASU_SIZE = 8;
using namespace std;

void Bomb(vector<string>& masu, int sx, int sy) {
    if (sx < 0 || sx >= MASU_SIZE || sy < 0 || sy >= MASU_SIZE) {
        return;
    }

    for (int i = -3; i <= 3; i++) {
        if (sx+i >= 0 && sx+i < MASU_SIZE && masu[sy][sx+i] == '1') {
            masu[sy][sx+i] = '0';
            Bomb(masu, sx+i, sy);
        }
        if (sy+i >= 0 && sy+i < MASU_SIZE && masu[sy+i][sx] == '1') {
            masu[sy+i][sx] ='0';
            Bomb(masu, sx, sy+i);
        }
    }
}

int main(void) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        vector<string> masu;
        int sx, sy;
        for (int j = 0; j < MASU_SIZE; j++) {
            string s;
            cin >> s;
            masu.push_back(s);
        }
        cin >> sx >> sy; sx--; sy--;

        Bomb(masu, sx, sy);

        cout << "Data " << i << ":" << endl;
        for (auto j = 0; j < MASU_SIZE; j++) {
            cout << masu[j] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1212