akhauriyash/Code-Regression huggingface dataset:
import sys

def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f 

input = sys.stdin.readline
N = int(input())
X = input().strip()

n0 = 0
for x_i in X:
    if x_i == "1":
        n0 += 1
# print("n0", n0)
r_p = 0 # 0 -> 1のケース
r_n = 0 # 1 -> 0のケース
X = X[::-1]
for i in range(N):
    x = int(X[i])
    r_p += x * pow(2, i, n0+1)
    r_p %= (n0+1)
    if 1 < n0:
        r_n += x * pow(2, i, n0-1)
        r_n %= (n0-1)
# print("r_p", r_p, "r_n", r_n)

ans = []
# print(n)
for i in range(N):
    count = 1
    diff = (1 if X[i] == "0"  else -1)
    # print("x_i", X[i], "diff", diff)
    n = n0 + diff
    if n == 0:
        ans.append(0)
        continue
    if diff == 1:
        r = r_p + (diff * pow(2, i, n))
        r %= n
    else:
        r = r_n + (diff * pow(2, i, n))
        r %= n
    # print("n", n, "r", r)
    n = r
    # print("n", n)
    while 0 < n:
        r = popcount(n)
        count += 1
        # print("n", n)
        if r == 0:
            break
        n = n % r
    ans.append(count)

for i in ans[::-1]:
    print(i)

Measured memory_bytes: 89660
import static java.lang.Math.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s1 = in.nextString().toCharArray();
			char[] s2 = in.nextString().toCharArray();

			int len1 = s1.length, len2 = s2.length;
			int[][] dp = new int[len1+1][len2+1];

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

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

			for (int i = 1; i < len1+1; i++) {
				for (int j = 1; j < len2+1; j++) {
					if (s1[i-1] == s2[j-1]) {
						dp[i][j] = min(min(dp[i-1][j]+1, dp[i][j-1]+1), dp[i-1][j-1]);
					} else {
						dp[i][j] = min(min(dp[i-1][j]+1, dp[i][j-1]+1), dp[i-1][j-1]+1);
					}
				}
			}

			out.println(dp[len1][len2]);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}



Measured memory_bytes: 29336
N = gets.to_i
D = []
N.times{|i|
  s, p = gets.chomp.split(" ")
  D << [i+1, s, p.to_i]
}

D.sort!{|a, b|
  (a[1] <=> b[1]).nonzero? || b[2] <=> a[2]
}

D.each{|d|
  puts d[0]
  #p d
}


Measured memory_bytes: 1788
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut a: Vec<usize> = vec![];
    for _ in 0..n {
        a.push(read());
    }
    let mut maxv = a.iter().max().unwrap();
    let mut keta = 1;
    let mut tmp = 2;

    while tmp < *maxv {
        keta += 1;
        tmp *= 2;
    }

    let mut cnt: Vec<usize> = vec![0; keta];

    for i in 0..a.len() {
        let ai = a[i];

        for j in 0..keta {
            cnt[j] += ai >> j & 1;
        }
    }

    for i in 0..a.len() {
        let ai = a[i];
        let mut ans = 0;
        for j in 0..keta {
            let a = cnt[j] - (ai >> j & 1);
            ans += (a % 2) << j;
        }
        print!("{} ", ans);
    }
}


Measured memory_bytes: 4212
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int counter = 1;
        for (int i = 1; i < n; i++) {
            if (s.charAt(i) != s.charAt(i - 1)) {
                counter++;
            }
        }
        System.out.println(counter);
        sc.close();
    }
}

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

typedef struct TV {
  int s;
  int t;
  int c;
} TV;

//チャンネルを昇順（同じ場合開始時間を昇順）
int c_acs(const void *a, const void *b)
{
  if (((TV *)a)->c == ((TV *)b)->c)
    return ((TV *)a)->s - ((TV *)b)->s;
  return ((TV *)a)->c - ((TV *)b)->c;
}

//開始時間を昇順
int s_acs(const void *a, const void *b)
{
  return ((TV *)a)->s - ((TV *)b)->s;
}

