akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s;
    cin >> s;

    int n = s.length();
    vbool flg(n, false);
    rep(i, n) if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') flg[i] = true;

    int ans = 0;
    rep(i, n) {
        int tmp = 0;
        srep(j, i, n) {
            if (!flg[j]) break;
            else tmp++;
        }
        ans = max(ans, tmp);
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 1e3 + 7;
const int M = 5e3 + 7;

int x[N];
vector<int> g[N];

int dp[N];

void dfs(int cur) {
	bitset<2 * M> c;
	c[0] = 1;
	int s = 0;
	for (auto t : g[cur]) {
		dfs(t);
		c = (c << x[t]) | (c << dp[t]);
		s += x[t];
		s += dp[t];
	}
	for (int i = x[cur]; i >= 0; i--) {
		if (c[i]) {
			dp[cur] = s - i;
			return;
		}
	}
	cout << "IMPOSSIBLE\n";
	exit(0);
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int p;
		cin >> p;
		p--;
		g[p].push_back(i);
	}
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	dfs(0);
	cout << "POSSIBLE\n";
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-10, PI = acos(-1);
const int N = 3e5 + 9, M = 1e5 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll x[N], y[N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n;
  cin >> n;
  vector<pair<long double, pair<ll, ll>>> vec;
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
    vec.push_back({atan2(x[i], y[i]), {x[i], y[i]}});
  }
  sort(vec.begin(), vec.end());
  double best = 0;
  for (int i = 0; i < n; ++i) {
    ll X = 0, Y = 0;
    for (int j = 0; j < n; ++j) {
      int nxt = (i + j);
      if(nxt >= n)
        nxt -= n;
      X += vec[nxt].second.first, Y += vec[nxt].second.second;
      best = max(best, sqrt(X * X + Y * Y));
    }
  }
  cout << best;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var k = p[1];
		var people = new bool[n];
		for(int i = 0; i < k; i++)
		{
			var d = Console.ReadLine().ToInt();
			p = Input().ToInt();
			for(int j = 0; j < d; j++)
			{
				people[p[j]-1] = true;
			}
		}
		int wa = 0;
		for(int i = 0; i < n; i++)
		{
			if(!people[i])
				wa++;
		}
		Console.WriteLine(wa);
		
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 27640
<?php
fscanf(STDIN, "%d%d%d", $N, $M, $R);
$rArray = array_map("intval", explode(" ", trim(fgets(STDIN))));

$wf = new Wf($N);
for($i = 0; $i < $M; $i++){
  fscanf(STDIN, "%d%d%d", $a, $b, $c);
  $wf->connect($a, $b, $c);
}
$d = $wf->solve();

echo dfs($rArray, -1);
function dfs($rArray, $current){
  global $d;
  if(!$rArray)return 0;
  $min = 10**10;
  foreach($rArray as $i => $p){
    $array = $rArray;
    unset($array[$i]);
    $dist = dfs($array, $p);
    if($current != -1){
      $dist += $d[$current][$p];
    }
    if($dist < $min){
      $min = $dist;
    }
  }
  return $min;
}

class Wf{
  public $d;
  public $n;
  function __construct($n)	{
    $this->n = $n;
    for($i = 1; $i <= $this->n; $i++){
      for($j = 1; $j <= $this->n; $j++){
        $this->d[$i][$j] = 10**18;
      }  
    }
  }
  function connect($a, $b, $c){
    $this->d[$a][$b] = $c;
    $this->d[$b][$a] = $c;
  }
  function solve(){
    for($k = 1; $k <= $this->n; $k++){
      for($i = 1; $i <= $this->n; $i++){
        for($j = 1; $j <= $this->n; $j++){
          if($this->d[$i][$j] > $this->d[$i][$k] + $this->d[$k][$j]){
            $this->d[$i][$j] = $this->d[$i][$k] + $this->d[$k][$j];
          }
        }
      }
    }
    return $this->d;
  }
}


Measured memory_bytes: 6648
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

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

string button[10] = {"12345678", ".,!? ", "abc", "def", "ghi", "jkl" , "mno", "pqrs", "tuv", "wxyz" };


int main()
{

    int n;
    cin >> n;
    string s;
    rep(j,n)
    {
        cin >> s;
        int bnum = 0;
        int pushnum = 0;
        REP(s.size())
        {
            if(s[i] == '0' && pushnum > 0)
            {
                cout << button[bnum][(pushnum + button[bnum].size() - 1) % button[bnum].size()];
                pushnum = 0;
                bnum = 0;
                continue;
            }
            if(s[i] != '0'){ pushnum = (pushnum+1) ; bnum = s[i] - '0'; }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        llin(a);
        llin(b);
        sal((a>12)?b:((a>5)?b/2:0))
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(int argc, char const *argv[]) {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, C;
    cin >> N >> C;
    v2int D(C, vint(C));
    rep(i, C) {
        rep(j, C) cin >> D[i][j];
    }
    v2int G(N, vint(N));
    rep(i, N) {
        rep(j, N) cin >> G[i][j];
    }

    ll ans = LINF;

    vector<unordered_map<int, int>> Colors(3);
    rep(i, N) {
        rep(j, N) {
            Colors[(i + 1 + j + 1) % 3][G[i][j] - 1]++;
        }
    }
    
    rep(i, C) {
        rep(j, C) {
            if (i == j) continue;
            rep(k, C) {
                if (i == k) continue;
                if (j == k) continue;
                ll cost = 0;
                for (auto& from_color_num : Colors[0]) {
                    cost += ll(D[from_color_num.first][i]) * ll(from_color_num.second);
                }
                for (auto& from_color_num : Colors[1]) {
                    cost += ll(D[from_color_num.first][j]) * ll(from_color_num.second);
                }
                for (auto& from_color_num : Colors[2]) {
                    cost += ll(D[from_color_num.first][k]) * ll(from_color_num.second);
                }
                ans = min(cost, ans);
            }
        }
    }

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

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

int main() {
    int n, x;
    cin >> n >> x;
    int m[200];
    int d = 0;
    int ans = 1;
    int z;

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

    for(int i = 0; i < n; i++){
        z = d + m[i];
        if(x >= z){
            ans++;
        }
        d = z;


    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int N, K, x, sum=0;
  scanf("%d%d", &N, &K);
  for (int i=0; i<N ;i++){
    scanf("%d",&x);
    if (K-x > x){
      sum += 2 * x;
    }
    else{
      sum += 2 * (K - x);
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
import sys
n = int(input())
A = list(map(int,sys.stdin))
cnt = 0
G = [int((2.25**i-1)/1.25)for i in range(17,0,-1)]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
for g in G:
    insertionSort(A, n, g)
print(len(G))
print(*G)
print(cnt)
print(*A, sep='\n')


Measured memory_bytes: 53388
#include <stdio.h>

int main(void)
{

  char a=0,b=0,c=0,d=0,e=0,f=0;
  
  scanf("%c%c%c%c%c%c",&a,&b,&c,&d,&e,&f);
  
  if(c==d)
  {
    if(e==f)
    {
      printf("Yes");
    }
    else
    {
      printf("No");
    }
  }
  else
  {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int W,a,b;
    cin >> W >> a >> b;
    int ans=INF;
    if(b>=a && b<=a+W) ans=0;
    if(b+W>=a && b+W<=a+W) ans=0;
    ans=min3(ans,abs(b-a-W),abs(b+W-a));
    cout << ans << endl;
}

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

using namespace std;

#define int long long
#define pb push_back
#define fi first
#define se second
typedef pair<int, int> ii;

const int N = 1e5 + 5;
int n, nChild[N], up[N], down[N];
vector<ii> d;
vector<int> gr[N], ver;

void dfs1 (int u, int p) {
    for (int v : gr[u]) if (v != p) {
        dfs1(v, u);
        down[u] += down[v] + nChild[v];
    }
}

void dfs2 (int u, int p) {
    for (int v : gr[u]) if (v != p) {
        up[v] = up[u] + down[u] - down[v] - nChild[v] + n - nChild[v];
        dfs2(v, u);
    }
}

signed main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int _ = 1; _ <= n; ++_) {
        nChild[_] = 1;
        int D; cin >> D;
        d.pb(ii(D, _) );
    }
    sort(d.begin(), d.end() );

    for (int i = d.size() - 1; i > 0; --i) {
        int u = d[i].se;
        int pos = lower_bound(d.begin(), d.end(), ii(d[i].fi - n + 2 * nChild[u], 0) ) - d.begin();
        if (pos == n || d[pos].fi != d[i].fi - n + 2 * nChild[u]) return cout << -1, 0;
        int v = d[pos].se;
        gr[u].pb(v); gr[v].pb(u);
        nChild[v] += nChild[u];
    }

    dfs1(d[0].se, 0);
    dfs2(d[0].se, 0);
    for (auto _ : d) {
        if (_.fi != up[_.se] + down[_.se]) return cout << -1, 0;
    }

    for (int i = 1; i <= n; ++i) {
        for (int j : gr[i]) if (i > j) cout << i << ' ' << j << '\n';
    }

    return 0;
}


Measured memory_bytes: 13552
#include<stdio.h>
int main(){
int i,v,j,n,l;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(l=0;l<n-1;l++){
printf("%d ",a[l]);
}
printf("%d",a[n-1]);
printf("\n");
for(i=1;i<=n-1;i++){
v=a[i];
j=i-1;
while(j>=0 && a[j]>v){
a[j+1]=a[j];
j--;
a[j+1]=v;
}
for(l=0;l<n-1;l++){
printf("%d ",a[l]);
}
printf("%d",a[n-1]);
printf("\n");
}
}



Measured memory_bytes: 2124
n, m = map(int, input().split())
py = [list(map(int, input().split())) + [0] for _ in range(m)]
py_sorted = sorted(py, key=lambda x: x[1])
d = {}

for pyi in py_sorted:
    if pyi[0] not in d:
        d[pyi[0]] = 1
    else:
        d[pyi[0]] += 1
    pyi[2] = d[pyi[0]]

for pyi in py:
    print(str(pyi[0]).zfill(6) + str(pyi[2]).zfill(6))


Measured memory_bytes: 30096
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> f(n, 0);
  rep(i, n){
    int add = 0;
    rep(j, 10){
      int ff;
      cin >> ff;
      if(ff == 1){
        add += 1 << j;
      }
    }
    f.at(i) = add;
  }
  vector<vector<int>> p(n, vector<int>(11));
  rep(i, n){
    rep(j, 11){
      int a;
      cin >> a;
      p.at(i).at(j) = a;
    }
  }
  int ans = -1e9;
  rep2(bit, 1, 1 << 10){
    int add = 0;
    rep(i, n){
      int temp = bit & f.at(i);
      int co = __builtin_popcount(temp);
      add += p.at(i).at(co);
    }
    ans = max(ans, add);
  }
  cout << ans << endl;
  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,A,B;

vpint latte[5];


pint operator+(const pint &a,const pint &b){
    return {a.fi+b.fi,a.se+b.se};
}

signed main(){
    cin>>N>>A>>B;
    rep(i,N){
        int t,a,b;
        cin>>t>>a>>b;
        t--;
        latte[t].pb({a,b});
    }

    rep(i,5)latte[i].pb({0,0});

    vpint luz,izr;
    for(auto &a:latte[0])for(auto &b:latte[1])for(auto &c:latte[2])luz.pb(a+b+c);
    for(auto &d:latte[3])for(auto &e:latte[4])izr.pb(d+e);
    sort(all(luz));
    sort(all(izr));
    multiset<int>st;
    st.insert(1001001001001001001ll);

    int l=luz.size(),r=luz.size();
    for(auto &w:izr){
        while(l>0&&luz[l-1].fi+w.fi>=A){
            st.insert(luz[l-1].se);
            l--;
        }
        while(r>0&&luz[r-1].fi+w.fi>B){
            auto it=st.find(luz[r-1].se);
            st.erase(it);
            r--;
        }

        auto it=st.lower_bound(A-w.se);
        if(*it+w.se<=B){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 67436
h, n = map(int, input().split())
a = []
b = []
for i in range(n):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)

dp = [10**9] * (h+1)
dp[0] = 0

for i in range(1, h+1):
    for j in range(n):
        dp[i] = min(dp[i], dp[max(i-a[j], 0)] + b[j])

print(dp[-1])

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

using namespace std;
typedef long long ll;

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}

int main() {
    ll x;
    cin >>  x;
    ll ans = 0;

    for(;;){
        if(primeNumber(x)){
            ans = x;
            break;
        }
        x++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
typedef long long int ll;

int N;
int num[] = {3, 5, 7};
vector<ll> va;

void rec(ll a){
	if(a > N) return ;
	for(int i = 0; i < 3; i++){
		if(10 * a + num[i] <= N){
			va.push_back(10 * a + num[i]);
			rec(10 * a + num[i]);
		}
	}
	return ;
}

int main(){
	scanf("%d", &N);
	int res = 0;
	rec(0);
	for(int i = 0; i < va.size(); i++){
		ll a = va[i];
		bool b[3] = {false, false, false};
		while(a > 0){
			if(a % 10 == 3) b[0] = true;
			if(a % 10 == 5) b[1] = true;
			if(a % 10 == 7) b[2] = true;
			a /= 10;
		}
		if(b[0] == false || b[1] == false || b[2] == false) continue;
		if(a <= N) res++;
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 640
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
BA = [[] for i in range(N)]
for i in range(N):
    a,b = LI()
    BA[i] = (b,a)

BA.sort()

tmp  = 0
for i in range(N):
    b,a = BA[i]
    tmp += a
    if b - tmp < 0:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 31932
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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;
}

int main(void) {
    int N;
    cin >> N;

    const double BTC = 380000.0;
    double ans = 0;
    for (int i = 0; i < N; i++) {
        double x;
        string u;
        cin >> x >> u;

        if (u == "JPY") {
            ans += x;
        } else {
            ans += x * BTC;
        }
    }

    printf("%.6f\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <string.h>
#define MOD 1000000007
#define N_MAX 200006

using namespace std;
typedef long long ll;

void rek(int fre, int s, int t){
	if(__builtin_popcount(fre) == 1){
		cout << s << ' ' << t << ' ';
	} else {
		int p = 1;
		while(!(fre&p) || !((s^t)&p) )
			p <<= 1;
		int q = 1;
		while(p == q || !(fre&q))
			q <<= 1;
		rek(fre^p, s, s^q);
		rek(fre^p, s^q^p, t);
	}
}
 
int main(){
	int N, A, B;
	cin >> N >> A >> B;
	if(__builtin_popcount(A^B) % 2 == 0){
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
		rek((1<<N)-1, A, B);
		cout << endl;
	}
}

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

#define ULL unsigned long long

using namespace std;

int n,m;

int fa[100009];

int findf(int x)
{
    if(fa[x]==x)return x;
    return fa[x]=findf(fa[x]);
}

void uni(int x,int y)
{
    x=findf(x);y=findf(y);
    fa[x]=y;
}

bool vis[100009];

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)fa[i]=i;
    int u,v;
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&u,&v);
        uni(u,v);
    }
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[findf(i)])
        {
            vis[findf(i)]=1;
            cnt++;
        }
    }
    printf("%d",cnt-1);
    return 0;
}


Measured memory_bytes: 4312
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    ll L, R;  cin >> L >> R;
    
    ll ans = 2018;
    ll mod = 2019;
    for(ll l=L; l<=min(L+2018, R); l++) for(ll r = l+1; r<=min(l+2019, R); r++){
        ans = min(ans, (l*r)%mod);
    }
    cout << ans << endl;
}


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

#if 0
#define DEBUG(x) do{cerr << #x << "=" << x << endl;}while(0);
#else
#define DEBUG
#endif

bool check( vector<int> a, int n ){
	for(int i=1; i<n; ++i){
		if( a[i] < a[i-1] ){
			return false;
		}
	}
	return true;
}

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	for(int i=0; i<n; ++i){
		cin >> p[i];
	}
	
	bool ans = check( p, n );
	for(int i=0; i<n; ++i){
		for(int j=i+1; j<n; ++j){
			if( p[i] > p[j] ){
				int tmp = p[i];
				p[i] = p[j];
				p[j] = tmp;

				if( true == check( p, n ) ){
					ans = true;
				}

				tmp = p[i];
				p[i] = p[j];
				p[j] = tmp;
			}
		}
	}

	cout << (ans ? "YES" : "NO") << endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int rem = N % 1000;
  int ans = 1000;
  if(rem == 0) cout << rem <<endl;
  if(rem > 0) {
    ans -= rem;
    cout << ans << endl;
  }
}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
    	var sc = new Scanner();
    	int n = sc.NextInt();
    	string s = sc.NextString();
    	int[] l = new int[300009];
    	int[] r = new int[300009];
    	for (int i = 0; i < n; i++)
    	{
    		if (s[i] == 'W') l[i]++;
    		else r[i]++;
    	}
    	for (int i = 1; i < n; i++)
    	{
    		l[i] += l[i - 1];
    		r[i] += r[i - 1];
    	}
    	int min = 1 << 30;
    	for (int i = 0; i < n; i++)
    	{
    		int c = (i > 0 ? l[i - 1] : 0) + r[n - 1] - r[i];
    		if (c < min) min = c;
    	}
    	Console.WriteLine(min);
    }
    
    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }
        
    public long NextLong()
    {
    	CheckNext();
    	return long.Parse(buf[index++]);
    }
    
    public double NextDouble()
    {
    	CheckNext();
    	return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}

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

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

  ll ans;
  if (b <= 0) {
    if (d <= 0) {
      ans = a * c;
    } else if (c <= 0) {
      ans = a * c;
    } else {
      ans = b * c;
    }
  } else if (a <= 0) {
    if (d <= 0) {
      ans = a * c;
    } else if (c <= 0) {
      ans = max(a * c, b * d);
    } else {
      ans = b * d;
    }
  } else {
    if (d <= 0) {
      ans = a * d;
    } else if (c <= 0) {
      ans = b * d;
    } else {
      ans = b * d;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	long int i, j;
	long int n;
	long int flg;
	long int count = 1;
	long int max = 0;
	long int tugi = 0;
	long int index_max;
	long int index_tugi;
	long int a[200000];
	
	scanf("%ld", &n);
	
	scanf("%ld%ld", &a[0], &a[1]);
	
	if(a[0] == a[1]) {
		max = tugi = a[0];
		count = 2;
	} else if(a[0] > a[1]) {
		max = a[0];
		tugi = a[1];
		index_max = 0;
		index_tugi = 1;
	} else {
		max = a[1];
		tugi = a[0];
		index_max = 1;
		index_tugi = 0;
	}
	
	for(i = 2; i < n; i++) {
		scanf("%ld", &a[i]);
		if(max < a[i]) {
			tugi = max;
			max = a[i];
			count = 1;
			index_tugi = index_max;
			index_max = i;
		} else if(max == a[i]) {
			count++;
		} else if(tugi < a[i]) {
			tugi = a[i];
			index_tugi = i;
		}
	}
	
	if(count == 1) {
		for(i = 0; i < n; i++) {
			if(i == index_max) {
				printf("%ld\n", tugi);
			} else {
				printf("%ld\n", max);;
			}
		}
	} else {
		for(i = 0; i < n; i++) {
			printf("%ld\n", max);
		}
	}
	
	return 0;
}


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

const int64_t mod = 1000000007;

int64_t dp[2010][2010];

void init() {
  dp[0][0] = 1;
  for (int i = 0; i < 2000; ++i) {
    for (int j = 0; j <= i; ++j) {
      dp[i+1][j] += dp[i][j] % mod;
      dp[i+1][j+1] += dp[i][j] % mod;
    }
  }
}

int64_t comb(int64_t x, int64_t y) {
  return dp[x][y];
}

int main(int argc, char *argv[]) {
  int n, k;
  cin >> n >> k;

  init();
  for (int i = 1; i <= k; ++i) {
    int64_t red = comb(n-k+1, i);
    int64_t blue = comb(k-1, i-1);

    cout << (blue * red) % mod << endl;
  }
  
  return 0;
}

Measured memory_bytes: 30208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	boolean[][] M;
	int n;
	boolean color[];
	int d[];
	int f[];

	private void run() {
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		M = new boolean[n][n];
		color =new boolean[n];
		d = new int[n];
		f = new int[n];
		for (int i = 0; i < n; i++) {
			int u = scanner.nextInt();
			int k = scanner.nextInt();
			u--;
			for (int j = 0; j < k; j++) {
				int v = scanner.nextInt();
				v--;
				M[u][v] = true;
			}
		}
		dfs();
	}

	private void dfs() {
		for (int u = 0; u < n; u++) {
			if (!color[u])
				dfs_visit(u);
		}
		for (int u = 0; u < n; u++) {
			System.out.printf("%d %d %d\n", u + 1, d[u], f[u]);
		}
	}

	int tt = 1;

	private void dfs_visit(int u) {
		color[u] = true;
		d[u] = tt++;
		for (int v = 0; v < n; v++) {
			if (!M[u][v])
				continue;
			if (!color[v]) {
				dfs_visit(v);
			}
		}
		f[u] = tt++;
	}
}

Measured memory_bytes: 21104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
/*using P = pair<int, int>;*/
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    int n, m, x; cin >> n >> m >> x;
    vector<vector<int> > a(n, vector<int>(m));
    vector<int> c(n);
    rep(i, n){
        cin >> c[i];
        rep(j, m){
            cin >> a[i][j];
        }
    }
    // bit全探索
    int ans = inf;
    for (int bit = 0; bit < (1<<n); ++bit){
        vector<int> S;
        int tmp_ans = 0;
        vector<int> understandings(m, 0);
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                tmp_ans += c[i];
                rep(j, m){
                    understandings[j] += a[i][j];
                }
            }
        }
        bool understand = true;
        rep(j, m){
            if(understandings[j] < x) understand = false;
        }
        if(understand) ans = min(ans, tmp_ans);
    }
    if(ans != inf) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long N, X;

int main() {
    while (cin >> N >> X) {
        long long d = GCD(N, X);
        N /= d;
        X /= d;
        long long res = (N - 1) * 3;
        cout << res * d << endl;
    }
}





Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

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

    if (n % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }

    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[i + n / 2]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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


using namespace std;


using ll = long long;


int main()
{
    ll N;
    map<ll, ll> cnt;

    cin >> N;
    for (ll i = 0; i < N; i++) {
        ll t;
        cin >> t;
        if (cnt.count(t) > 0) {
            cnt[t]++;
        } else {
            cnt[t] = 1;
        }
    }

    ll ans = 0;
    for (auto c : cnt) {
        if (c.second > c.first) {
            ans += c.second - c.first;
        } else if (c.second < c.first) {
            ans += c.second;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6272
#include <stdio.h>
int main(){
    int w,h,x,y,r;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    if(0 <= x-r && 0 <= y-r){
        if(x+r <= w && y+r <= h){
            printf("Yes\n");
        }
        else printf("No\n");
    }
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 2684
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


n=int(input())
mod=10**9+7

lst=[0]*1000

for i in range(2,n+1):
  x=factorization(i)
  for j in x:
    lst[j[0]]+=j[1]
    
ans=1

for i in lst:
  ans*=(i+1)
  ans%=mod
  
print(ans)

Measured memory_bytes: 74456
import java.util.Scanner;

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

		int ans = 0;
		int i;
		int length = s.length();
		for(i = 0; i < length; i++) {
			if(s.substring(i, i + 1).equals(t.substring(i, i + 1)))
				ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <unordered_map>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define REP(i,a,b) for(int i=a; i<=b; i++)
using namespace std;

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x,y,a;
    cin >> x >> y;
    unordered_map<int,int> z;
    for(int i=0; i<y; i++){
        cin >> a;
        z[a]=1;
    }
    if(z[x]==0) cout << x;
    else{
        int b=x-1,c=x+1;
        while(true){
            if(z[b]==0){
                cout << b;
                break;
            }
            if(z[c]==0){
                cout << c;
                break;
            }
            b--;
            c++;
        }
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    int n,ans=0;
    pint red[100], blue[100];
    bool isusedr[100],isusedb[100];
    cin >> n;
    REP(i,n)isusedr[i]=isusedb[i]=false;
    REP(i,n)cin >> red[i].SE >> red[i].FI;
    REP(i,n)cin >> blue[i].FI >> blue[i].SE;
    sort(red, red + n);
    sort(blue, blue + n);
    REP(i,n){
        int bx = blue[i].FI, by = blue[i].SE;
        IREP(j,n){
            int rx = red[j].SE, ry = red[j].FI;
            if (rx < bx && ry < by && !isusedr[j]){
                isusedr[j] = true;
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

using namespace std;

class BCountBalls {
public:
    void solve(istream& cin, ostream& cout) {
        ll n, a, b;
        cin >> n >> a >> b;
        cout << a * (n/(a+b)) + min(a, n%(a+b)) << '\n';
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    BCountBalls solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int A, B, C, D, P, x, y, charge;
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);
  scanf("%d", &D);
  scanf("%d", &P);
  x = A * P;
  if(P < C){
    y = B;
  }else{
    y = B + (P - C) * D;
  }
  if(x <= y){
    charge = x;
  }else{
    charge = y;
  }
  printf("%d\n", charge);
  return 0;
}

Measured memory_bytes: 596
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if(b - a == c - b){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}

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

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

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

    vector<int> ans;

    if(n == 0){
        cout << 0;
        return 0;
    }

    while(n != 0){
        if(n%2 == 0){
            
            ans.push_back(0);
        }else{
            n -= 1;
            ans.push_back(1);
        }
        n = -n/2;
    }

    for(int i = 0;i < ans.size();i++){
        cout << ans[ans.size()-1-i];
    }
    
    return 0;
}
//g++ -std=c++14 code1.cpp


Measured memory_bytes: 764
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    good = [True] * N
    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        if H[a] > H[b]:
            good[b] = False
        elif H[b] > H[a]:
            good[a] = False
        else:
            good[a] = False
            good[b] = False
    # print(good)
    ans = 0
    for i in range(N):
        if good[i]:
            ans += 1
    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 20336
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	ll n,m,x;cin>>n>>m>>x;
	ll a[n]={0},b[m];
	rep(i,0,m)cin>>b[i],a[b[i]]=1;
	ll ans=0,c=0;
	for(ll i=1;i<x;++i)if(a[i])ans++;
	rep(i,x+1,n)if(a[i])c++;
	cout<<min(ans,c);
	
	return 0;
}



Measured memory_bytes: 256
D, G = map(int, input().split())
P, C = [], []
for i in range(D):
    pi, ci = map(int, input().split())
    P.append(pi)
    C.append(ci)

ans = float('inf')
for i in range(2**D):
    A = []
    X_solve, X_score = 0, 0
    bit = bin(2**D + i)[3:]

    for j in range(D):
        if bit[j] == "1":
            X_solve += P[j]
            X_score += 100 * (j+1) * P[j] + C[j]
        else:
            A += [100*(j+1)] * P[j]

    if X_score >= G:
        ans = min(ans, X_solve)
        continue

    A = A[::-1]
    for k in range(len(A)):
        X_score += A[k]
        if X_score >= G:
            ans = min(ans, X_solve + k + 1)
            break

print(ans)


Measured memory_bytes: 42736
#include<stdio.h>
int main(){
	int s[9000],n,m,t,f,i;
	while(scanf("%d%d",&n,&m),n)
		for(i=t=f=1;i<=n+m;i++){
			scanf("%d",&s[i]);
			if(i>n){t+=s[t+=s[i]];
				if(t>=n&f==1)
					printf("%d\n",i-n,f=0);
			}
		}
}

Measured memory_bytes: 0
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0) break;
		if(a > b) printf("%d %d\n",b,a);
		else{
			printf("%d %d\n",a,b);
		}
	}
}



Measured memory_bytes: 2600
#include <stdio.h>

int main(){
  int i,j,v,A[1000],a,k;
  scanf("%d",&a);
  for(i=0; i<a; i++){
    scanf("%d",&A[i]);
  }
  for(i=0; i<a-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  for(i=1; i<=a-1; i++){
    v = A[i];
    j = i -1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(k=0; k<a-1; k++){
      printf("%d ",A[k]);
    }
    printf("%d\n",A[k]);
  }
}


Measured memory_bytes: 2764
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(final String[] args){
 
        final Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int ans=0;
        long q =2;
        long keep =N;
 
        if(N==1){
            System.out.println(0);
            return;
        }
 
        while(q*q<=N){
            if(N%q ==0){
                //N = N/q;
                //ans ++;
                for(int i = 1; N>=Math.pow(q,i);i++){
                    if(N%Math.pow(q, i)==0){
                        ans++;
                        N = (long) (N / Math.pow(q, i));
                    }
                }
                while(N%q ==0){
                    N = N/q;
                }
            }   
            q++;
        }
        if(N != 1){ans++;}
       
            System.out.println(ans);
    }
}


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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

LL N;
LL A[100100];
LL minCount[100100];
LL maxCount[100100];

int main()
{
	cin >> N;
	REP(i, N + 1) {
		cin >> A[i];
	}

	if (N == 0) {
		if (A[0] == 1) {
			cout << 1 << endl;
		}
		else {
			cout << -1 << endl;
		}
		return 0;
	}

	minCount[N] = A[N];
	maxCount[N] = A[N];
	for (LL i = N - 1; i >= 0; --i) {
		minCount[i] = (minCount[i + 1] + 1) / 2 + A[i];
		maxCount[i] = maxCount[i + 1] + A[i];
	}

	LL ans = 1;
	maxCount[0] = 1;
	for (LL i = 1; i <= N; ++i) {
		LL m = (maxCount[i - 1] - A[i - 1]) * 2;
		if (m < minCount[i]) {
			cout << -1 << endl;
			return 0;
		}

		maxCount[i] = min(m, maxCount[i]);

		ans += maxCount[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5912
import java.util.*; 
import java.lang.*; 

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		long K = scan.nextLong();
		long p = 0;
		
		Queue<Long> que = new ArrayDeque<>();
		
		for(long i=1; i<=9; i++){
			que.add(i);
		}
		
		for(long i=1; i<=K; i++){
			p = que.poll();
			
			if((p%10)!=0){
			que.add(p*10+p%10-1);
			}
			
			que.add(p*10+p%10);
			
			if((p%10)!=9){
			que.add(p*10+p%10+1);
			}
		}
		
		System.out.println(p);
	}
}

Measured memory_bytes: 30036
#include <iostream>
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll mod(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  mod(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*mod(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return mod(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}



int main()
{
    string s,t;
    cin>>s>>t;
    int m=s.length();
    int n=t.length();
    int ans=INT_MAX;
    for(int i=0;i<m-n+1;i++){
        int mi=0;
        for(int j=0;j<n;j++){
            if(t[j]!=s[i+j])mi++;
        }
        ans=min(mi,ans);
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
int war(int *x,int *y,int N,int M){
  int i,Z=-100;
  for(i=0;i<N+1;i++)
  if(x[i]>Z) Z=x[i];

  for(i=0;i<M+1;i++){
  if(y[i]<=Z) return 1;
}
return 0;
}
int main(void){
  int i,N,M,x[101],y[101];
  scanf("%d%d%d%d",&N,&M,&x[0],&y[0] );
  for(i=1;i<N+1;i++)
  scanf("%d",&x[i] );
  for(i=1;i<M+1;i++)
  scanf("%d",&y[i] );
  if(war(x,y,N,M)==1)
  printf("War\n");
  else printf("No War");
  return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

#define M (1046527)
#define NIL (-1)
#define L (14)

char H[M][L];

int getChar(char ch){
    if(ch=='A')return 1;
    else if(ch=='C')return 2;
    else if(ch=='G')return 3;
    else if(ch=='T')return 4;
    else return 0;
}

unsigned long getKey(char str[]){
    unsigned long sum=0,p=1;
    for(int i=0;i<strlen(str);i++){
        sum+=p*(getChar(str[i]));
        p*=5;
    }
    return sum;
}

int h1(int key){
    return key%M;
}

int h2(int key){
    return 1+(key%(M-1));
}

int insert(char str[]){
    unsigned long key,i,h;
    key=getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}

int search(char str[]){
    unsigned long key,i,h;
    key=getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0)return 0;
    }
    return 0;
}


int main(void){
    int n;
    char str[L],com[9];
    for(int i=0;i<M;i++){
        H[i][0]='\0';
    }
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s %s",com,str);
        if(com[0]=='i'){
            insert(str);
        }else{
            if(search(str)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}



Measured memory_bytes: 17456