akhauriyash/Code-Regression huggingface dataset:
// g++ -std=c++14 submit.cpp
// #define INF 9223372036854775807

# include <bits/stdc++.h>
// # define INF 1e9 + 1
using namespace std;

int main(){
  long int N, K;
  cin >> N >> K;
  vector<long int> A, F;
  long int v;

  long int tot = 0;
  for(int i=0; i<N; i++){
    cin >> v;
    A.push_back(v);
    tot += v;
  }

  if(tot <= K){
    cout << 0 << endl;
    exit(0);
  }

  for(long int i=0; i<N; i++){
    cin >> v;
    F.push_back(v);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  sort(F.begin(), F.end());

  long int l, r;
  l = 0;
  vector<long int> B;
  for(long int i=0; i<N; i++) {
    B.push_back(A[i] * F[i]);
    r = max(r, A[i]*F[i]);
  }

  long int ans = 1e12;

  while(l < r){
    long int m = (l+r) / 2;
    long int count = 0;
    for(long int i=0; i<N; i++){
      if(B[i] - m > 0){
        count += (B[i] - m) / F[i];
        if((B[i] - m) % F[i] != 0) count++;
      }
    }

    if(count <= K){
      ans = min(ans, m);
      if(r == m+1) break;
      r = m+1;
    } else {
      if(l == m-1) break;
      l = m-1;
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 6384
#include<bits/stdc++.h>
// Begin Header {{{
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
using namespace std;
using Graph = vector<vector<lli>>;
using P = pair<int, int>;
// }}} End Header

double calc(lli x, lli k, lli men){
	lli kaisu=0, now = x;
	while(now<k){
		now*=2;
		kaisu++;
	}
	return powl(0.5, (double)kaisu)/men;
}

int main(){
	lli N, K;
	cin >> N >> K;
	double ans=0.0;
	loop(i, 1, N+1){
		ans += calc(i, K, N);
	}
	printf("%.15f", ans);
}

Measured memory_bytes: 640
N, X = map(int, input().split())
L = list(map(int, input().split()))
D = [0 for i in range(N+1)]
for i in range(1, N+1):
    D[i]=(D[i - 1] + L[i-1])
    
count = 0
for value in D:
    if value <= X:
        count += 1

print(count)

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

typedef long long ll;
int main() {
    ll a[100000], N, i;
    cin >> N;
    for (i = 0; i < N; i++) cin >> a[i];

    sort(a,a+N);

    ll r = 0, s = 0;
    for (i = 0; i < N; i++) {
        s += a[i];
        (i == N-1 || a[i+1] <= 2*s) ? r++ : r = 0;
    }
    cout << r << endl;
}

Measured memory_bytes: 1024
import sys

N,M,C = map(int,input().split())

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

A = [ list(map(int,input().split())) for _ in range(N)]


#print(N,M,C)
#print("B")
#print(B)
#print("A")
#print(A)

num = 0
count = 0
for i in range(N):
    for j in range(M):
        num = num + B[j]*A[i][j]

    if ( (num + C) > 0): count = count + 1
    num = 0

print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	int N;
	cin >> N;
	vector<int> d(N);
	for(int i=0; i<N; ++i) cin >> d[i];
	sort(d.begin(), d.end());
	int now = d[0];
	int count = 1;
	for(int i=1; i<N; ++i){
		if(d[i]!=now){
			++count;
			now = d[i];
		}
	}
	cout << count << endl;
}



Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const MOD = 1000000007

var SIntListInitialValue int
var SIntListIsInitialized bool

type SIntList []int

func lib_IntSliceToMap(values []int) map[int]struct{} {
	m := map[int]struct{}{}
	for _, value := range values {
		m[value] = struct{}{}
	}
	return m
}
func lib_ModSum(a, b, mod int) int {
	return ((a % mod) + (b % mod)) % mod
}
func lib_NewSIntList(length int, initialValue int) SIntList {
	if SIntListIsInitialized {
		panic("SIntList is already used")
	}
	ret := make([]int, length, length)
	for i := 0; i < length; i++ {
		ret[i] = initialValue
	}
	SIntListInitialValue = initialValue
	return ret
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	var M int
	scanner.Scan()
	M, _ = strconv.Atoi(scanner.Text())
	a := make([]int, M)
	for i := 0; i < M; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
	}
	fmt.Println(solve(N, M, a))
}
func solve(N int, M int, a []int) int {
	dp := lib_NewSIntList(N+1, 0)
	m := lib_IntSliceToMap(a)
	if _, ok := m[1]; !ok {
		dp[1] = 1
	}
	if N == 1 {
		return dp[1]
	}
	if _, ok := m[2]; !ok {
		dp[2] = dp[1] + 1
	}
	if N == 2 {
		return dp[2]
	}
	for i := 3; i <= N; i++ {
		if _, ok := m[i]; ok {
			continue
		}
		dp[i] = lib_ModSum(dp[i-1], dp[i-2], MOD)
	}
	return dp[N]
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#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(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N,M,C;
	cin>>N>>M>>C;
	vector<int> A(M),B(M);
	rep(i,M)cin>>B[i];
	int cnt = 0;
	rep(i,N){
		int ans = C;
		rep(j,M){
			cin>>A[j];
			ans+=A[j]*B[j];
		}
		if(ans>0)cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <set>
#include <map>

#define X first
#define Y second
#define MP make_pair
#define PB push_back

using namespace std;

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

const int N = 1e5 + 500;
const int M = 1e6 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 20;
const int OFF = (1 << LOG);
const double EPS = 1e-9;
const double PI = 3.1415926535;

int a,b;

int main(){
    scanf("%d%d", &a, &b);
    printf("%d\n", a - 1 + int(a <= b));
    return 0;
}


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

struct edge
{int u,v,next;
};
struct edge e[200010];

int n,num,ans;
int head[200010],f[2][200010],g[200010];

void add(int u,int v)
{e[num].u=u;
 e[num].v=v;
 e[num].next=head[u];
 head[u]=num;
 num++;
 e[num].u=v;
 e[num].v=u;
 e[num].next=head[v];
 head[v]=num;
 num++;
}

void dfs(int i,int fa)
{int j;
 
 j=head[i];
 while(j!=-1)
 {	if(e[j].v!=fa)
 	{	dfs(e[j].v,i);
 		f[g[e[j].v]^1][i]++;
 	}
 	j=e[j].next;
 }
 g[i]=(f[0][i]==0);
}

void dfs1(int i,int fa,int flag)
{int j,x=0;
 int c[2];
 
 if(f[0][i]>=2) ans=1;
 
 //cout<<i<<" "<<fa<<" "<<f[0][i]<<" "<<f[1][i]<<" "<<flag<<endl;
 
 if(i!=1)
 {	c[0]=f[0][fa];
 	c[1]=f[1][fa];
 	c[g[i]^1]--;
 	c[flag]++;
 	x=(c[0]==0);
 	x^=1;
 	if(f[0][i]+(x==0)>=2) ans=1;
 	
 	//cout<<"## "<<i<<" "<<f[0][i]<<" "<<x<<endl;
 }
 else
 	x=1;
 j=head[i];
 while(j!=-1)
 {	if(e[j].v!=fa)
 		dfs1(e[j].v,i,x);
 	j=e[j].next;
 }
}	

int main()
{int i,j,x,y;
 
 while(scanf("%d",&n)!=EOF)
 {	num=0;
 	for(i=1;i<=n;i++)
	{	head[i]=-1;
		f[0][i]=f[1][i]=g[i]=0;
	}
 	for(i=1;i<n;i++)
 	{	scanf("%d%d",&x,&y);
 		add(x,y);
 	}
 	ans=(n==1);
 	dfs(1,0);
 	dfs1(1,0,0);
 	printf("%s",ans?"First":"Second");
 }
 return 0;
}

Measured memory_bytes: 4864
#include<cstdio>
using namespace std;
int n,tmp,mx,mn=1000000005;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&tmp);
		if(tmp>mx)mx=tmp;
		if(tmp<mn)mn=tmp;
	}
	printf("%d",mx-mn);
} 

Measured memory_bytes: 128
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    if (a * c <= b) {
      System.out.println(c);
    } else {
      System.out.println(b / a);
    }
  }
}