int main() {
  int n, c;
  scanf("%d%d", &n, &c);
  TV t[n];
  for (int i=0; i<n; i++)
    scanf("%d%d%d", &(t[i].s), &(t[i].t), &(t[i].c));
  qsort(t, n, sizeof(TV), c_acs);
  int j=0;
  for (int i=1; i<n; i++) {
    if (t[j].c == t[i].c) {
      if (t[j].t == t[i].s) {
        t[j].t = t[i].t;
        t[i].s = 0;
      } else {
        j = i;
      }
    } else {
      j = i;
    }
  }
  //for (int i=0; i<n; i++) printf("%d %d %d\n", t[i].s, t[i].t, t[i].c);
  int recoder[30] = {}, ans = 1;
  bool can;
  qsort(t, n, sizeof(TV), s_acs);
  for (int i=0; i<n; i++) {
    can = false;
    if (t[i].s == 0)
      continue;
    for (int j=0; j<ans; j++) {
      if(recoder[j]<t[i].s) {
        recoder[j] = t[i].t;
        can = true;
        break;
      }
    }
    if (!can) {
      recoder[ans] = t[i].t;
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

public class Main {

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

		// 初期位置
		double x = 0;
		double y = 0;
		// 進行方向
		double r = Math.toRadians(90);

		while (!(line = br.readLine()).equals("0,0")) {

			double distance = Double.parseDouble(line.split(",")[0]);
			double turn = Double.parseDouble(line.split(",")[1]);

			// 進む
			x += Math.cos(r) * distance;
			y += Math.sin(r) * distance;

			// 進行方向を変える
			if (turn < 0) {
				r += Math.toRadians(turn * -1);
			} else {
				r -= Math.toRadians(turn);
			}
		}
		System.out.println((int) x);
		System.out.println((int) y);
	}
}

Measured memory_bytes: 16928
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand((unsigned)time(NULL));
  ll N;
  cin >> N;
  if( N % 3000 == 0){
    cout << 0 << endl;
  }
  else{
    ll n = ( N + 999) / 1000 * 1000;
    cout << n - N << endl;
  }
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    double a, b, x; cin >> a >> b >> x;

    double degree;

    if ((a * a * b) / 2 >= x) {
        double l = (2.0 * x) / (a * b);

        double radian = atan2((double)l, (double)b);

        degree = radian * 180.0 / 3.141592653589793;

        cout << setprecision(10) << 90.0 - degree << endl;

        return 0;
    } else {
        double l = (2.0 * ((a * a * b) - x) / (a * a));

        double radian = atan2((double)l, (double)a);

        degree = radian * 180.0 / 3.141592653589793;

        cout << setprecision(10) << degree << endl;

        return 0;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vvl a(n,vl(n));
	rep(i,n)rep(j,n)cin>>a[i][j];
	auto wf=a;
	rep(k,n)rep(i,n)rep(j,n)wf[i][j]=min(wf[i][j],wf[i][k]+wf[k][j]);
	rep(i,n)rep(j,n)if(a[i][j]!=wf[i][j]){
		cout<<-1<<endl;
		return 0;
	}
	ll ans=0;
	rep(i,n)range(j,i+1,n){
		ll cost=a[i][j];
		rep(k,n)if(i-k)if(j-k)if(a[i][j]==a[i][k]+a[k][j])cost=0;
		ans+=cost;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1664
from collections import OrderedDict


if __name__ == "__main__":
    N, X, Y = map(int, input().split())
    k_dict = OrderedDict()

    for i in range(1, N):
        k_dict[i] = 0

    for i in range(1, N):
        for j in range(i+1, N+1):
            if i <= X and j <= X:
                d = j - i
                k_dict[d] += 1
                # print('{} {} {} debug 1'.format(i, j, d))
                continue

            if i <= X and X < j and j < Y:
                d = min(j-i, X-i + 1 + Y-j)
                k_dict[d] += 1
                # print('{} {} {} debug 2'.format(i, j, d))
                continue

            if i <= X and Y <= j:
                d = X-i + 1 + j-Y
                k_dict[d] += 1
                # print('{} {} {} debug 3'.format(i, j, d))
                continue

            if X < i and i < Y and X < j and j < Y:
                d = min(j-i, i-X + 1 + Y-j)
                k_dict[d] += 1
                # print('{} {} {} debug 4'.format(i, j, d))
                continue

            if X < i and i < Y and Y <= j:
                d = min(j-i, i-X + 1 + j - Y)
                k_dict[d] += 1
                # print('{} {} {} debug 5'.format(i, j, d))
                continue

            if Y <= i and Y <= j:
                d = j-i
                k_dict[d] += 1
                # print('{} {} {} debug 6'.format(i, j, d))
                continue

    for k, v in k_dict.items():
        # print('{} {}'.format(k, v))
        print(v)


Measured memory_bytes: 50908
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
const ll nmax=8;
bool graph[nmax][nmax];
ll dfs(ll v,ll N,bool visited[nmax]){
   bool all_visited=true;
   for(ll i=0;i<N;++i){
     if(visited[i]==false)all_visited=false;
   }
   if(all_visited){
     return 1;
    }
ll ret=0;
for(ll i=0;i<N;++i){
  if(graph[v][i]==false) continue;
  if(visited[i]) continue;
  visited[i]=true;
  ret+=dfs(i,N,visited);
  visited[i]=false;
  }
  return ret;
} 
int main()
{
  ll S,N;
  cin>>S>>N;
  if(S<=N)cout<<"unsafe"<<endl;
  else cout<<"safe"<<endl;
}

Measured memory_bytes: 3628
from sys import stdin

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input())

def sinput():
	return input().split()

def intsput():
	return map(int, sinput())

n, m = intsput()
ls = list(intsput())
ls = sorted(ls)
total = 0
for x in ls:
	total += x
crit = total / (4*m)
ls = ls[::-1]
if ls[m-1]>=crit:
	print("Yes")
else:
	print("No")


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

//--------------------------------------------
#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(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int main(){
  LL n,k;

  scanf("%lld %lld",&n,&k);

  LL ka = 1;
  REP (i, n - 1) ka *= k - 1;
  printf("%lld\n",ka * k);
}


Measured memory_bytes: 256
N =  int(input())
cnt = [input() for i in range(N)]

ac=0
wa=0
tle=0
re=0

for i in range(N):
        if  cnt[i] == 'AC':
                ac+=1
        elif cnt[i] == 'WA':
                wa+=1
        elif cnt[i] == 'TLE':
                tle+=1
        else :
                re+=1
print('AC x ',ac)
print('WA x ',wa)
print('TLE x ',tle)
print('RE x ',re)

Measured memory_bytes: 16332
N = int(input())
b = list(map(int,input().split()))
ans = []
count = 1
for i in range(N-1,-1,-1):
    flag = True
    for j in range(i,-1,-1):
        if b[j] == j+1:
            ans.append(j+1)
            b.pop(j)
            flag = False
            break
    if flag:
        break
if flag:
    print(-1)
else:
    for i in range(len(ans)-1,-1,-1):
        print(ans[i])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
        
	ll x;cin>>x;
	cout<<1-x<<endl;
}

Measured memory_bytes: 3648
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int n;
void unite(int *id, int x, int y){
  int set_id;
  set_id = id[y];
  for(int i=0;i<n;i++){
    if(id[i] == set_id) id[i] = id[x];
  }
  return;
}

bool same(int *id, int x, int y){
  if(id[x] == id[y]) return true;
  else return false;
}

int main(void){
  int q, x, y, com;
  cin >> n >> q;
  int id[n];

  for(int i=0;i<n;i++) id[i] = i;

  for(int i=0;i<q;i++){
    cin >> com >> x >> y;
    if(com == 0) unite(id, x, y);
    else if(com == 1){
      if(same(id, x, y)) cout << "1" << endl;
      else cout << "0" << endl;
    }
  }

    return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int x = read(), ans = 0;
  if (x == 1) {
    print(1);
    return 0;
  }
  for (int i = 2; i <= x; i++) {
    int tmp = i;
    while ((tmp = tmp * i) <= x) chmax(ans, tmp);
  }
  print(ans);
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
H, W, K = map(int, input().split())
S = [input()[:-1] for _ in [0]*H]
N = H+W
ans = 0
for bitH in range(1 << H):
    T = []
    for h in range(H):
        if bitH >> h & 1:
            T.append(S[h])

    for bitW in range(1 << W):
        cnt = 0
        for w in range(W):
            if bitW >> w & 1:
                for t in T:
                    cnt += 1 if t[w] == "#" else 0

        if cnt == K:
            ans += 1

print(ans)


Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;



int main() {
    int a,b,c;
    cin >> a >> b >> c;
    string ans = "NO";
    for(int i = a;i < a*b;i+=a){
        if(i%b == c){
            ans = "YES";
        }
    }
    cout << ans;
}




Measured memory_bytes: 3588
while True:
    d, w, h = sorted(map(int, input().split()))
    if d == w == h == 0:
        break
    dw = (d**2 + w**2)
    n = int(input())
    for i in range(n):
        y = int(input())
        if (2*y)**2 > dw:
            print("OK")
        else:
            print("NA")



Measured memory_bytes: 5592
n = int(input())
s = input()

codec = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O' , 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
result = ''
for _s in s:
    result += codec[(codec.index(_s) + n) % 26]

print(result)


Measured memory_bytes: 3188
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << setprecision(20);
    
    int a, b, c;
    cin >> a >> b >> c;
    
    cout << a * b / 2 << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int A[1000000],n;

int binarysearch(int key){
  int left=0;
  int right=n;
  int mid;

  while(left<right){
    mid=(left+right)/2;
    if(A[mid]==key){
    return 1;
    }
    else if(key<A[mid]){
      right=mid;
    }
    else{
      left=mid+1;
    }
  }
    return 0;
}

  int main(){
    int q,key,i;
    int count=0;

    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d",&A[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
      scanf("%d",&key);
      count=count+binarysearch(key);
    }
    printf("%d\n",count);

    return 0;
  }



Measured memory_bytes: 2188
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
	string s;
	cin >> s;
	int current = 0;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			current++;
		}
		else {
			ans = max(ans, current);
			current = 0;
		}
		if (i == s.size() - 1 ) {
			if (current > ans) {
				ans = current;
			}
		}
	
	}
	cout << ans;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int T = sc.nextInt();
        
        int total = 0;
        int second = 1;
        while ( A * second <= T ){
            total += B;            
            second++;
        }
        
        System.out.println(total);
    }
}


