akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(n)]
res=0
for i in range(n-1,-1,-1):
    cnt=0
    for j in range(i,n,i+1): #j+1の倍数
        cnt+=b[j]
    if cnt%2!=a[i]:
        b[i]+=1
        res+=1

print(res)
if res==0:
    exit()
for i in range(n):
    if b[i]==1:
        print(i+1)

Measured memory_bytes: 70620
from math import *
n = int(input())
a = list(map(int,input().split()))
g = 0
for i in range(n):
    g = gcd(g,a[i])
    
if g == 1:
    x = a.count(1)
    a = list(set(a))
    m = len(a)
    
    sw2 = 0

    if x >= 2:
        if m != n - x + 1:
            sw2 = 1
    else:
        if m != n:
            sw2 = 1
    
    if sw2 == 1:
        print("setwise coprime")
        
    else:
    
        b = [True]*(10**6+1)

        for i in range(m):
            b[a[i]] = False

        sw = 1
        
        for i in range(2, 10**6+1):
            q = 0
            j = 1
            while i*j <= 10**6:
                if b[i*j] == False:
                    q += 1
                j += 1
                
                
            if q >= 2:
                sw = 0
                break

        if sw == 0:
            print("setwise coprime")
        else:
            print("pairwise coprime")
        
else:
    print("not coprime")

Measured memory_bytes: 241452
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, M;
  cin >> N >> M;
  ll ans = (N * (N-1) / 2) + (M * (M-1) / 2);
  cout << ans << "\n";
  return 0;
}


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

int main(){
int N,K;
	cin >> N >> K;
  
  double tot=0,m=0;
  vector <double> p(N);
  vector <double> q(N+1);
  q.at(0)=0;
  rep(i,N){
    cin >> p.at(i);
    p.at(i)=kitaichi(p.at(i));
  }

  rep(i,N){
    q.at(i+1)=q.at(i)+p.at(i);

  }

rep(i,N-K+1){
  m=max(m,q.at(i+K)-q.at(i));

}
  printf("%.12lf",m);

}

double kitaichi(double i){
  double tot=0;
tot=(1+i)*i/2;
  return tot/i;
}

Measured memory_bytes: 3328
import java.util.Scanner;
class Main{
    public static void main(String[] av){
        Scanner sc=new Scanner(System.in);
        int m = 0;
        int a;
        int cnt = 0;
        int n = sc.nextInt();
        int[] d=new int[n];
        for(int i=0; i<n;i++){
            a = sc.nextInt();
            d[i] = a;
            if(m < a){
                m = a;
            }
        }
   
        boolean[] p=new boolean[m+1];

        p[1]=false;

        for(int i=2; i<=m ;i++){
             p[i]=true;
        }
        for(int i=2; i<=Math.sqrt(m);i++){
            if(p[i]) for(int j=i*2; j<=m; j+=i) p[j]=false;
        }
        for(int i=0; i<n ;i++){
            if(p[d[i]]){
                cnt = cnt+1;
            }
        }
        System.out.println(cnt);
    }
}



Measured memory_bytes: 140516
#include<stdio.h>
int main(){
        int a,b,c;
        scanf("%d %d",&a,&b);
        if(a==3 && b==1)
            printf("2\n");
        else if(a==1 && b==2)
            printf("3\n");
                else if(b==3 && a==2)
                    printf("1\n");
                else if(b==2 && a==3)
            printf("1\n");
                    else if(b==1 && a==2)
            printf("3\n");
            else if(b==3 && a==1)
            printf("2\n");

        return 0;

}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>

typedef long long ll;

int main(){
    int N;
    scanf("%d", &N);
    
    while(N--){
        ll s, d;
        scanf("%lld %lld", &s, &d);
        
        int t = 0;
        while(s != d){
            ll s_ = std::abs(s);
            ll mx = s_ & -s_;
            if(s == 0ll){mx = 1ll << 62;}
            for(ll i=mx;i>0;i>>=1){
                if(s + i <= d){s += i; break;}
            }
            t++;
        }
        
        printf("%d\n", t);
    }
}

Measured memory_bytes: 1012
import random
import time

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][j]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)

    random.seed(20)
    while time.time() - start < 1.9:
        idx = random.randint(0,25)
        d = random.randint(0,D-1)
        if c[idx] == 0 or ans[d-1] == idx:
            continue
        tmp = ans[d]
        ans[d] = idx
        last_d = [0 for i in range(26)]
        score2 = 0    
        for i in range(D):
            score2 += s[i][ans[i]]
            last_d[ans[i]] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d] = tmp
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