Measured memory_bytes: 22868
//?????贈?????????
 
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
    while(kbd.hasNext()){
        String cards = kbd.next();
        if(!cards.equals("-")){
        solve(cards);
        }
    }
    }
 
    static void solve(String cards){
    int m = kbd.nextInt();
    while(m > 0){
        int a = kbd.nextInt();
        String fore = cards.substring(0, a);
        String back = cards.substring(a, cards.length());
        cards = back+fore;
        m--;
    }
    System.out.println(cards);
    }
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int MOD = 1e9+7;
const long long INF = 1LL << 60;
const int INF_INT = 1e9;
typedef long long ll;

int main(){
    int n, a,b;
    cin >> n >> a >> b;
    int ans = min(n*a,b);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 2e5+5;

typedef pair <int,int> pii;
#define x first
#define y second

pii a[sz];

vector <int> g[sz];

int tree[sz*4], ans[sz];

void update(int node, int b, int e, int x, int v)
{
    if(x<b || e<x) return;
    if(b == e) {
        tree[node] += v;
        return;
    }

    int l=node<<1, r=l+1, m=b+e>>1;

    update(l, b, m, x, v);
    update(r, m+1, e, x, v);
    tree[node] = max(tree[l], tree[r]);
}

int segq(int node, int b, int e, int i, int j)
{
    if(i>j || e<i || j<b) return 0;
    if(i<=b && e<=j)
        return tree[node];

    int l=node<<1, r=l+1, m=b+e>>1;

    return max(segq(l, b, m, i, j), segq(r, m+1, e, i, j));
}

int heavy[sz], depth[sz], head[sz], par[sz], pos[sz], cpos;

int dfs(int u = 1)
{
    int subc = 1, mxc = 0;
    for(int v : g[u]) if(v ^ par[u]) {
        par[v] = u;
        depth[v] = depth[u] + 1;
        int nxtc = dfs(v);
        subc += nxtc;
        if(nxtc > mxc) mxc = nxtc, heavy[u] = v;
    }
    return subc;
}

void hfs(int u = 1, int h = 1)
{
    head[u] = h, pos[u] = ++cpos;
    int hv = heavy[u];
    if(hv) hfs(hv, h);

    for(int v : g[u])
        if(v ^ par[u] && v ^ hv)
            hfs(v, v);
}

int hldq(int u, int v, int n)
{
    int ans = 0;
    while(head[u] ^ head[v]) {
        if(depth[head[u]] < depth[head[v]])
            swap(u, v);
        ans = max(ans, segq(1, 1, n, pos[head[u]], pos[u]));
        u = par[head[u]];
    }

    if(depth[u] > depth[v]) swap(u, v);
    return max(ans, segq(1, 1, n, pos[u], pos[v]));
}

void go(int u = 1, int p = 0)
{
    for(int v : g[u]) if(v ^ p) {
        ans[v] = max(ans[v], ans[u]);
        go(v, u);
    }
}

int main()
{
    int n;
    cin >> n;
    for(int i=1; i<=n; i++) scanf("%d", &a[i].x), a[i].y = i;
    sort(a+1, a+n+1);

    for(int i=1; i<n; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }

    dfs();
    hfs();

    for(int i=1; i<=n;) {
        vector <int> now;
        for(int j=i; i<=n && a[i].x==a[j].x; i++) {
            int u = a[i].y;
            now.push_back(u);
            ans[u] = hldq(1, u, n) + 1;
        }
        for(int u : now) update(1, 1, n, pos[u], ans[u]);
    }

    go();
    for(int i=1; i<=n; i++) printf("%d\n", ans[i]);
}


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

int main()
{
	int a,b,c,cnt=0;
	cin >> a >> b >> c;
	for(int i = a; i <= b; i++)
	{
		if(i > c)
			break;
		if(c % i == 0)
		{
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

int main(){
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    vector<int> X(n);
    vector<int> Y(m);
    for(int i=0;i<n;i++){
        cin >> X[i];
    }
    for(int i=0;i<m;i++){
        cin >> Y[i];
    }
    int Xmax = x;
    int Ymin = y;
    for(int i=0;i<n;i++){
        Xmax = max(Xmax,X[i]);
    }
    for(int i=0;i<m;i++){
        Ymin = min(Ymin,Y[i]);
    }
    if(Xmax<Ymin) cout << "No War";
    else cout << "War";


}

Measured memory_bytes: 384
from collections import defaultdict, deque

n, q = map(int, input().split())

tree = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)

count = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    count[p - 1] += x

ret = [0] * n
q = deque(maxlen = n)
q.append((0, 0))
while len(q) > 0:
    f, c = q.popleft()
    ret[c] = count[c] + ret[f]
    for n in tree[c]:
        if n != f:
            q.append((c, n))

print(*ret)


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

long long N, M;

int main(){
	scanf("%lld%lld", &N, &M);
	long long res1 = min(N, M / 2);
	long long res2 = (M - res1 * 2) / 4;
	printf("%lld\n", res1 + res2);
	return 0;
}


Measured memory_bytes: 256
/*
    Mbak Sana Dong
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[200200];
int main()
{
    int n,m,i,j,k,x,y,ans,curr,temp;
    ll now;
    cin >> now;
    if(now % 2 == 1)
    {
        cout << "0" << endl;
        return 0;
    }
    ll sana = 0;
    now /= 2;
    while(now > 0)
    {
        sana += now/5;
        now /= 5;
    }
    cout << sana << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans;}
   base *= base;pow/=2;}return ans;}
ll expo1(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}   
ll inv(ll x){return expo1(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){if(k == 0) return 1LL;
    ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};

int dp[123456],vis[123456];
vector <vector <int> > vec;
int ans = 0;
void dfs(int n){
     dp[n] = 1;
     vis[n] = 1;
     int max1 = 0;
     for(auto x:vec[n]){
         if(!vis[x]){
            dfs(x);
         }
         max1 = max(max1,dp[x]);
     }
     dp[n] += max1;
     ans = max(ans, dp[n]);
}

int main(){
    int n, m;
    cin >> n >> m;
    vec.resize(n+1);
    for(int i = 0; i < m; i++){
       int u,v;
       cin >> u >> v;
      vec[u].push_back(v);
    }
    for(int i = 1; i <= n; i++){
        if(!vis[i]) dfs(i);
    }
    cout << ans-1;
}


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

int main() {
  int n;
  cin>>n;
  bool ans=true;
  map<ll,ll> mp;
  rep(i,n){
    int a;
    cin>>a;
    mp[a]++;
    if(mp[a]>=2){
      ans=false;
    }
  }
  if(ans){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 12800
// 参考(AtCoder Beginner Contest 113 - 情報妖精の競プロ日記 https://31536000.hatenablog.com/entry/2018/11/04/233559)
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstdlib>
#include <math.h>
#include <algorithm>
#include <numeric>
const int MAX = 100000;
using namespace std;

int main(){
  int N, M, P, Y;
  scanf("%d%d", &N, &M);
  static pair<pair<int, int>, int> city[MAX];
  static pair<int, int> num[MAX];
  for (int i = 0;i < M; i++) {
    scanf("%d%d", &P, &Y);
    city[i] = make_pair(make_pair(P, Y), i);
  }
  sort(city, city+M);
  for (int i = 0, c = 1;i < M; i++, c = city[i-1].first.first == city[i].first.first ? c + 1 : 1) {
    num[city[i].second] = make_pair(city[i].first.first, c);
  }
  for (int i = 0; i < M; i++) {
    printf("%06d%06d\n", num[i].first, num[i].second);
  }
  return 0;
}


Measured memory_bytes: 3456
m = int(input())
info = [list(map(int, input().split())) for i in range(m)]

amari = 0
ans = 0
for i in range(m):
    a, b = info[i]
    while b != 0:
        if a == 0:
            ans += b
            break
        elem_num = -((-10) // a)
        kumi_num = b // elem_num
        if amari == 0:
            ans += max(0, (b % elem_num) -1)
        else:
            ans += max(0, (b % elem_num))
        amari += a * (b % elem_num)
        ans += kumi_num * (elem_num - 1)
        ans += kumi_num
        a = (a * elem_num) // 10 + ((a * elem_num) % 10)
        b = kumi_num
        if amari >= 10:
            ans += 1
            amari = amari // 10 + (amari % 10)
print(ans)


Measured memory_bytes: 80600
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;


int main(){
  ll n,c,k;
  cin >> n >> c >> k;

  std::vector<ll> t(n);
  rep(i,n){
    cin >> t.at(i);
  }
sort(all(t));

ll a=t.at(0),ne=0,pa=1,bus=0,time;
for(auto i=1;i<n;i++){
  if(ne==1){
    a=t.at(i-1);
    ne=0;
  }


  time=t.at(i)-a;
  pa++;

  if(time>k || pa>c){
    bus++;
    ne=1;
    pa=1;
  }


}

  cout << bus+1 << endl ;


  }


Measured memory_bytes: 3940
package main

import (
	"fmt"
	"strings"
)

func main() {
	var (
		n, m int
		S    string
		Ss   string
	)
	fmt.Scan(&n, &m, &S)
	for i, s := range S {
		if i != m-1 {
			Ss += string([]rune{s})
		} else {
			Ss += strings.ToLower(string([]rune{s}))
		}
	}
	fmt.Println(Ss)
}


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

int main() {
	long long N, M; cin >> N >> M;
	if (2 * N >= M) {
		cout << M/2;
	}
	else {
		long long d = M - 2 * N;
		cout << N + d / 4;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
int A, B;
cin >> A >> B;
 
if(A % 3 == 0) { cout << "Possible" << endl; return 0; }
if(B % 3 == 0) { cout << "Possible" << endl; return 0; }
if((A + B) % 3 == 0) { cout << "Possible" << endl; return 0; }
 
 
cout << "Impossible" << endl;
 return 0;
}

Measured memory_bytes: 3604
<?php

fscanf(STDIN, '%d %d', $x, $n);

if ($n === 0) {
    fprintf(STDOUT, "%d\n", $x);
} else {
    fscanf(STDIN, "%[^\n]", $s);
    $list = explode(' ', $s);

    $i = 0;
    while (true) {
        if (false === array_search($x - $i, $list)) {
            fprintf(STDOUT, "%d\n", $x - $i);
            break;
        } elseif (false === array_search($x + $i, $list)) {
            fprintf(STDOUT, "%d\n", $x + $i);
            break;
        }

        ++$i;
    }
}


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

using namespace std;

int main(int argc, char *argv[])
{
    int N;
    cin >> N;
    struct block {
        int w;
        int s;
        int v;
        bool operator<(const block& b) const {
            return s - b.w > b.s - w;
        }
    };
    vector<block> blocks(N);
    int max_solidity = 0;
    for (int i = 0; i < N; i++) {
        cin >> blocks[i].w >> blocks[i].s >> blocks[i].v;
        max_solidity = max(max_solidity, blocks[i].s);
    }
    max_solidity *= 2;
    sort(begin(blocks), end(blocks));
    const int INF = 1e9;
    vector<long> dp(max_solidity + 1, -INF);
    dp[max_solidity] = 0;
    long res = 0;
    for (int i = 0; i < N; i++) {
        block b = blocks[i];
        for (int solidity = b.w; solidity <= max_solidity; solidity++) {
            int s = min(b.s, solidity - b.w);
            dp[s] = max(dp[s], dp[solidity] + b.v);
            res = max(res, dp[s]);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int count = 0;
    while (A >= B) {
        count++;
        B *= 2;
    }
    while (B >= C) {
        count++;
        C *= 2;
    }
    if (K < count) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3616
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
bool second_greater(const pii& left, const pii& right) {
    return left.second > right.second;
}
#endif


int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;  cin >> N;
    vi A(N); 
    set<int> st;
    REP(i, N) {
        cin >> A[i];
        st.insert(A[i]);
    }

    map<int,int> mp;
    for (int k : st) mp[k] = 0;

    REP(i, N) mp[A[i]]++;

    int ans = 0;
    for (int k : st) {
        if (k < mp[k]) ans += mp[k] - k;
        else if (k > mp[k]) ans += mp[k];
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

struct mons{
  ll X,A;
  bool operator<(const mons& other){return X < other.X;}
};
class BIT{
  public:
  vector<ll> s;
  const int n;
  BIT(int N) : s(N+1,0),n(N){}
  ll sum(int i){
    ll res = 0;
    while(i){
      res += s[i];
      i -= i & -i;
    }
    return res;
  }
  ll sum(int l,int r){
    return sum(r)-sum(l-1);
  }
  void add(int pos,ll val){
    while(pos <= n){
      s[pos] += val;
      pos += pos & -pos;
    }
  }
};

int main(){
  
  ll n,d,a;
  cin >> n >> d >> a;
  vector<mons> v(n);
  rep(i,n)cin >> v[i].X >> v[i].A;
  sort(ALL(v));
  BIT bit(n+10);
  ll res = 0;
  rep(i,n){
    ll k = bit.sum(i+1);
    if(v[i].A - k <= 0)continue;
    ll sum = (v[i].A-k+a-1)/a;
    res += sum;
    bit.add(i+1,a*sum);
    ll left = 0,right = n;
    while(right-left > 1){
      ll mid = (right+left)/2;
      if(v[mid].X > v[i].X+2*d)right = mid;
      else left = mid;
    }
    bit.add(left+2,-a*sum);
  }
  cout << res << endl;





  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
int a,b;
cin>>a>>b;
char dot[a][b];
rep(i,a){
    rep(j,b){
        cin>>dot[i][j];
    }
}
    rep(i,a){
        rep(j,b){
            cout<<dot[i][j];
        }
        cout<<endl;
        rep(j,b){
            cout<<dot[i][j];
        }
        cout<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
ans [] [] = 0
ans (v:vs) (c:cs)
  | v > c = v - c + ans vs cs
  | otherwise = ans vs cs



main = do
  n <- read <$> getLine :: IO Int
  vs <- (map read . words) <$> getLine :: IO [Int]
  cs <- (map read . words) <$> getLine
  putStrLn $ show $ ans vs cs



Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)     for(long long int i=a; i<n; i++)
#define loop(i,a,n)     for(long long int i=a; i>=n; i--) 

set<long long int> factors(long long int a) {set<long long int> v; for(long long int i=2; i*i<=a; i++){while(a%i==0){v.insert(i);a/=i;}}if(a>=2)v.insert(a);return v;}

int main()
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL);
	
	int a;
	cin>>a;
	int b[a], flag=0;
	map<int,int> m;
	forr(i, 0, a)
	{
		cin>>b[i];
		set<long long int> v=factors(b[i]);
		for(auto const x: v)
			m[x]++;
	}
	for(auto const x: m)
	{
		if(x.second!=1)
		{
			flag=1;
			if(x.second>=a)
			{
				return cout<<"not coprime", 0;
			}
		}
	}
	if(!flag)
		cout<<"pairwise coprime";
	else
		cout<<"setwise coprime";
	
	return 0;
}

Measured memory_bytes: 11192
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;

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

    vector<ll> s(A+2), t(B+2), x(Q);
    s[0] = -100000000000;
    rep(i,A) cin >> s[i+1];
    s[A+1] = 100000000000;
    t[0] = -100000000000;
    rep(i,B) cin >> t[i+1];
    t[B+1] = 100000000000;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    rep(i,Q) cin >> x[i];

    rep(i,Q){

        int s_left = lower_bound(s.begin(), s.end(), x[i]) - s.begin();
        int s_right = upper_bound(s.begin(), s.end(), x[i]) - s.begin()-1;
        int t_left = lower_bound(t.begin(), t.end(), x[i]) - t.begin();
        int t_right = upper_bound(t.begin(), t.end(), x[i]) - t.begin()-1;

        ll s_distances[2];
        s_distances[0] = s[s_left];
        s_distances[1] = s[s_right];

        ll t_distances[2];
        t_distances[0] = t[t_left];
        t_distances[1] = t[t_right];

        ll ans = INF;
        for (int j = 0; j < 2; j++){
            ans = min(ans, abs(x[i] - s_distances[j]) +abs(s_distances[j] - t_distances[j]));
            ans = min(ans, abs(x[i] - s_distances[j]) +abs(s_distances[j] - t_distances[(j+1)%2]));
        }
        for (int j = 0; j < 2; j++){
            ans = min(ans, abs(x[i] - t_distances[j]) +abs(t_distances[j] - s_distances[j]));
            ans = min(ans, abs(x[i] - t_distances[j]) +abs(t_distances[j] - s_distances[(j+1)%2]));
        }

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

    }


}

Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define IT iterator 
#define vi vector<int>
#define TP template<class o>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20,mod=998244353,inf=2e9;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
    char c=gc; x=0; int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
    while(isdigit(c)) x=x*10+c-'0',c=gc;
    x*=f;
}
template<class o> void qw(o x) {
    if(x/10) qw(x/10);
    putchar(x%10+'0');
}
template<class o> void pr1(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar('\n');
}

bool f[N][2];
int n,a[N];
int main() {
    qr(n);
    for(int i=1;i<=n;i++) qr(a[i]);
    f[1][0]=f[1][1]=1;
    for(int i=1;i<=n;i++)
        for(int j=0;j<2;j++)
            for(int k=0;k<2;k++)
                f[i][j] |= f[i-1][k]&&(a[i-1]-k<=a[i]-j);
    int ans=f[n][0]|f[n][1];
    if(ans) puts("Yes");
    else puts("No");
    return 0;
}

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


int main() {
  int k,n;
  cin>>k>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++)cin>>vec.at(i);
  sort(vec.begin(),vec.end());
 // for(int i=0;i<n;i++)cout<<vec.at(i)<<" ";
 /* 
  for(int i=0;i<n;i++){
    for(int j=0;j<i;j++){
      if(vec.at(i)<vec.at(j))swap(vec.at(i), vec.at(j));
    }
  }
  */
  int longer=max(vec.at(1)-vec.at(0),k+vec.at(0)-vec.at(n-1));
  for(int i=1;i<n-1;i++)longer=max(longer,vec.at(i+1)-vec.at(i));
  cout<<k-longer;
}






Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>


using namespace std;


int main(){

    int N;
    cin >> N;

    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        /* code */
        int tmp = i;
        int cnt = 0;
        while(tmp > 0){
            tmp = tmp / 10;
            //cout << "i:" << i << endl;
            //cout <<"tmp:" << tmp << endl;
            cnt++;
        }
        if(cnt % 2 != 0){
            ans++;
        }
    }
    
    cout << ans << endl;



}


Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int a[114514];
int main() {
	int n,iwa=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		if (a[i] == a[i + 1]) {
			iwa++;
			a[i] = 10000;
			a[i + 1] = a[i];
		}
	}
	cout << iwa << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 205;

queue <int> q;
int g[N][N], ans[N];
int n, maxn;

int main() {
    read(n);
    for(register int i = 1; i <= n; i++) {
        for(register int j = 1; j <= n; j++) {
            char c = getchar();
            while(c < '0' || c > '9') c = getchar();
            g[i][j] = c - '0';
        }
    }
    for(register int i = 1; i <= n; i++) {
        memset(ans, 0, sizeof(ans));
        ans[i] = 1; q.push(i);
        while(!q.empty()) {
            int u = q.front(); q.pop();
            for(register int v = 1; v <= n; v++) {
                if(g[u][v]) {
                    if(ans[v] == ans[u]) {
                        print(-1, '\n');
                        return 0;
                    }
                    if(!ans[v]) {
                        ans[v] = ans[u] + 1;
                        q.push(v);
                    }
                }
            }
        }
        for(register int j = 1; j <= n; j++) maxn = max(maxn, ans[j]);
    }
    print(maxn, '\n');
    return 0;
}

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

int main() {
  int n,x;
  cin>>n>>x;
  std::vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
    x-=v[i];
  }
  sort(v.begin(),v.end());
  cout<<n+x/v[0]<<endl;
}