Measured memory_bytes: 23252
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1 == 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int maxl = 1e18;
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("out.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        int k;
        cin >> k;
        string s;
        cin >> s;
        for (int i = 0; i < min((int)s.length(), k); i++)
            cout << s[i];
        if (s.length() > k) {
            cout << "...";
        }
    }
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == '1') {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
n = int(raw_input())
a = raw_input().split()

b = []
c = []
for i in range(n):
  if i % 2:
    b.append(a[i])
  else:
    # b.insert(0, a[i])
    c.append(a[i])

b = c[::-1] + b

if n % 2:
  print " ".join(b)
else:
  print " ".join(b[::-1])


Measured memory_bytes: 26972
import sys
input = sys.stdin.readline
"""
N,X=map(int,input().split())
vA=list(map(int,input().split()))
vA.sort()
"""

S=input().rstrip()
T="hi"

res=any(S==T*i for i in range(1,6))
print("No Yes".split()[res])
#print(res)


Measured memory_bytes: 2940
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
cnt1,cnt2 = 0,0
for i in range(x):
  if i in a:
    cnt1+=1
for i in range(x+1,n+1):
  if i in a:
    cnt2+=1
print(cnt1) if cnt1<cnt2 else print(cnt2)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
struct Node{
  int no;
  int mx;
  int mn;
  int num;//parの数
  void build(int i){
    no=i;mx=0;mn=0;
    num=0;
  }
};
signed main(){
  int n;cin>>n;
  vector<int> a(n+1);
  rep(i,n+1){
    cin>>a[i];
  }
  if(n==0&&a[0]==1){
    cout<<1<<endl;
    return 0;
  }
  if(a[0]!=0){
    cout<<-1<<endl;
    return 0;
  }
  a.push_back(0);
  vector<Node> node(n+1);
  rep(i,n+1){
    node[i].build(i);
  }
  node[n].mn=a[n];
  node[n].mx=a[n];
  for(int i=n-1;i>=0;--i){
    int mn=(node[i+1].mn-1)/2+1+a[i];
    node[i].mn=mn;
    int mx=node[i+1].mx+a[i];
    node[i].mx=mx;
  }
  if(node[0].mn>1){
    cout<<-1<<endl;
    return 0;
  }
  int res=1;
  node[0].num=1;
  rep1(i,n){
    if(node[i].mn<=node[i-1].num*2&&node[i-1].num*2<=node[i].mx){
      node[i].num=node[i-1].num*2-a[i];
      res+=node[i-1].num*2;
    }
    else if(node[i-1].num*2>node[i].mx){
      node[i].num=node[i].mx-a[i];
      res+=node[i].mx;
        if(node[i-1].num>node[i].mx){
        res=-1;
        break;
      }
    }
    else{
      res=-1;
      break;
    }
    //printf("res=%lld, num=%lld, mx=%lld, mn=%lld\n",res,node[i].num,node[i].mx,node[i].mn);
  }

  cout<<res<<"\n";

  return 0;
}


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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

int main(void){
    #ifdef ccsnoopy
        freopen("D:/Code/in.txt","r",stdin);
    #endif

    int n;
    map<int,int> mapper;
    int arr[100010];
    sc(n);
    FOR(i,n){
        sc(arr[i]);
        mapper[arr[i]] = i;
    }

    sort(arr,arr+n);
    int tot = 0;
    FOR(i,n){
        if(i%2 != mapper[arr[i]]%2){
            tot++;
        }
    }

    cout << tot/2;



    return 0;
}




Measured memory_bytes: 5376
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  vector<ll>a(30,1);
  rep(j,1,30){
    a[j]=a[j-1]*26;
    if(a[j]>=(ll)1e16)break;
  }
  ll n;cin>>n;
  rep(i,1,30){
    if(n<=a[i]){
      n--;
      string ret;
      rep(j,0,i){
        ret+=n%26+'a';
        n/=26;
      }
      reverse(ALL(ret));
      cout<<ret<<endl;
      return 0;
    }
    else n-=a[i];
  }
  return 0;
}

