akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 __int128
#endif

#define all(x) x.begin(), x.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
}

ll const maxn = 3e5 + 5;

unordered_map<ll, int128> dp;
vector<ll> kek = { 2,3,5 };
vector<ll> rofl = { 0,0,0 };
ll a, b, c, d;

ll f(ll n) {
    if (dp.find(n) != dp.end()) return dp[n];
    int128 x = n;
    dp[x] = x * d;
    for (int i = 0; i < 3; i++) {
        int128 ddd = kek[i] - x % kek[i];
        int128 y = (x + ddd) / kek[i];
        dp[x] = min(dp[x], f(y) + rofl[i] + (int128)ddd * d);
        ddd = x % kek[i];
        y = (x - ddd) / kek[i];
        dp[x] = min(dp[x], f(y) + rofl[i] + (int128)ddd * d);
    }
    return dp[x];
}


signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("output.txt", "w", stdout);
    ll q; cin >> q;
    while (q--) {
        ll n; cin >> n;
        for (ll i = 0; i < 3; i++) cin >> rofl[i];
        cin >> d;
        dp[0] = 0;
        cout << f(n) << '\n';
        dp.clear();
    }


    return 0;
}

/*

*/

Measured memory_bytes: 4732
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int a, b, c;

//解法
void solve() {

	cout << (a + b >= c ? "Yes" : "No");

	return;
}