Measured memory_bytes: 256
import sys

s = input()

for i in range(len(s)):
    if(i%2 ==0):
        if(s[i] != 'R'and s[i] != 'U' and s[i] != 'D'):
            print('No')
            sys.exit()
    else:
        if(s[i] != 'L'and s[i] != 'U' and s[i] != 'D'):
            print('No')
            sys.exit()

print("Yes")

Measured memory_bytes: 3060
#include <iostream>

using namespace std;
int main()
{
	long X;
	cin >> X;

	long kyu = 0;
	if (400 <= X && X <= 599)
	{
		kyu = 8;
	}
	else if (600 <= X && X <= 799)
	{
		kyu = 7;
	}
	else if (800 <= X && X <= 999)
	{
		kyu = 6;
	}
	else if (1000 <= X && X <= 1199)
	{
		kyu = 5;
	}
	else if (1200 <= X && X <= 1399)
	{
		kyu = 4;
	}
	else if (1400 <= X && X <= 1599)
	{
		kyu = 3;
	}
	else if (1600 <= X && X <= 1799)
	{
		kyu = 2;
	}
	else if (1800 <= X && X <= 1999)
	{
		kyu = 1;
	}

	cout << kyu << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int m;
  char a[33];
  char b1[11]={'y','u','i','o','p','h','j','k','l','n','m'},b2[15]={'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};

  while(1){
    int count=0;

    scanf("%s",a);
    m=strlen(a);
    for(int i=0;i<m;i++)
      if(a[i]=='#')
	m--;
    if(m==0)break;
    
    for(int i=0;i<m;i++)
      for(int j=0;j<11;j++)
	if(a[i]==b1[j])
	  for(int k=0;k<15;k++)
	    if(a[i+1]==b2[k])count++;

    for(int i=0;i<m;i++)
      for(int j=0;j<15;j++)
	if(a[i]==b2[j])
	  for(int k=0;k<11;k++)
	    if(a[i+1]==b1[k])count++;
    
    cout<<count<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi t(N+1,0),x(N+1,0),y(N+1,0);
  rep(i,N) {
    cin >> t[i+1] >> x[i+1] >> y[i+1];
  }
  rep(i,N) {
    int b = t[i+1]-t[i];
    int d = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    if(b<d) {
      cout << "No" << endl;
      return 0;
    }
    if((b-d)&1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1408
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int64 a, b; cin >> a >> b;
  bitset<32> bit1(a), bit2(b);
  cout << (bit1 & bit2) << '\n';
  cout << (bit1 | bit2) << '\n';
  cout << (bit1 ^ bit2) << '\n';

  return 0;
}


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


// これだと計算量はNM
// int main(){
//   int N, M;
//   cin >> N >> M;
//   vector<int> data(M*2);
//   for(int i=0; i<M*2;i++)cin >> data.at(i);
//   sort(data.begin(), data.end());
//   for(int i = 1; i<N+1;i++){
//     int res = 0;
//     for(int j = 0; j<M*2; j++){
//       if(data.at(j) == i)res+=1;
//     }
//     cout << res << endl;
//   }
// }

// これだとN+M
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> roads(100);
  vector<int> data(M*2);
  for(int i=0; i<M*2;i++)cin >> data.at(i);
  for(int i=0; i<M*2;i++){
    roads.at(data.at(i)-1)+=1;
  }
  for(int i=0;i<N;i++){
    cout << roads.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;   //m[3]=5;
vector<int> v;

int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;++i){
		int x;
		cin>>x;
		if(m[x]==0)v.push_back(x);  //m.count(x)==0
		++m[x];
	}
	int ans=0;
	for(int i=0;i<v.size();++i)
		if(v[i]>m[v[i]]) ans+=m[v[i]];
		else if(v[i]<m[v[i]]) ans+=m[v[i]]-v[i];
	cout<<ans<<"\n";
	return 0; 
}

Measured memory_bytes: 5112
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, w; cin>>n>>w;
	int wt[n+1], value[n+1];
	int total_value=0;
	for(int i=0;i<n;i++){
		cin>>wt[i]>>value[i];
		total_value+=value[i];
	}
	int dp[total_value+1];
	dp[0]=0;
	for(int i=1;i<=total_value;i++)
		dp[i]=1e9+9;
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=total_value;j>=value[i-1];j--){
			dp[j] = min(dp[j], dp[j-value[i-1]] + wt[i-1]);
			if(dp[j]<=w)
				ans=max(ans, j);
		}
	} 
	cout << ans << endl;
}