Measured memory_bytes: 3656
n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for i in range(n)]

maxa = [0 for i in range(m)]
for i in range(n):
    for j in range(m):
        maxa[j] += ca[i][j+1]
ans = 10**7
for i in range(m):
    if maxa[i] < x:
        ans = -1
        break

#print(maxa)

def sankousyo(l):
    if len(l) == n:
    #    print(l)
        global ans
        kingaku = 0
        maxa_k = [0 for i in range(m)]
        for i in range(n):
            if l[i] == 1:
                for j in range(m):
                    maxa_k[j] += ca[i][j+1]
        for i in range(m):
            if maxa_k[i] < x:
                kingaku = -1
                break
        if kingaku != -1:
            for i in range(n):
                if l[i] == 1:
                    kingaku += ca[i][0]
            ans = min(ans,kingaku)
    else:
        sankousyo(l+[0])
        sankousyo(l+[1])
    
if ans == 10**7:
    sankousyo([])

print(ans)

Measured memory_bytes: 9272
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

ll a[3][3];
ll c[3][3];

int main()
{
    rep(i,3){
        rep(j,3){
            cin >> a[i][j];
        }
    }
    ll n;
    cin >> n;
    vector<ll> b(n);
    rep(i,n){
        cin >> b[i];
    }
    rep(j,3){
        rep(k,3){
            rep(i,n){
                if(b[i]==a[j][k]){
                    c[j][k]=1;
                    break;
                }
            }
        }
    }
    bool flag=false;
    rep(i,3){
        ll cnt=0;
        rep(j,3){
            if(c[i][j]==1) cnt++;
        }
        if(cnt==3){
            flag=true;
            break;
        }
    }
    rep(i,3){
        ll cnt=0;
        rep(j,3){
            if(c[j][i]==1) cnt++;
        }
        if(cnt==3){
            flag=true;
            break;
        }
    }
    ll cnt1=0;
    ll cnt2=0;
    rep(i,3){
        if(c[i][i]==1) cnt1++;
    }
    if(cnt1==3) flag=true;
    rep(i,3){
        if(c[i][2-i]==1) cnt2++;
    }
    if(cnt2==3) flag=true;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a;
  cin >> b;
  int c;
  if ((a + b) % 2 == 0){
  c = a + b;
  } else {
  c = a + b + 1; 
  }
  cout << c / 2 << endl;
}

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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define All(x) (x).begin(), (x).end()
#define mp make_pair
#define Task "abc"