int main() {
	//入力
	cin >> a >> b >> c;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ct=0
b=0
for i in range(0,n-2):
  p=a[i]
  for j in range(i+1,n-1):
    q=a[j]
    for k in range(j+1,n):
      r=a[k]
      if p!=q and q!=r and r!=p and 2*max(p,q,r)<p+q+r:
        ct+=1
print(ct)


Measured memory_bytes: 9188
import java.util.Scanner;

public class Main {
    static final Scanner sc = new Scanner(System.in);
    static final int MOD = (int) 1E9 + 7;
    
    public static void main(String[] args) {
        int N = nint();
        System.out.println(N * N * N);
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0);
    }

    private static char[][] nchars2(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 21844
N, M, X, Y = map(int, input().split())
xi = list(map(int, input().split()))
yi = list(map(int, input().split()))

for z in range(X+1, Y+1):
    if max(xi) < z and min(yi) >= z:
        print('No War')
        quit()
 
print('War')

Measured memory_bytes: 3060
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  printf("%d\n", (n+1)/2);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//Setを使って、新たな要素は追加していき、最後にサイズをチェックする
int main(){
    int N;
    scanf("%d", &N);
    string inString;

    set<string> set_dict;
    int a = 0;
    while(a < N){
        cin >> inString;
        set_dict.insert(inString);
    
        a++;
    }
    cout << set_dict.size() << endl;
}


Measured memory_bytes: 19252
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

int main( void ) {
    int n, a, b;
    std::cin >> n >> a >> b;

    std::vector< int > hs;
    for( size_t i = 0; i < n; ++i ) {
        int h;
        std::cin >> h;
        hs.push_back( h );
    }

    // とりあえずbでx回攻撃して削ったとみなして
    // 残ったヒットポイントは
    // 「実は必要な分はこの怪物をaで攻撃してたから0になってるんだよ！」
    // と後付けでいう。
    // それが全ての怪物で問題なく言えるなら、x回の攻撃で倒せる
    // その上で最小のxを二分探索で探す

    // 最初から滅んでる場合が最小
    size_t min = 0;
    // 初期上限としては、最大のものをbだけで吹き飛ばすほどの回数で十分
    size_t max = std::ceil( *std::max_element(hs.begin(), hs.end()) / (double)b );

    while( min != max ) {
        const size_t mid = (min + max) / 2;

        size_t a_attacks = 0;
        const int base = mid * b;
        for( size_t i = 0; i < hs.size(); ++i ) {
            // 何回分のa攻撃が必要なのか求める。
            // b攻撃してきた中にa攻撃であるものが実はある程度あった、、、という計算は
            // hs[i] - baseでb攻撃分のhを削ったあと、a-bだけダメージが増す攻撃があったということ
            const int attacks = std::ceil( (double)(hs[ i ] - base) / (a - b) );
            // 0を下回る場合、もうb攻撃だけで死んでいるからa攻撃しない
            if( attacks <= 0 ) continue;
            a_attacks += attacks;
        }

        if( a_attacks <= mid ) {
            max = mid;
        } else {
            min = mid + 1;
        }
    }

    std::cout << min << std::endl;
    
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
/*AtCoder Beginner Contest 104(๑•﹏•๑｀)*/

int main(){
	string S;
	getline(cin,S);
	int len = S.length();
	bool c = false;
	bool flg = true;

	if (S[0] != 'A') flg = false;

	FORq(i,1,len-1){
		if ((S[i] == 'C') and (2 <= i) && (i <= len-2)){
			if (c == false){
				c = true;
				continue;
			}else{
				flg = false;
			}
		}

		if(!((S[i] >= 'a') and (S[i]<='z'))){
			flg = false;
		}
	}

	if (c == false) flg = false;

	if (flg) printf("AC\n");
	else printf("WA\n");



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int H[N];
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }
    int ans = 1;
    for (int i = 1; i < N; i++)
    {
        int judge = 1;
        for (int j = 0; j < i; j++)
        {
            if (H[j] > H[i])
            {
                judge = 0;
            }
        }
        if (judge == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
void dfs(ll x, vector<vector<ll>> &g, vector<bool> &see,bool &ok,vector<ll> &dist)
{
  //点xに対する処理
  see[x] = 1;
  for (auto p : g[x])
  {
    if (see[p]){
      if(dist[p]%2!=(dist[x]+1)%2)ok=0;
      continue;
    }
    //進む辺に対する処理（これは木構造でオイラーツアーするために使う）
    dist[p]=dist[x]+1;
    dfs(p,g,see,ok,dist);
    //戻る辺に対する処理
  }
  //点xの親に戻る時の処理
}
int main()
{
ll n, m;
cin >> n >> m;
vector<vector<ll>> g(n);
//多重辺がないならsetでもよい（辺を消去したいときなど）この場合はinsert
//set<ll> g[n];
rep(i, m)
{
  ll a, b;
  cin >> a >> b;
  g[a - 1].push_back(b - 1);
  g[b - 1].push_back(a - 1); //無向辺
}
bool ok=1;
vector<ll> dist(n);
vector<bool> see(n);
dfs(0,g,see,ok,dist);
if(ok){
  ll nu=0;
  for(auto p:dist)if(p%2)nu++;
  ans=nu*(n-nu) - m;
}
else{
  ans=n*(n-1)/2-m;
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 8448
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
#include <set>
#include <iomanip>
using namespace std;
using Graph = vector<vector<int>>;
 
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    vector<int> C(N);
    for (int i=0; i<N; i++){
        cin >> H[i];
        C[i] = true;
    }
    //vector<int> A(M);
    //vector<int> B(M);
    for (int i=0; i<M; i++){
        int a, b;
        //cin >> A[i] >> B[i];
        cin >> a >> b;
        if (H[a-1] >= H[b-1]) C[b-1] = false;
        if (H[a-1] <= H[b-1]) C[a-1] = false;
    }
    int ans = count(C.begin(), C.end(), true);
    cout << ans << endl;
    return 0;
}

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

ll gcdll(ll a, ll b){
    if(!b) return a;
    return gcdll(b, a%b);
}

void seive(int n){
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;

    for(int i=2; i*i<=n; i++){
        if(is_prime[i]){
            for(int j=i*i; j<=n; j+=i){
                is_prime[j] = false;
            }
        }
    }
}

vector<int> constructZFunc(string s){
    int n = s.size();
    vector<int> z(n);
    int l, r;
    l = r = 0;
    z[0] = 0;
    rep(i, 1, n-1){
        z[i] = 0;
        if(i<=r){
            z[i] = min(r-i+1, z[i-l]);  /// initialization, req. for linear time approach.
        }
        while(i+z[i] < n && s[z[i]] == s[i+z[i]])
            ++z[i];
        if(i+z[i]-1 > r){
            r = i+z[i]-1;
            l = i;
        }
    }
    return z;
}

void solve(){
    int n, x;
    cin>>n;
    int cnt[n+1] = {0};
    fr(i, n-1) {
        cin>>x;
        cnt[x]++;
    }
    rep(i, 1, n) cout<<cnt[i]<<endl;
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



Measured memory_bytes: 4444
#include <stdio.h>

int main(void)
{
	int x1,x2,c;
	scanf("%d %d",&x1,&x2);
	if(x1>x2 || x1==x2)c=x1-x2;
	else if(x1<x2)c=x2-x1;
	printf("%d\n",c);
	return 0;
}


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


int main(){
  string S;
  cin>>S;
  int num[4];
  for(int i=0;i<4;i++){
    num[i]=S[i]-'0';
  }
  
  for(int i=0;i<(1<<3);i++){
    int pm[3];
    for(int j=0;j<3;j++){
      if((i>>j)&1) pm[j]=1;
      else pm[j]=-1;
    }
    if(num[0]+pm[0]*num[1]+pm[1]*num[2]+pm[2]*num[3]==7){
      cout<<num[0]<<((pm[0]==1)?'+':'-')<<num[1]<<((pm[1]==1)?'+':'-')<<num[2]<<((pm[2]==1)?'+':'-')<<num[3]<<"=7"<<endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 256
s = list(input())
t = list(input())
ls =len(s)
lt = len(t)
s.reverse()
t.reverse()
for i in range(ls):
    for j in range(lt):
        if i + j >= ls:
            break
        if s[i+j] != '?' and s[i+j] != t[j]:
            break
    else:
        for j in range(lt):
            s[i+j] = t[j]
        s = [x if x != '?' else 'a' for x in s]
        s.reverse()
        ans = ''.join(s)
        break
else:
    ans = 'UNRESTORABLE'
print(ans)

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

struct ZeroClearableArray {
	std::vector<int> data;
	std::vector<int> written;
	int n;
	ZeroClearableArray (int n) : data(n), n(n) {}
	int operator [] (int i) { return data[i]; }
	void set(int i, int val) { data[i] = val; written.push_back(i); }
	void zero_clear() {
		while (written.size()) data[written.back()] = 0, written.pop_back();
	}
};

#define MOD 1000000007
int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri();
	std::vector<ZeroClearableArray> dp(3, ZeroClearableArray(100001));
	if (a[0] != 0) {
		std::cout << 0 << std::endl;
		return 0;
	}
	dp[0].set(0, 1);
	dp[1].set(0, 1);
	dp[2].set(0, 1);
	for (int i = 1; i < n; i++) {
		int prim = a[i - 1];
		std::vector<std::pair<std::pair<int, int>, int> > add_list;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) continue;
				bool new_primary = !k || (!j && k == 1);
				bool old_primary = !j || (!k && j == 1);
				if (!new_primary && i - a[i - 1] - 1 - a[i] < 0) continue;
				if (!old_primary && i - a[i] - a[i - 1] - 1 < 0) continue;
				int add_num = dp[j][new_primary ? a[i] : i - a[i - 1] - 1 - a[i]];
				add_list.push_back({{k, old_primary ? a[i - 1] + 1 : i - a[i - 1] - a[i] - 1}, add_num});
			}
		}
		if (a[i] != a[i - 1] + 1) {
			for (int j = 0; j < 3; j++) {
				dp[j].zero_clear();
			}
		}
		for (auto &i : add_list) {
			int val = dp[i.first.first][i.first.second];
			val += i.second;
			if (val >= MOD) val -= MOD;
			dp[i.first.first].set(i.first.second, val);
		}
	}
	int res = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j <= 100000; j++) {
			res += dp[i][j];
			if (res >= MOD) res -= MOD;
		}
	}
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n;
	cin>>n;
	while(n--){
		int a,b;
		cin>>a>>b;
		int c1=1,c2=1;
		int t1=a/100,t2=b/30;
		if(a%100)c1++;
		if(b%30)c2++;
		vi out;
		rep(i,c1)rep(j,c2){
			out.pb(5*(t2+j)+t1+i);
		}
		sort(all(out));
		rep(i,out.size())cout<<(i?" ":"")<<out[i];cout<<endl;
	}
}

Measured memory_bytes: 1220
n,m = map(int, input().split())
C = list(map(int, input().split()))
inf = float("inf")
T = [inf for i in range(n+1)]
T[0] = 0

for i in range(m):
    for j in range(C[i], n+1):
        T[j] = min(T[j], T[j - C[i]] + 1)

print(str(T[n]))

Measured memory_bytes: 9628
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

int n, W, w[100], v[100];
ll dp[100][100001];

ll f(int k, int r)
{
    if (r < 0) return 2e9;
    if (k == n) return r ? 2e9 : 0;
    if (dp[k][r] != -1) return dp[k][r];
    return dp[k][r] = min(w[k] + f(k + 1, r - v[k]), f(k + 1, r));
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> W;
    for (int i = 0; i < n; ++i)
        cin >> w[i] >> v[i];
    memset(dp, -1, sizeof dp);
    ll bst = 0;
    for (int i = 0; i <= 100000; ++i)
        if (f(0, i) <= W)
            bst = i;
    cout << bst;
}


Measured memory_bytes: 78336
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
typedef vector<long long> vll;

// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	return a/ gcd(a,b)*b;
}
int hin[100010];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int A,B,C,D,E,F;
	scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);
	set<int> water;
	set<int> sugar;
	REP(i, F + 1) {
		REP(j, F + 1) {
			int y = i * C + j * D;
			if (y <= F) {
				sugar.insert(y);
			}
		}
	}
	REP(i, (F+99) /100+1) {
		REP(j, (F + 99) / 100 + 1) {
			int x = (i * A + j * B) * 100;
			if (x <= F) {
				water.insert(x);
			}
		}
	}
	double maxNodo = -1;
	const double seigenNodo = E*100.0/(100+E);
	int maxWater,maxSugar;
	for(auto x : water) {
		for (auto y : sugar) {
			if ((x + y) > F)continue;
			if ((x + y) == 0)continue;
			double nodo = (100.0 * y) / (x + y);
			if(nodo > seigenNodo)continue;
			if (nodo > maxNodo) {
				maxNodo = nodo;
				maxWater = x;
				maxSugar = y;
			}
		}
	}
	cout << maxWater+ maxSugar << " " << maxSugar << endl;
	return 0;
}


Measured memory_bytes: 384
n,x,y = map(int,input().split())

# 0スタートに合わせる
x -= 1
y -= 1

# 距離を格納するためのリスト
lengh_list = [0]*n

for i in range(n-1):
    for j in range(i+1,n):
        len_itoj = min(j-i,abs(x-i)+1+abs(y-j))
        lengh_list[len_itoj] += 1

for length in lengh_list[1:]:
    print(length)

Measured memory_bytes: 3572
S = input()
if len(S) == 7:
  print(['NO','YES']["keyence"==S])
  exit()
i = 0
while i < 7 and S[i] == "keyence"[i]:
  i += 1
  
j = -1
while j >= -7 and S[j] == "keyence"[j]:
  j -= 1
  
j *= -1
j -= 1
print(['NO','YES'][i+j>=7])

Measured memory_bytes: 3064
const char* version[]=
{
	"+---------version--------------+",
	"+last update:2014/10/27/17:46  +",
	"+author:Shitonai Rindo         +",
	"+------------------------------+",
	"endl"
};
const char* help[]=
{
	"+--------help----------------------------------+",
	"+summary:At Boss's Expense:searchMaxPrime      +",
	"+required inputs (stdin):                      +",
	"firstLine:value kinds (tab) budget             +",
	"others:values                                  +",
	"+supported comandline options:-h -v            +",
	"+----------------------------------------------+",
	"endl"
};
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
void manage_helpAndVersionOutput(char arg_line[]);
int atBoss_s_expense();
bool primeChecker(int num);

int main(int argc, char* argv[])
{
	manage_helpAndVersionOutput(argv[argc-1]);
	
	while(atBoss_s_expense());/*0 0が入力されるまで関数を繰り返し*/
	
	return 0;
}

int atBoss_s_expense()
{
	int kindc,budget;
	scanf("%d %d",&kindc,&budget);/*価格の種類、予算を入力*/
	if(!kindc && !budget)
	{
		return 0;
	}
	bool valueBucket[budget+1];/*予算上限までのbool型変数を取る。与えられた料理の価格でその金額が実現可能ならtrue、他はfalse*/
	valueBucket[0]=true;/*0円は料理の種類に関わらず必ず実現できる*/
	int init_bucket;
	for(init_bucket=1;init_bucket<=budget;init_bucket++)/*boolバケツの初期化*/
	{
		valueBucket[init_bucket]=false;
	}
	
	int roop_values,roop_sum,roop_threshold;
	int value;
	for(roop_values=0;roop_values<kindc;roop_values++)/*料理ごとに注文数を1,2,3...と変化させた時の価格を格納し、実現可能価格を割り出す*/
	{
		scanf("%*c%d",&value);
		roop_threshold=budget-value;
		for(roop_sum=0;roop_sum<=roop_threshold;roop_sum++)/*料理X*1,料理X*2...の値段を順次、そのタイミングで判明している実現可能価格に足していく*/
		{
			if(valueBucket[roop_sum])
			{
				valueBucket[roop_sum+value]=true;
			}
		}
	}
	
	int roop_checkPrime;
	for(roop_checkPrime=budget;roop_checkPrime>1;roop_checkPrime--)/*予算上限から1ずつを減じ、素数かつ実現可能な価格を見つける。見つかった時点でreturn*/
	{
		if(valueBucket[roop_checkPrime] && primeChecker(roop_checkPrime))/*primeChecker関数で素数判定*/
		{
			printf("%d\n",roop_checkPrime);
			return 1;
		}
	}
	printf("NA\n");/*見つからない場合はNA*/
	return 1;
}

bool primeChecker(int num)
{
	int divideNum;
	for(divideNum=(int)floor(sqrt(num));num%divideNum;divideNum++);/*素数判定は判定する数の平方根以上で十分とされる。*/
	if(num==divideNum)/*ループ明けがnum自身によるものなら素数*/
	{
		return true;
	}
	else
	{
		return false;
	}
}



void manage_helpAndVersionOutput(char arg_line[])
{
	int line;
	if(strcmp(arg_line,"-h")==0)
	{
		for(line=0;strcmp(help[line],"endl");line++)
		{
			printf("%s\n",help[line]);
		}
		exit(0);
	}
	else if(strcmp(arg_line,"-v")==0)
	{
		for(line=0;strcmp(version[line],"endl");line++)
		{
			printf("%s\n",version[line]);
		}
		exit(0);
	}
}

Measured memory_bytes: 1588
#include <iostream>

using namespace std;

int main()
{
    int x, h, m, s;

    cin >> x;

    h = x / 3600;

    m = (x % 3600) / 60;

    s = (x % 3600) % 60;

    cout << h << ":" << m << ":" << s << endl;
}


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

int main(){
    ll n,k;
    cin>>n>>k;
    map<ll,ll> ma;
    for(ll i=0;i<k;i++){
        ll d,t;
        cin>>d;
        while(d--)  cin>>t,ma[t]++;
    }
    ll count=0;
    for(auto i : ma)    count++;
    cout<<n-count<<endl;
    return 0; 
}


Measured memory_bytes: 3640
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    x=II()
    ans=x//11*2
    x%=11
    if x>6:ans+=2
    elif x>0:ans+=1
    print(ans)

main()

Measured memory_bytes: 3064
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int x = readint;
    int a = readint;
    int b = readint;

    int donut = (x - a) / b;
    writeln(x - a - b * donut);
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};