Measured memory_bytes: 4008
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let x: f64 = itr.next().unwrap().parse().unwrap();

    let mut v = 100.0;
    let mut cnt = 0;
    while v < x {
        let up = (v * 0.01).floor();
        v += up;
        cnt += 1;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2656
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x)      x.begin(), x.end()
#define rep(i,n)    for (int i = 0; i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

bool isSorted(const vector<int> &a)
{
    for (int i= 1; i < a.size(); ++i)  {
        if (a[i-1] >= a[i]) return false;
    }
    return true;
}

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);

    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) {
        cin >> a[i];
    }

    if(isSorted(a)) {
        puts("YES");
        return 0;
    }

    for (int i = 0; i < N; ++i){
        for (int j = i+1; j < N; ++j) {
            auto b = a;
            swap(b[i], b[j]);
            if (isSorted(b)) {
                puts("YES");
                return 0;
            }
        }
    }

    puts("NO");

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int m=min(x,y);
  int ans;
  if(a+b<2*c){
    ans = (a+b)*m;
  }else{
    ans = 2*c*m;
  }
  
  x -= m;
  y -= m;
  
  if(x>0){
    if(a<2*c){
      ans += a*x;
    }else{
      ans += 2*c*x;
    }
  }
  
  if(y>0){
    if(b<2*c){
      ans += b*y;
    }else{
      ans += 2*c*y;
    }
  }

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

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