typedef long long ll;
const int maxn = 2e5 + 10;
const ll mod = 1e9 + 7;

ll f[maxn][3];

int main(){
  ios_base::sync_with_stdio(0); cin.tie(NULL);
//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);
  int n; cin >> n;
  vector<int> a(n+1);
  for (int i = 1; i <= n; ++i){
    cin >> a[i];
  }
  ll inf = ll(1e18);
  for (int i = 0; i <= n; ++i)
  for (int j = 0; j < 3; ++j) f[i][j] = -inf;
  f[1][0] = -inf; f[1][1] = 0; f[1][2] = a[1];
  f[2][0] = 0; f[2][1] = max(a[1], a[2]);
  for (int i = 3; i <= n; ++i){
    int l = i/2 - 1, r = (i+1) / 2;
    int opl = (i-2)/2 - 1, opr = (i-1) / 2;
    for (int j = opl; j <= opr; ++j){
      if (l <= j + 1 && j + 1 <= r) f[i][j - l + 1] = max(f[i][j - l + 1], f[i-2][j - opl] + a[i]);
    }
    opl = (i-1)/2 - 1, opr = i / 2;
    for (int j = opl; j <= opr; ++j){
      if (l <= j && j <= r) f[i][j - l] = max(f[i][j - l], f[i-1][j - opl]);
    }
  }
  cout << f[n][1];
return 0;
}