int main(){
    ll n,h; cin >> n >> h;
    vpl a(n);
    ll sum = 0;
    rep(i,n){
        cin >> a[i].first >> a[i].second;
    }
    sort(all(a));
    ll t = a[n-1].first;
    rep(i,n){
        swap(a[i].first, a[i].second);
    }
    sort(rall(a));
    ll ans = 0;
    rep(i,n){
        if(a[i].first<=t) break;
        h -= a[i].first;
        ans++;
        if(h<=0){
            cout << ans << endl;
            return 0;
        }
    }
    ans += (h+t-1)/t;
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>

#define MAX 244140625

int Hash[MAX];
char str[13];

int getChar(char);
int getKey();
int find();
void insert();

int main(){
  int n;
  char com[7];

  scanf("%d" ,&n);
  while(n--){
    scanf("%s %s" ,com ,str);

    if(com[0] == 'i'){
      insert();
    }else{
      if(find()){
	puts("yes");
      }else{
	puts("no");
      }
    }
  }

  return 0;
}

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

int getKey(){
  int sum = 0, p = 1, i;

  for(i = 0 ; i < strlen(str) ; i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int find(){
  int key = getKey();

  if(Hash[key]){
    return 1;
  }

  return 0;
}

void insert(){
  Hash[getKey()] = 1;
}

Measured memory_bytes: 38620
#include<stdio.h>

int main(){
	int n,l,i;
	scanf("%d%d",&n,&l);
	int ans=0;
	for(i=0;i<n;i++)ans+=l+i;
	if(l>=0)ans-=l;
	else{
		if(-l+1>n)ans-=l+n-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;

static const long long MOD = 1000000007;

struct modll {
	long long x;
	modll() { }
	modll(int _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(int y) { return (x + y + MOD) % MOD; }
	modll operator+=(int y) { x = (x + y + MOD) % MOD; return *this; }
	modll operator-(int y) { return (x - y + MOD) % MOD; }
	modll operator-=(int y) { x = (x - y + MOD) % MOD; return *this; }
	modll operator*(int y) { return (x * y) % MOD; }
	modll operator*=(int y) { x = (x * y) % MOD; return *this; }
	modll operator/(int y) { return (x * modpow(y, MOD - 2)) % MOD; }
	modll operator/=(int y) { x = (x * modpow(y, MOD - 2)) % MOD; return *this; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

void solve(int N) {
	modll ans = modll::modpow(10, N) - modll::modpow(9, N) * 2 + modll::modpow(8, N);
	cout << ans << endl;
}

int main() {
	int N;
	std::cin >> N;
	solve(N);
	return 0;
}


Measured memory_bytes: 3580
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro split-ints-bind (vars string &body body)
  (let ((position (gensym))
        (s (gensym)))
    (labels ((expand (vars &optional init-pos)
               (if (null vars)
                   body
                   `((multiple-value-bind (,(car vars) ,position)
                         (parse-integer ,s :start ,(or init-pos position)
                                           :junk-allowed t)
                       ,@(when (null (cdr vars)) `((declare (ignore ,position))))
                       ,@(expand (cdr vars)))))))
      `(let ((,s ,string))
         (declare (string ,s))
         ,@(expand vars 0)))))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

(defun main ()
  (let* ((n (read))
         (xyhs (make-array n :element-type '(cons uint32 (cons uint32 uint32)))))
    (dotimes (i n)
      (split-ints-bind (x y h) (read-line)
        (setf (aref xyhs i) (list h x y))))
    (setf xyhs (sort xyhs #'> :key #'car))
    (when (zerop (car (aref xyhs 0))) (error "Huh?"))
    (dotimes (cx 101)
      (dotimes (cy 101)
        (loop with cand-height = most-positive-fixnum
              for i below n
              for (h x y) = (aref xyhs i)
              do (if (zerop h)
                     (unless (<= cand-height (+ (abs (- x cx)) (abs (- y cy))))
                       (return))
                     (let ((must-height (+ h (abs (- x cx)) (abs (- y cy)))))
                       (when (< must-height 1)
                         (return))
                       (if (= cand-height most-positive-fixnum)
                           (setf cand-height must-height)
                           (unless (= cand-height must-height)
                             (return)))))
              finally (format t "~A ~A ~A~%" cx cy cand-height)
                      (return-from main))))))

#-swank(main)


Measured memory_bytes: 11748
var x = require('fs').readFileSync('/dev/stdin', 'utf8');
 
var h = Math.floor(x/3600);
var m = Math.floor((x - (h * 3600)) / 60);
var s = x - (h * 3600) - (m * 60);
console.log(h + ':' + m + ':' + s);

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin>>a>>b;
        // 実はmax({a+b, a-b, a*b})でもよい
	cout<<max(a+b, max(a-b, a*b))<<'\n';
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
const int maxn = 1e6+5;
const int mod = 1e9+7;
const double eps = 1e-8;
using namespace std;

void tlfclwx(){ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int main()
{
    string s; cin >> s;
    int sum = 0;
    for(int i = 0; i < s.size()/2; i++) {
        if(s[i]!=s[s.size()-1-i]) sum++;
    }
    cout << sum <<endl;
}


Measured memory_bytes: 256
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int main(int argc, const char * argv[]) {
    
    //Input
    int N, value, maximum, ans, tmp;
    maximum = 0;
    scanf("%d", &N);
    
    int *array = NULL;
    array = (int*)malloc(sizeof(int) * N);
    int * flag = NULL;
    flag = (int*)malloc(sizeof(int) * N);
    
    REP(i, N){
        scanf("%d", &value);
        array[i] = value;
    }
    
    ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = N-1; j > i; j--){
            if(array[j-1] > array[j]){
                tmp = array[j-1];
                array[j-1] = array[j];
                array[j] = tmp;
                ans += 1;
            }
        }
    }
    
    REP(i, N){
        printf("%d", array[i]);
        if(i != N-1){
            printf(" ");
        }
    }
    printf("\n");
    printf("%d\n", ans);
    
    
    
    return 0;
}

Measured memory_bytes: 1032
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,D,x,y;
int main()
{
	scanf("%d%d",&n,&D);int ans=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&x,&y);
		if(1ll*x*x+1ll*y*y<=1ll*D*D)++ans;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3252
#include <iostream>
#include <cstring>

using namespace std;

int N, t[10001];
int dp[2][10001][2];

int main() {
    cin >> N;
    for (int i=0; i<N-1; i++) cin >> t[i];
    t[N-1] = 0;

    memset(dp, 0x01, sizeof(dp));
    dp[0][1][0] = dp[0][0][1] = 0;

    for (int i=0; i<N; i++) {
        for (int j=0; j<=N/2; j++) {
            dp[(i+1)&1][j+1][0] = min(dp[i&1][j][0], dp[i&1][j][1]+t[i]);
            dp[(i+1)&1][j][1] = min(dp[i&1][j][0]+t[i], dp[i&1][j][1]);
        }
    }

    cout << min(dp[(N-1)&1][N/2][0], dp[(N-1)&1][N/2][1]) << endl;

    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

vector<PI> edge[22];

int main() {
    li n;
    cin >> n;
    li bit_num = 40;
    while (bit(bit_num) > n) {
        bit_num--;
    }
    repp(i, 1, bit_num + 1) {
        edge[i].pb({i - 1, bit(i - 1)});
        edge[i].pb({i - 1, 0});
    }
    n -= bit(bit_num);
    li root_node = bit_num;
    ///*
    li cur = bit(bit_num);
    while (n > 0 && bit_num >= 0) {
        if (n < bit(bit_num)) {
            bit_num--;
            continue;
        }
        //p3(n, bit_num, cur);
        edge[root_node].pb({bit_num, cur});
        cur += bit(bit_num);
        n -= bit(bit_num);
        bit_num--;
    }
    //*/

    li link_num = 0;
    rep(i, root_node + 1) {
        link_num += edge[i].size();
    }
    cout << root_node + 1 << " " << link_num << endl;
    for (li i = root_node; i >= 0; --i) {
        //
        rep(j, sz(edge[i])) {
            cout << root_node - i + 1 << " "
                 << root_node - edge[i][j].first + 1 << " "
                 << edge[i][j].second << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
lent = len(t)
ans = []
if len(s) == lent:
    ans1 = 0
    for s1, t1 in zip(s, t):
        ans1 += (s1==t1)
    ans.append(ans1)
else:
    for i in range(len(s) - lent):
        ss = s[i:i+lent]
        ans1 = 0
        for s1, t1 in zip(ss, t):
            ans1 += (s1==t1)
        ans.append(ans1)
print(lent-max(ans))

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

int main() {
  int n, c = 1;
  cin >> n;
  vector<int> array(n), n1(n), n2(n);
  for(int i = 0; i < n; i++){
    cin >> n1[i];
  }
  for(int i = 0; i < n; i++){
    cin >> n2[i];
  }
  for(int i = 0; i < n; i++){
    array[i] = c;
    c++;
  }
  int cnt = 1, a, b;
  do {
    cout << endl;
      if(equal(array.begin(), array.end(), n1.begin())){
         a = cnt;
      }else if(equal(array.begin(), array.end(), n2.begin())){
        b = cnt;
      }
    if(equal(n1.begin(), n1.end(), n2.begin())){
      a = b;
    }
      cnt++;
   }while (next_permutation(array.begin(), array.end()));
  cout << abs(a - b) << "\n";
  return 0;
}

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



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,k;
    cin>>a>>b>>k;
    ll temp1=std::max(a-k,0ll);
    ll temp=k-(a-temp1);
    ll temp2=std::max(b-temp,0ll);
    //cout<<temp<<endl;
    cout<<temp1<<" "<<temp2<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int hat[100010][3];

int main() {
    int n;
    cin >> n;
    vec a(n);
    rep(i, n) cin >> a[i];

    lint res = 1;

    rep(i, 100000) rep(j, 3) hat[i][j] = 0;

    rep(i, n) {
        int cnt = 0;
        rep(j, 3) if (hat[i][j] == a[i]) cnt++;
        res *= cnt;
        rep(j, 3) {
            if (hat[i][j] == a[i]) {
                hat[i][j]++;
                break;
            }
        }
        rep(j, 3) hat[i+1][j] = hat[i][j];
        res %= MOD;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
int main(){
  int n;
  cin>>n;
  vll p(n),m(n);
  int ans=1;
  
  REP(i,n){
    ll x;
    cin>>x;
    if(i!=0){
      if(p[i-1]>x){ans++;}
      p[i]=min(p[i-1],x);

    }
    else{p[i]=x;}
  
  }
  
  
  cout<<ans<<endl;
  
}



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

int main() {
    while (true) {
        int N;
        cin >> N;
        if (N == 0) break;
        vector<int> W(N);
        for (int i = 0; i < N; i++) cin >> W[i];

        int dp[N+1][N+1];
        for (int i = 0; i < N+1; i++){
            for (int j = 0; j < N+1; j++) {
                dp[i][j] = 0;
            }
        }

        for (int b = 2; b < N+1; b++) {
            for (int i = 0; i < N; i++) {
                int j = i + b;
                if (j > N) continue;
                if (abs(W[i] - W[j-1]) <= 1 && dp[i+1][j-1] == j-i-2) {
                    dp[i][j] = j - i;
                }
                for (int k = i+1; k < j; k++) {
                    dp[i][j] = max(dp[i][j], dp[i][k] + dp[k][j]);
                }
            }
        }
        cout << dp[0][N] << endl;
    }
}


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

int main()
{
	long long h,w;
	cin >> h >> w;
	unsigned long long ans = 0,ans1,ans2;
	if(h==1||w==1)cout << "1" << endl;
	else {
		ans = (h*w+1)/2;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
H, N = map(int, input().split())
a, b = zip(*(list(map(int, input().split())) for _ in range(N)))
maxA = max(a)
 
inf = float("inf")
dp = [inf] * (H+maxA+1)
dp[0] = 0
 
for j in range(N):
    for i in range(a[j], H+maxA+1):
        dp[i] = min(dp[i], dp[i-a[j]]+b[j])
 
print(min(dp[H:]))

Measured memory_bytes: 50524
foods=[int(input()) for i in range(5)]
time=0
tmp=[]

for i in range(5):
    mod=foods[i]%10
    if mod==0:
        time+=foods[i]
    else:
        tmp.append((mod, i))

l=sorted(tmp, reverse=True)

for i in range(len(l)):

    if i != len(l)-1:
        time+=(10-l[i][0])+foods[l[i][1]]
    else:
        time+=foods[l[i][1]]
        

print(time)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <random>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define pi 3.141592653589793
#define prique priority_queue
constexpr auto mod=1000000007;
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int n){
    int cnt=0;
    for(int i=1;i<=sqrt(n);i++){
        if(n%1==0)cnt++;
    }
    if(cnt!=1) return false;
    else return n!=1;
}
struct UnionFind{
    vector<int> r;
    UnionFind(int N){
        r=vector<int>(N,-1);
    }
    int root(int x){
        if(r[x]<0) return x;
        return r[x]=root(r[x]);
    }
    bool unite(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(r[x]>r[y]) swap(x,y);
        r[x]+=r[y];
        r[y]=x;
        return true;
    }
    int size(int x){
        return -r[root(x)];
    }
};
vector<int> v;
int n,m,cnt=1,ans=1,aa[220000];
pair<int,int> pp[220000];
string s,ss[220000];
queue<int> que;
signed main(){
    cin>>n;
    aa[6]=1;
    for(int i=7;i<2020;i++){
        aa[i]=aa[i-1]+aa[i-3];
        aa[i]%=mod;
    }
    if(n==1||n==2){
        cout<<0;
    }else{
        rep(i,n+1){
            cnt+=aa[i];
            cnt%=mod;
        }
        cout<<cnt;
    }
}

Measured memory_bytes: 10616
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<tuple>
#include<utility>
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb push_back
#define mp make_pair

int main() {
	LL n;
	cin >> n;
	vector<pair<string, pair<int, int>>> ans;
	rep(i, 0, n) {
		string s;
		int x;
		cin >> s >> x;
		ans.pb(mp(s, mp(-x, i)));
	}
	SORT(ans);
	rep(i, 0, n) {
		cout << ans[i].second.second + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
ps = gets.split.map &:to_i

diff_count = 0

(0...n).each{ |i|
	if ps[i] != i + 1 then
		diff_count +=1
	end
}

if diff_count == 0 || diff_count == 2 then
	puts "YES"
else
	puts "NO"
end


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <map>
#include <algorithm>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )

typedef long long llong;



using namespace std;

int main(void) {

	int N;
	llong ans = 0;
	map<string, int> m;

	scanf("%d", &N);

	REP(i, 0, N) {
		char tmp[11];
		scanf("%s",tmp);

		sort(tmp, tmp + 10);
		
		string s = tmp;
		if (m[tmp] == 0) {
			m[tmp] = 1;
		} else {
			ans += (llong)m[tmp]++;
		}


	}

	

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

	return 0;
}


Measured memory_bytes: 11136
r,c = [int(x) for x in input().split()]
s_row = [0 for x in range(c+1)]
for i in range(r):
    row = [int(x) for x in input().split()]
    row.append(sum(row))
    print(" ".join([str(x) for x in row]))
    s_row = [x+y for x,y in zip(s_row,row)]
print(" ".join([str(x) for x in s_row]))

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll k, a, b;
	cin >> k >> a >> b;
	
	if ((a + 2) >= b or (k + 2) <= a) {
		cout << k + 1 << endl;
		return 0;
	}
	
	ll cnt = a;
	k -= a - 1;
	cnt += (b - a) * (k / 2);
	if (k % 2 == 1) cnt++;
	
	cout << cnt << endl;
	
	return 0;
}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;

/*************************************************************************/

bool solve(int n, VI &a) {
    if (n == 1) {
        return false;
    }
    
    int sum = 0;
    FOR(i,0,n-1) {
        sum = (sum + a[i]) % 2;
    }
    
    if (1 - sum == n % 2) {
        return true;
    }
    
    bool found = false;
    FOR(i,0,n-1) if (a[i] % 2 && a[i] > 1) {
        found = true;
        a[i]--;
        
        break;
    }
    
    if (!found) {
        return false;
    }
    
    int gcd = 0;
    FOR(i,0,n-1) {
        gcd = __gcd(gcd, a[i]);
    }
    
    FOR(i,0,n-1) {
        a[i] /= gcd;
    }
    
    return !solve(n, a);
}

/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    VI a(n);
    FOR(i,0,n-1) {
        cin >> a[i];
    }
    
    cout << (solve(n, a) ? "First" : "Second");

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 768
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using namespace std;
using namespace boost::multiprecision;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mis map<int,string>
#define msi map<string,int>
#define mll map<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define srta(a) sort(all(a))
#define srtd(a) sort(all(a),greater<型>())
#define rvs(s) reverse(all(s))
#define psb push_back
#define ppb pop_back
#define isu isupper
#define isl islower
#define lb(a,k) lower_bound(all(a),k)
#define ub(a,k) upper_bound(all(a),k)
#define bs(a,k) binary_search(all(a),k)
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

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

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

int main() {
    ll N, D;
    cin >> N >> D;

    ll cnt = 0;
    rep (i, N) {
        ll x = 0;
        ll y = 0;
        cin >> x >> y;

        ll n = x*x + y*y;
        ll d = D*D;

        if (d >= n) cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3552