Measured memory_bytes: 9724
#include<bits/stdc++.h>
#define F first
#define S second
#define INF (1<<30)
#define LINF (1LL<<60)
using namespace std;
typedef pair<long long,long long> P;
long long a,b,c,d;
string s,s2,s3;
long long  sum=0,ans=0,pos=0;
long long n,m,h,w;
main(){
  cin>>s;
  n=s.size();
  a=0;
  b=0;
  for(int i=0;i<n;i++){
    if(s[i]=='A'){
      a=i;
      break;
    }
  }
  for(int i=n-1;i>=0;i--){
    if(s[i]=='Z'){
      b=i;
      break;
    }
  }
  cout<<b-a+1<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    unordered_map<ll,ll>m;
    for(int i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        m[x]++;
    }
    ll ans=0;
    for(auto x:m)
    {
        if(x.second%2!=0)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int main(){
	int n;
	bool f=false;
	while(cin>>n){
		if(!n)break;
		multimap<int,string,greater<int> > teams;
		for(int i=0,w,l,d;i<n;++i){
			string team;
			cin>>team>>w>>l>>d;
			teams.insert(multimap<int,string>::value_type(w*3+d,team));
		}
		if(f)cout<<endl;
		f=true;
		for(multimap<int,string>::iterator it=teams.begin();it!=teams.end();++it) cout<<(*it).second<<","<<(*it).first<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b=parseMap(split(readline()))
    println(ifelse(a+b>=10,"error",a+b))
end
main()

Measured memory_bytes: 166900
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int lli;
int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
  lli k,i;
  string s,s1=" ";
  cin>>k;
  cin>>s;
  if(s.size()>k)
  {
      for(i=0;i<k;i++)
      {
          s1=s1+s[i];
      }
      s1=s1+"...";
      cout<<s1;
  }
  else
  {
      cout<<s;
  }

}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

/* 白 -> .
 * 黒 -> #
 */

struct edge {
	// 状態
	char cond;
	// このマスまでの白マスの最短距離
	int dis;
};

int h,w;
std::vector<std::vector<edge>> v;

void dps(int x, int y){
	int xx[] = {0,1,0,-1};
	int yy[] = {1,0,-1,0};
	for (size_t i = 0; i < 4; i++) {
		if (0 <= x + xx[i] && x + xx[i] < h && 0 <= y + yy[i] && y + yy[i] < w) {
			if (v[x+xx[i]][y+yy[i]].cond == '.' && v[x+xx[i]][y+yy[i]].dis > v[x][y].dis + 1) {
				v[x+xx[i]][y+yy[i]].dis = v[x][y].dis + 1;
				dps(x+xx[i],y+yy[i]);
			}
		}
	}
}

int main(int argc, char const *argv[]) {
	std::cin >> h >> w;
	int MAX = h * w + 10;
	std::vector<string> str(h);
	v.resize(h);
	int white = 0;
	for (size_t i = 0; i < h; i++) {
		std::cin >> str[i];
		for (size_t j = 0; j < w; j++) {
			v[i].push_back({str[i][j], MAX});
			if (str[i][j] == '.') {
				white++;
			}
		}
	}

	v[0][0].dis = 1;

	dps(0, 0);

	if (v[h-1][w-1].dis == MAX) {
		std::cout << -1 << '\n';
		return 0;
	}

	std::cout << white - v[h-1][w-1].dis << '\n';

	return 0;
}


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

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if(A <= C && C <= B)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3608
n = gets.chomp.to_i
t, a = gets.chomp.split(" ").map(&:to_f)
h = gets.chomp.split(" ").map(&:to_i)
diff = 1 << 40
ans = -1

n.times do |i|
    temp = t - h[i] * 0.006
    if (a-temp).abs < diff
        ans = i
        diff = (a-temp).abs
    end
end

puts ans+1

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

int main(void){
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    double x = X;
    double k = K;
    double d = D;
    if(x > 0.9 * k * d && X > K * D) cout << X - K * D << endl;
    else{
        if(K % 2 == 1) X += D;
        D *= 2;
        cout << min(X % D, D - (X % D)) << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main()
{
    long long int n, i, j, p, o, w=0;
    cin >> n;
    cin >> p;
    for(i=1; i<n; i++){
        cin >> o;
        w+=max(p-o, (long long)0);
        p=max(p, o);
        //cout << p;
    }
    cout << w << '\n';
    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


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

const ll INF = 1e16;
const ll MOD = 998244353 /*1e9 + 7 */;

#define REP(i, n) for(ll i = 0; i < n; i++)




const long long table_size = 3e5 + 5;
long long fact[table_size], inverse[table_size];

// 高速に n^m (mod p) を求める
long long POW(long long n, long long m, long long p){
    if(m == 0){
        return 1;
    }
    if(m % 2 == 0){
        long long tmp = POW(n, m / 2, p) % p;
        return tmp * tmp % p;
    }
    else{
        return n * POW(n, m - 1, p) % p;
    }
}

// 階乗を生成    e.g. 5! == fact[5]
void make_table(long long n, long long p) {
    fact[0] = 1;
    inverse[0] = 1;
    for (long long i = 1; i <= n; i++) {
        fact[i] = (fact[i - 1] * i) % p;
        inverse[i] = POW(fact[i], p - 2, p) % p;
    }
}

// nCr
long long nCr(long long n, long long r, long long p) {
    return fact[n] * inverse[r] % p * inverse[n - r] % p;
}

int main() {
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    
    make_table(n + 1, MOD);
    
    ll ans = 0;
    REP(i, n + 1){
        ll t = k - i * a;
        if(t < 0 || t > n * b || t % b != 0)continue;
        ll tt = t / b;
        ans += nCr(n, i, MOD) * nCr(n, tt, MOD) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
N = int(input())
A = list(map(int,input().split()))
ans = [0 for i in range(N)]
ans[0] = sum(((-1)**i)*A[i] for i in range(N))//2
for i in range(1,N):
    ans[i] = A[i-1]-ans[i-1]
for i in ans:
    print(2*i,end = ' ')

Measured memory_bytes: 14028
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
		if(c>=Math.min(a, b)&&c<=Math.max(a, b)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22612
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, n;
    cin >> k >> n;
    vector<int> a(n+1);
    rep(i,n) cin >> a[i];
    a[n] = k+a[0];
    int ans = k;
    rep(i,n) chmin(ans, k-abs(a[i]-a[i+1]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys

a, b, c, x = map(int, sys.stdin.read().split())
x //= 50

def main():
    ways = 0
    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                if 10*i + 2*j + k == x:
                    ways += 1
    return ways

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int n;


signed main(){
    cin >> n;

    cout << CEIL(n/2) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;


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

	int ans = A + B;

	if (2 * A - 1 > ans) ans = 2 * A -1;
	if (2 * B - 1 > ans) ans = 2 * B -1;

	printf("%d", ans);

	return 0;
}



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

int main() {
	int N;
	vector<int> a;
	double ave;
	cin >> N;
	for (int i=0; i<N; i++) {
		int tmp;
		cin >> tmp;
		ave += tmp;
		a.push_back(tmp);
	}
	ave /= N;
	double difave = 100;
	int itr = 0;
	for (int i=0; i<N; i++) {
		if (difave>fabs(ave-a[i])) {
			itr = i;
			difave = fabs(ave-a[i]);
		}
	}
	cout << itr << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

template<typename T = int>
struct S2D {
    const int w, h;
    V<V<T>> f;

    S2D(int w, int h, T z) : f(h+1, V<T>(w+1,z)), w(w+1), h(h+1) {}

    void build() {
        for(int i = 1; i < h; i++) {
            for(int j = 1; j < w; j++) {
                f[i][j] = f[i][j] + f[i][j-1] + f[i-1][j] - f[i-1][j-1];
            }
        }
    }

    void add(int x, int y, T val) {
        x++; y++;
        if(x >= w || h <= y) return ;
        f[y][x] += val;
    }

    T query(int lx, int ly, int rx, int ry) {
        return f[ry][rx] - f[ly][rx] - f[ry][lx] + f[ly][lx];
    }
};

LL N, K;

int main(){
    INIT;
    cin >> N >> K;
    S2D<LL> s2d(2*K+1,2*K+1,0);

    REP(i,N) {
        LL x, y; char c;
        cin >> x >> y >> c;
        if(c == 'W') s2d.add((x)%(2*K), (y+K)%(2*K), 1);
        else s2d.add(x%(2*K), y%(2*K), 1);
    }

    s2d.build();

    LL ans = 0;
    REP(i,K) {
        FOR(j,0,K) {
            int rx = i+K;
            int ry = j+K;
            LL cnt = s2d.query(i,j,rx,ry);
            cnt += s2d.query(0,0,i,j);
            cnt += s2d.query(rx,0,2*K+1,j);
            cnt += s2d.query(0,ry,i,2*K+1);
            cnt += s2d.query(rx,ry,2*K,2*K);
            if(cnt >= 0) {
                ans = std::max(ans, cnt);
                ans = std::max(ans, N-cnt);
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
const int N = 500005;
int n, k, A[N], P[N], R[N], M[N], MX[N * 2];
priority_queue < int > Pq;
inline void Set(int i, int val)
{
    MX[i += n - 1] = val;
    for (; i; i >>= 1)
        MX[i >> 1] = max(MX[i], MX[i ^ 1]);
}
inline int Get(int l, int r)
{
    int Mx = 0;
    l = max(l, 1);
    r = min(r, n + 1);
    l += n - 1; r += n - 1;
    for (; l < r; l >>= 1, r >>= 1)
    {
        if (l & 1) Mx = max(Mx, MX[l ++]);
        if (r & 1) Mx = max(Mx, MX[-- r]);
    }
    return (Mx);
}
inline void Do(int block)
{
    int i = block * k + 1;
    if (i < 0 || i > n || M[block])
        return ;
    int Mx = Get(i, i + k);
    if (Mx && Get(R[Mx] - k + 1, R[Mx] + k) == Mx)
        M[block] = 1, Pq.push(R[Mx]);
}
int main()
{
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++)
        scanf("%d", &P[i]), R[P[i]] = i, Set(i, P[i]);
    for (int i = 0; i <= (n - 1) / k; i++)
        Do(i);
    for (int i = n; i; i --)
    {
        int id = Pq.top();
        Pq.pop();
        A[id] = i;
        Set(id, 0);
        M[(id - 1) / k] = 0;
        Do((id - 1) / k);
        Do((id - 1) / k - 1);
        Do((id - 1) / k + 1);
    }
    for (int i = 1; i <= n; i++)
        printf("%d\n", A[i]);
    return 0;
}

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

using namespace std;

string compare(int a, int b) {
	string sa, sb;
	sa = string(b, a + '0');
	sb = string(a, b + '0');
	return (sa < sb) ? sa : sb;
}

int main() {
	int a, b;
	cin >> a >> b;
	cout << compare(a, b);
	return 0;
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
  	string s;
  	cin>>s;
  	if (s == "AAA" || s == "BBB") {
      cout<<"No"<<endl;
    } else {
      cout<<"Yes"<<endl;
    }
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ABS1(x,y) (x)>(y)?(x)-(y):(y)-(x)
#define ABS2(x,y) ((x)-(y))*((x)-(y))
#define ABS3(x,y) (x)>(y)?((x)-(y))*((x)-(y))*((x)-(y)):((y)-(x))*((y)-(x))*((y)-(x))
#define MAX(x,y) (x)>(y)?(x):(y)

using namespace std;
array<long double,100> x;
array<long double,100> y;

int main(){ _;
  int n=0; cin>>n;
  REP(i,n) cin>>x[i];
  REP(i,n) cin>>y[i];

  long double one=0,two=0,three=0,inf=0;
  REP(i,n){
    one+=ABS1(x[i],y[i]);
    two+=ABS2(x[i],y[i]);
    three+=ABS3(x[i],y[i]);
    inf=max(inf,ABS1(x[i],y[i]));
  }
  printf("%.6Lf\n",one);
  printf("%.6Lf\n",pow(two,1./2));
  printf("%.6Lf\n",pow(three,1./3));
  printf("%.6Lf\n",inf);
}

Measured memory_bytes: 1284
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
N = ri()
A = ri_()
ans = 1
for i in range(N):
    ans = ans * A[i]
    if ans > 1000000000000000000:
        ans = -1
        break
if 0 in A:
    print(0)
else:
    print(ans)

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

#define forn(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vii;

const int ma=1e5+5;
vector<vector<int>> v(ma);
int in_degree[ma];
bool visited[ma];
int dist[ma];

void dfs(int s){
    assert(!visited[s]);
    visited[s]=true;
    for(int i:v[s]){
        dist[i]=max(dist[i],dist[s]+1);
        --in_degree[i];
        if(in_degree[i]==0)dfs(i);
    }
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);	
        int n,m;
        cin>>n>>m;
        for(int i=0;i<m;i++){
            int x,y;
            cin>>x>>y;
            v[x].push_back(y);
            ++in_degree[y];
        }
        for(int i=1;i<=n;i++){
            if(!visited[i] && in_degree[i]==0)dfs(i);
        }
        int ans=0;
        for(int i=1;i<=n;i++){
            ans=max(ans,dist[i]);
        }
        cout<<ans<<endl;

}


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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    int ans=1000000007;
    for(int j=0;j<n;j++){
        cin >> x.at(j);
    }
    for(int i=1;i<101;i++){
        int tmp=0;
        for(int j=0;j<n;j++){
            tmp+=(x.at(j)-i)*(x.at(j)-i);
        }
        if(ans>tmp)ans=tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		String[] cut = x.split(" ");
		int a = Integer.parseInt(cut[0]);
		int b = Integer.parseInt(cut[1]);
		String w = "Draw";

		if (a == 1) {
			a = 14;
		}
		if (b == 1) {
			b = 14;
		}

		if (a > b) {
			w = "Alice";
		} else if (a < b) {
			w = "Bob";
		}

		System.out.println(w);
	}
}

Measured memory_bytes: 22612
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vs;
int main() {
	ll x;
	cin >> x;
	if (x%11==0) {
		cout << (x / 11) * 2 << endl;
	}
	else {
		ll d = x / 11;
		ll m = x % 11;
		d *= 2;
		if (m<=6) {
			d+=1;
		}
		else {
			d += 2;
		}
		cout << d << endl;
	}

};

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
#define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() {
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    double long a,b;
    cin>>a>>b;
    cout<<long(a*b);

    return 0;
}


Measured memory_bytes: 3744
import java.util.*;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int n = sc.nextInt();//宝石数
      
      //配列
      int value[] = new int[n];
      int cost[]  = new int[n];
      
      int truth =0;
      int max =0;
      
      //宝石の価値の配列作成
      for(int i=0; i<n; i++){
        value[i] = sc.nextInt();
      }
      
      //コストの配列作成  
      for(int i=0; i<n; i++){
        cost[i]  = sc.nextInt();
      }   
     
      for(int i=0; i<n; i++){
       //価値からコストを引くことで「真の価値」を求める
      	if(value[i]>=cost[i] && cost[i]>=0){
          truth = value[i] - cost[i];
          max += truth;   
        }
      }
      System.out.println(max);
    }
}

Measured memory_bytes: 21844
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def gcd_list(nums):
    return reduce(gcd, nums)

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))
diff = [abs(xi - X) for xi in x]
print(gcd_list(diff))




Measured memory_bytes: 14596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll n;
	cin>>n;
	double sum=0;
	for (int i = 0; i < n; ++i)
	{
		double x;
		cin>>x;
		sum+=(1/x);

	}
	cout<<(1/sum)<<"\n";

}



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

int main()
{
  vector<int> a(3);
  vector<int> b(3);
  int i;
  for(i = 0; i < 3; i++)
  {
    cin >> a.at(i);
    cin >> b.at(i);
  }
  vector<int> count(4);
  for(i = 0; i < 3; i++)
  {
    count.at(a.at(i)-1)++;
    count.at(b.at(i)-1)++;
  }
  int s = 0;
  for(i = 0; i < 4; i++)
  {
    if(count.at(i) >= 3)
    {
      s = 1;
      break;
    }
  }
  if(s == 1)
  {
    cout << "NO" << endl;
  }
  else
  {
    cout << "YES" << endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, init, n) for(int i = init; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

int main()
{
    int a, b, c;
    
    while(cin >> a >> b >> c, a, b, c)
    {
        vector<int> sta(a + b + c + 1, 2);

        int N;
        cin >> N;

        vector<tuple<int, int, int, int>> vec;

        rep(num, N)
        {
            int i, j, k, r;

            cin >> i >> j >> k >> r;

            vec.push_back(make_tuple(r, i, j, k));
        }

        sort(vec.begin(), vec.end(), greater<tuple<int, int, int, int>>());

        rep(num, N)
        {
            int i, j, k, r;
            tie(r, i, j, k) = vec[num];

            if(r == 1)
            {
                sta[i] = 1;
                sta[j] = 1;
                sta[k] = 1;
            }
            else if(r == 0)
            {
                int cnt = 0;

                 for(int pro : {i, j, k})
                {
                    if(sta[pro] == 1) cnt++;
                }

                if(cnt != 2) continue;

                for(int pro : {i, j, k})
                {
                    if(sta[pro] == 1) continue;

                    sta[pro] = 0;
                }
            }   
        }

        rep(i, a + b + c) cout << sta[i + 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3020
d = {}
N, K = map(int, input().split())
for _ in range(N):
    a,b = map(int, input().split())
    if a not in d:d[a] = 0
    d[a] += b
now = 0
for i , v in sorted(d.items()):
    now += v
    if now >= K:
        print(i)
        break


Measured memory_bytes: 14564
import sys

N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

s = [0 for i in range(N)]

for i in range(N):
    if i == 0:
        s[i] = a[i]
    else:
        s[i] = s[i-1] + a[i]

    if s[i] > x:
        print(i)
        sys.exit()

if s[-1] < x:
    print(N-1)
else:
    print(N)


Measured memory_bytes: 38512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<pair<ll, ll>> que;
    rep(i, n) {
        ll a;
        cin >> a;
        que.emplace(a, 1);
    }
    rep(i, m) {
        ll b,c;
        cin >> b >> c;
        que.emplace(c, b);
    }
    ll ans = 0;
    ll cnt = n;
    while (cnt)
    {
        // pair
        auto p = que.top(); que.pop();
        ans += p.first * min(cnt, p.second);
        cnt -= min(cnt, p.second);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6256
#include <iostream>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; in(N);
  int digit = 1+log10(N);
  int ans = 0;
  rep(d, digit+1) {
    rep(bit, pow(3, d)) {
      int n = 0;
      bool has_3 = false, has_5 = false, has_7 = false;
      rep(i, d) {
        int a = (int)(bit / pow(3, i)) % 3;
        n *= 10;
        if (a == 0) {
          n += 3; has_3 = true;
        } else if (a == 1) {
          n += 5; has_5 = true;
        } else {
          n += 7; has_7 = true;
        }
      }
      if (has_3 && has_5 && has_7 && n <= N)
        ++ans;
    }
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

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

        for (int i = 0; i < n; i++){
            int a = scanner.nextInt();
            if (a%2 == 0){
                if (a%3 != 0 && a%5 != 0){
                    answer = "DENIED";
                    break;
                }
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 23892
#!/usr/bin/env python3
import sys
from collections import deque
from copy import copy

def get_digits(i):
    last_digit = int(str(i)[-1])
    if last_digit in list(range(1,9)):
        return [last_digit-1, last_digit, last_digit+1]
    elif last_digit == 0:
        return [last_digit, last_digit+1]
    elif last_digit == 9:
        return [last_digit-1, last_digit]

def solve(K: int):
    deq1 = deque()
    deq2 = deque()
    lunlun_list = []

    for i in range(1,10):
        deq1.append(i)
        lunlun_list.append(i)

    while  len(lunlun_list) <= 10 ** 5:
        num = deq1.popleft()
        digits = get_digits(num)
        for new_digit in digits:
            new_num = int(str(num)+str(new_digit))
            lunlun_list.append(new_num)
            deq2.append(new_num)

        if len(deq1) == 0:
            deq1 = copy(deq2)
            deq2 = deque()

    print(lunlun_list[K-1])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


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

typedef signed long long ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) x.begin(),x.end()

#define DEBUG

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

	int ans;
	if(a > 9 || b > 9)
	{
		ans = -1;
	}
	else
	{
		ans = a * b;
	}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <algorithm>

int main() {
  std::string A;
  std::cin >> A;
  std::vector<bool> used('z' - 'a' + 1, false);
  std::vector<int> segment(A.size() + 1, 0);
  auto cnt = 'z' - 'a' + 1;
  auto seg_cnt = 0;
  segment[A.size()] = -1;
  for (auto i = A.size(); i > 0; --i) {
    segment[i - 1] = seg_cnt;
    if (!used[A[i - 1] - 'a']) {
      used[A[i - 1] - 'a'] = true;
      --cnt;
      if (cnt == 0) {
        ++seg_cnt;
        cnt = 'z' - 'a' + 1;
        std::fill(used.begin(), used.end(), false);
      }
    }
  }

  std::vector<std::vector<int>> idx('z' - 'a' + 1);
  for (unsigned i = 0; i < A.size(); ++i) {
    idx[A[i] - 'a'].push_back(i);
  }
  for (auto &i : idx) { i.push_back(A.size()); }

  int pos = 0;
  for (int l = seg_cnt; l > -1; --l) {
    for (int i = 0; i < 'z' - 'a' + 1; ++i) {
      auto p = std::lower_bound(idx[i].begin(), idx[i].end(), pos);
      if (*p == (int) A.size() || segment[*p] == l - 1) {
        std::cout << (char) ('a' + i);
        pos = *p + 1;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2172
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


inline void print(){
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest){
    cout << first << ' ';
    print(rest...);
}


void solve() {
    int A, B; cin >> A >> B;
    int A0 = (A * 100 + 7) / 8, A1 = ((A + 1) * 100 - 1) / 8;
    int B0 = B * 10, B1 = (B + 1) * 10 - 1;

    //print(A0, A1, B0, B1);

    if (B0 <= A0 && A0 <= B1) {
        cout << A0 << endl;
        return;
    }
    else if (A0 <= B0 && B0 <= A1) {
        cout << B0 << endl;
        return;
    }
    else {
        cout << -1 << endl;
        return;
    }
}


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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args){

		final String YES	= "Yes";
		final String NO		= "No";

		String res = YES;

		// TODO ABC_086_C
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();

		int tNow = 0;
		int xNow = 0;
		int yNow = 0;
		int tNext = 0;
		int xNext = 0;
		int yNext = 0;

		int xDist = 0;
		int yDist = 0;

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

			tNext = sc.nextInt();
			xNext = sc.nextInt();
			yNext = sc.nextInt();

			if(tNext%2 != (xNext+yNext)%2) {
				res = NO;
				break;
			}

			xDist = Math.abs(xNext - xNow);
			yDist = Math.abs(yNext - yNow);

			if(tNext - tNow < xDist + yDist) {
				res = NO;
				break;
			} else {
				tNow = tNext;
				xNow = xNext;
				yNow = yNext;
			}
		}

		// Scannerクラスのインスタンスをクローズ
		sc.close();

		System.out.println(res);
	}
}


Measured memory_bytes: 57748
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 sum = a + kaijou2(a) + kaijou3(a);
      	System.out.println(sum);
    }
  
  	public static int kaijou2 (int a) {
      	return a*a;
    }
  
  	public static int kaijou3 (int a) {
      	return a*a*a;
    }
}

Measured memory_bytes: 35712
#include <iostream>

using namespace std;

int main(){
  int n,m;
  while(cin >> n >> m ,n||m){
    int i,j,tarosum = 0,hanasum = 0;
    int taro[n],hana[m],tans=-1,hans=-1,sum=0;
    for(i=0;i<n;i++){
      cin >> taro[i];
      tarosum += taro[i];
    }
    for(i=0;i<m;i++){
      cin >> hana[i];
      hanasum += hana[i];
    }
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
        if(tarosum-taro[i]+hana[j] == hanasum-hana[j]+taro[i]){
          if(tans==-1){
            tans = taro[i];
            hans = hana[j];
            sum = tans + hans;
            continue;
          }
          if(taro[i]+hana[j]<sum){
            tans = taro[i];
            hans = hana[j];
          }
        }
      }
    }
    if(tans<0)cout << -1 << endl;
    else cout << tans << " " << hans << endl;
  }
  return 0;
}



Measured memory_bytes: 2988
import math
n=int(input())
l=[[int(i) for i in input().split()] for j in range(n)]
d=[]
for i in range(n):
  for j in range(i):
    d.append(((l[i][0]-l[j][0])**2+(l[i][1]-l[j][1])**2)**0.5)
total=[]
print(sum(d)*(n-1)/len(d))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i<(n); i++)
using namespace std;
using vec2div = vector<vector<long long>>;
using vec = vector<long long>;
using ll = long long;


int main(){
	int x,n,min,kai;
	
	cin >> x >> n;
	
	if(abs(101-x) < x){
		min = abs(101-x);
		kai = 101;
	}else{
		min = x;
		kai = 0;
	}
	int i;
	if(n==0){
		cout << x << endl;
		return 0;
	}
	vector<int> p(n);
	for(i=0;i<n;i++){
		cin >> p.at(i);
	}
	sort(p.begin(),p.end());
	int j=0;
	for(i=1;i<=100;i++){
		//cout << min << endl;
		if(i == p.at(j)){
			if(j != n-1)j++;
			continue;
		}
		if(abs(x-i)==min){
			if(kai > i)kai = i;
		}
		if(abs(x-i)<min){
          min = abs(x-i);
          kai = i;
        }
	}
	cout << kai  << endl;
		
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int d,g;
	cin>>d>>g;
	vector<int> p(d),c(d);
	rep(i,d){
		cin>>p[i]>>c[i];
	}
	int ans=INF;
	rep(S,1<<d){
		int point=0,cnt=0;
		rep(i,d){
			if(S & 1<<i){
				point+=100*(i+1)*p[i]+c[i];
				cnt+=p[i];
			}
		}
		if(point>=g){
			chmin(ans,cnt);
			continue;
		}
		for(int i=d-1;i>=0;i--){
			if(S & 1<<i) continue;
			rep(_,p[i]-1){
				if(point>=g) break;
				point+=100*(i+1);
				cnt++;
			}
		}
		if(point>=g){
			chmin(ans,cnt);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using i64 = int64_t;
#define rep(i, s, n) for (i64 i = (s); i < (n); ++i)

int main() {
  cin.tie(nullptr);

  i64 D, T, S;
  cin >> D >> T >> S;
  cout << ((D <= (S * T)) ? "Yes" : "No") << endl;

  return 0;
}


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

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

using namespace std;

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


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int c[3][3];
    forn(i,3){
        forn(j,3){
            cin>>c[i][j];
        }
    }

    int a0,a1,a2,b0,b1,b2;
    forn(a0,101){
        b0 = c[0][0] - a0;
        b1 = c[0][1] - a0;
        b2 = c[0][2] - a0;
        a1 = c[1][0] - b0;
        a2 = c[2][0] - b0;
        if(a1+b1==c[1][1] && a2+b2==c[2][2] && a1+b2==c[1][2] && a2+b1==c[2][1]){
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;
}



Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int N, Q;
  cin >> N >> Q;
  vector<ll> stk;
  stk.push_back(N);
  while (Q--) {
    ll q;
    cin >> q;
    while (!stk.empty() && stk.back() >= q)
      stk.pop_back();
    stk.push_back(q);
  }
  vector<ll> cnt(stk.size()), ans(N + 1);
  cnt.back() = 1;
  int m = stk.size();
  while (m--) {
    ll cur = stk[m], con = cnt[m];
    while (cur > stk[0]) {
      int pos = upper_bound(stk.begin(), stk.begin() + m, cur) - stk.begin() - 1;
      cnt[pos] += cur / stk[pos] * con;
      cur %= stk[pos];
    }
    ans[cur] += con;
  }
  for (int i = N - 1; i; --i) ans[i] += ans[i + 1];
  for (int i = 1; i <= N; ++i) cout << ans[i] << '\n';

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

int main(){
  int n,y,x,z,a[6] = {500,100,50,10,5,1},b[6],c[6] = {1000,100,50,10,5,0};
  cin >> x;		//1024
  
  for(int i=0;i<6;i++)
  {
    y=x/a[i];		//y will have the multiple
    b[i]=y;			//storing multiple value in array b[]
    x=x-(y*a[i]);   //updating the value of x
  }
  for(int i=0;i<6;i++)
  {
    z = z+(b[i]*c[i]);
  }
  cout<<z;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int whiteCells = H * W;
		whiteCells -= h * W;
		whiteCells -= w * (H-h);
		System.out.println(whiteCells);

	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10, inf = 1e9;
int n , m, ans;
char s[22][22];
int dist[22][22];
bool ok(int i, int j){
    if(i <= 0 || i > n || j <= 0 || j > m) return false;
    if(s[i][j] == '#') return false;
    return true;
}
void bfs(int i, int j){
    queue<pair<int, int>> q;
    q.emplace(i, j);
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m ;j ++)
            dist[i][j] = inf;
    }
    dist[i][j] = 0;
    while(!q.empty()){
        int x = q.front().first, y = q.front().second;
        q.pop();
        if(ok(x - 1, y) && dist[x - 1][y] == inf){
            dist[x - 1][y] = dist[x][y] + 1;
            ans = max(ans, dist[x - 1][y]);
            q.push(make_pair(x - 1 , y));
        }
        if(ok(x + 1, y) && dist[x + 1][y] == inf){
            dist[x + 1][y] = dist[x][y] + 1;
            q.push(make_pair(x + 1 , y));
            ans = max(ans, dist[x + 1][y]);
        }
        if(ok(x, y - 1) && dist[x][y - 1] == inf){
            dist[x][y - 1] = dist[x][y] + 1;
            q.push(make_pair(x  , y - 1));
            ans = max(ans, dist[x][y - 1]);
        }
        if(ok(x, y + 1) && dist[x][y + 1] == inf){
            dist[x ][y + 1] = dist[x][y] + 1;
            q.push(make_pair(x, y + 1));
            ans = max(ans, dist[x][y + 1]);
        }
    }
}

int main(){
    scanf("%d %d", &n, &m);
    for(int i = 1 ;i <= n; i++)
        scanf("%s", s[i] + 1);
    for(int i = 1 ;i <= n; i++){
        for(int j =1 ; j <= m ;j ++){
            if(s[i][j] != '#')
                bfs(i, j);
        }
    }
    printf("%d\n", ans);
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 256