Measured memory_bytes: 8736
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int N, K;

void _main() {
    cin >> N >> K;
    int ans = 0;
    REP(i, N) {
        int h;
        cin >> h;
        ans += (h >= K);
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i'))
            freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o'))
            freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int main() {
  const int inf = 1000000000;
  int h, n;
  cin >> h >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a.at(i) >> b.at(i);
  vector<int> dp(h + 1, inf);
  dp.at(h) = 0;
  for (int i = 0; i < n; i++) {
    for (int j = h; j >= 0; j--) {
      int k = min(j + a.at(i), h);
      dp.at(j) = min(dp.at(j), dp.at(k) + b.at(i));
    }
  }
  cout << dp.at(0) << endl;
}


Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))
w0 = W[0]
w1 = sum(W[1:])
x = [0]*(N-1)
x[0] = abs(w0 - w1)
for i in range(N-2):
    w0 += W[i+1]
    w1 -= W[i+1]
    x[i+1] = abs(w0 - w1)
print(min(x))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
    #define F first
    #define S second
    #define mkp(x, y) make_pair(x, y)
     
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    typedef vector<int> vi;
    typedef pair<int,int> pii;
     
     
    map<ll, ll> mp;
    ll a[222222];
    vector<int> ans;
    int main()
    {
    	ll n;
    	cin >> n;
    	a[0] = -1;
    	for(int i = 1; i <= n; i ++)
    	{
    		cin >> a[i];
    		if(a[i] - a[i - 1] > 1)
    		{
    			cout << -1;
    			return 0;
			}
    	}
    	ll ans = 0;
    	for(int i = 2; i <= n; i ++)
    	{
    		if(a[i - 1] == a[i] - 1)
    			ans ++;
    		else
    			ans += a[i];
    	}
    	cout << ans;
    }

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i, x, y) for(register int i = x; i <= y; ++i)
#define repd(i, x, y) for(register int i = x; i >= y; --i)
#define repl(i, x) for(register int i = fi[x]; i; i = l[i].next)
#define p_b push_back
#define m_p make_pair
#define X first
#define Y second
using namespace std;
typedef long long ll;
const int maxn = 2333;
ll n, x, ans;
ll read(){
	ll num = 0, flag = 1; char c = getchar();
	for(; c < '0' || c > '9'; c = getchar())
		if(c == '-') flag = 0;
	for(; c >= '0' && c <= '9'; c = getchar())
		num = (num<<3)+(num<<1)+c-48;
	return flag? num: -num;
}

void work(ll a, ll b){
	if(a < b) swap(a, b);
	if(!b){
		ans -= a;
		return;
	}
	ll cnt = a/b;
	ans += cnt*b*2;
	work(a-cnt*b, b);
}