int main() {

  int a,b;
  cin >> a >> b;
  
  vector<int> t,s;
  rep(i,a) {
    int azi = i+1 + b-1;
    t.push_back(azi);
    s.push_back(abs(azi));
  }
  
  int sum = 0;
  rep(i,a) sum += t[i];
 
  sort(s.begin(), s.end());
  
  if(sum >= 0) cout << sum - s[0] << endl;
  else cout << sum + s[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
long long n,x,a[105],s;
 
int main()
{
    cin >> n >> x;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    if (s==x) 
    {
        cout << n;
        return 0;
    }
    s=0;
    sort(a+1,a+n+1);
    for (int i = 1; i <= n; i++)
    {
        s+=a[i];
        if (s>x)
        {
            cout << i-1;
            return 0;
        }
        if (i==n)
        {
            cout << n-1;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
const double pi = acos(-1);
const int mod = 998244353;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;

int main(){
	string s;
	cin >> s;
	int fl = 0;
	for(int i = 0;i < s.size();i++){
		if(s[i] == '7') fl = 1;
	}
	if(fl) cout << "Yes"<<endl;
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        int w = stdIn.nextInt();
        int h = stdIn.nextInt();
        int x = stdIn.nextInt();
        int y = stdIn.nextInt();
        int r = stdIn.nextInt();
        
        if ((x >= r) && (x <= (w-r)) && (y >= r) && (y <= (h-r))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 26324
import java.util.*;
import java.util.ArrayList;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int flag = 0;
        if(n%4 == 0 || n%7 == 0){
            flag = 1;
        }
        while(n >= 0){
            n = n-4;
            if(n % 7 == 0){
                flag = 1;
                break;
            }
        }
        if(flag == 1){
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }
    }
}

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

using ll = long long;
using pll = pair<ll, ll>;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    ll N, A, B, C, D;
    bool solve() {
        cin >> N >> A >> B >> C >> D;
        N--;
        B -= A;
        A = 0;
        bool ok = false;
        rep(i, N) {
            ll l = N * C - (C + D) * i;
            ll r = l + N * (D - C);
            if(l <= B and B <= r) {
                ok = true;
            }
        }
        if(ok) cout << "YES" << endl;
        else cout << "NO" << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 256
eval"N,K="+`tr \\  ,`
*I=s=0
1.upto([N,K+x=y=1].min){|i|s+=x*y
I<<r=i<2?1:M/i*-I[M%i]%M
x=x*N*r%M=10**9+7
y=y*r%M*N-=1}
p s%M

Measured memory_bytes: 3720
using System;
using System.Linq;
using System.Collections.Generic;

class Program {
  static void Main() {
    string[] input = Console.ReadLine().Split(' ');
    int n = int.Parse(input[0]);
    input = Console.ReadLine().Split(' ');
    List<int> a = new List<int>(Array.ConvertAll<string, int>(input, int.Parse));
    int result = n-a.Sum();
    
    Console.WriteLine((result>=0?result:-1).ToString());
  }
}

Measured memory_bytes: 29360
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long ans=0;
  int N,P;
  cin>>N>>P;
  int kisuu=0,guusuu=0;
  for(int i=0;i<N;i++){
    int a;cin>>a;
    if(a%2)
      kisuu++;
    else
      guusuu++;
  }
  if(P==1){
    if(kisuu==0)
      ;
    else{
      ans+=pow(2,guusuu)*pow(2,kisuu);
      ans/=2;
    }
  }else{
      ans+=pow(2,kisuu)*pow(2,guusuu);
      if(kisuu==0){
	;}else if(N!=1)
	ans/=2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 512
var lines = [];

var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var v = [];
    var N = lines.shift();
    N = Number(N);

    for (var i = 0; i < 5; i++) {
        v[i] = Number(lines[i]);
    }

    var a = Array(6).fill(0);
    var result = 0;

    a[0] = N;
    var min = Infinity; var hoge = 0;

    for (var i = 0; i < 5; i++) {
        if (v[i] < min) { min = v[i]; hoge = i; }
    }

    for (var i = 0; i < 5; i++) {
        if (i === hoge) { result += Math.ceil(N / v[i]); }
        else { result++; }
    }
    console.log(result);
    
});

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

int main() {
  long A, B, C, D;
  cin >> A >> B >> C >> D;
  long E=C, F=D;
  long R=F%E;
  while(R!=0){
    F=E;
    E=R;
    R=F%E;
  }
  long S=C*D/E;
  cout << B-(A-1)-(B/C-(A-1)/C+B/D-(A-1)/D-(B/S-(A-1)/S)) << endl;  
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int r, d, x;
    cin >> r >> d >> x;
    for(int i=0; i<10; i++) {
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}


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

int main() {
	int n,m,i,j,k,ans,cur;
	string s,t,u;
	cin >> s >> t >> n >> m >> u;
	if(s==u){
		n--;
	}else{
		m--;
	}
	cout << n << ' ' << m;
	return 0;
}

Measured memory_bytes: 256