int main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = read(); x = read();
	ans = x+(n-x);
	work(x, n-x);
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
  int y; //縦
  int x; //横
  string a="."; // 前の列
  string b; // 現在列
  string c; // 次の列
  char def='.';
  
  cin >> y >> x;
  
  //前列定義
  
  for ( int k = 0 ; k < x ; k++ ){
   a += def;
  }
  
  
  //現在列取得
  
  cin >> b;

  //次列取得と1列しかない時の処理
  
  if ( y != 1 ){
    cin >> c;
  }
  else{
    for ( int k = 0 ; k < x ; k++ ){
    c += def;
    }
  }
  
  for ( int i = 0 ; i < y ; i++ ){
    
    for ( int j = 0 ; j < x ; j++ ){
      
      if ( b.at(j) == '#' ) {
        cout << "#";
      }
      
      else{
        int mine=0;
        
        if ( j-1 >= 0 ){
          if ( a.at(j-1) == '#' ) mine++;
          if ( b.at(j-1) == '#' ) mine++;
          if ( c.at(j-1) == '#' ) mine++;
        }
        
        if ( j+1 < x ){          
          if ( a.at(j+1) == '#' ) mine++;        
          if ( b.at(j+1) == '#' ) mine++;
          if ( c.at(j+1) == '#' ) mine++;
        }
        
        if ( a.at(j) == '#' ) mine++;
        if ( c.at(j) == '#' ) mine++;       
        
        cout << mine;
      }
    }
    
    cout << endl;
    
    a=b;
    b=c;
    
    if ( i < y-2 ){
      cin >> c;
    }
    
    else{
      c = "";
      
      for ( int k = 0 ; k < x ; k++ ){
        c += def;
      }
      
    }
    
  }
  
}

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


//ABC 119 c
int n,a,b,c;
int ans = 1000000000;

void calc(vector<int> v,vector<int> l){
    int value[4] = {0,0,0,0};
    int count[4] = {-1,-1,-1,0};
    rep(i,n){
        value[v[i]] += l[i];
        
        count[v[i]]++;
    }

    if((count[0]+1)*(count[1]+1)*(count[2]+1)){
        int ans_cand = abs(a-value[0])+abs(b-value[1])+abs(c-value[2])+10*(count[0]+count[1]+count[2]);
        if(ans > ans_cand) ans = ans_cand;
    }
}

void dfs(int depth,vector<int> v,vector<int> l){
    if(depth==n) calc(v,l);
    else{
        for(int i = 0;i<4;i++){
            v[depth] = i;
            depth++;
            dfs(depth,v,l);
            depth--;
        }
    }
}




int main(){
    cin >> n >> a >> b >> c;
    vector<int> l(n),v(n);
    rep(i,n) cin >> l[i];
    v.assign(n+1,0);
    dfs(0,v,l);
    cout << ans << endl;
}




Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

template< typename Monoid >
struct SegmentTree
{
  using F = function< Monoid(Monoid, Monoid) >;
 
  int sz;
  vector< Monoid > seg;
 
  const F f;
  const Monoid M1;
 
  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }
 
  void set(int k, const Monoid &x)
  {
    seg[k + sz] = x;
  }
 
  void build()
  {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  void update(int k, const Monoid &x)
  {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  Monoid query(int a, int b)
  {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }
 
  Monoid operator[](const int &k) const
  {
    return seg[k + sz];
  }
};


int main(){
    int n, t, a[100010];
    cin >> n >> t;
    SegmentTree< int > seg(n, [](int a, int b){ return max(a, b); }, 0);
    REP(i, n){
        cin >> a[i];
        seg.set(i + 1, a[i]);
    }
    seg.build();
    int cnt = 1, maxa = 0;
    REP(i, n - 1){
        int tmp = seg.query(i + 2, n + 1);
        if(tmp - a[i] > maxa){
            cnt = 1;
            maxa = tmp - a[i];
        }else if(tmp - a[i] == maxa){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

/* n = 3 t = 2
a = 100 50 200
-- 売るところ/買うところの値段を変えるとよさそう
*/

/*
n = 5 t = 8
50 30 40 10 20
30 - 40 10 - 20
aj - ai (j >= i)に対してmax(aj - ai)の個数
重複するところはどうすればいいのか？
↑これ存在しないのでは？
    ex) n = 4 t = 8
        10 20
*/

Measured memory_bytes: 1664