akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>

using namespace std;

int N;
int a[100001];
int rems;

int main() {
    scanf("%d", &N);
    int x;
    for(int i = 0; i<N; i++) {
        scanf("%d", &x);
        if(x > N) {
            rems++; continue;
        }
        a[x]++;
    }
    for(int i = 1; i<=N; i++) {
        if(a[i] < i) {
            rems += a[i];
        } else {
            rems += a[i] - i;
        }
    }
    printf("%d\n", rems);
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, m, c=0;
  cin >> n >> m;
  c = min(n, m / 2);
  m -= c * 2;
  c += m / 4;
  cout << c << endl;
}


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

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;


int dp[3005][3005];
string s, t;

void getLCS(int i, int j, string& res) {
    if (i == 0 || j == 0) return;
    if (s[i - 1] == t[j - 1]) {
        res = s[i - 1] + res;
        return getLCS(i - 1, j - 1, res);
    }

    if (dp[i - 1][j] >= dp[i][j - 1]) {
        getLCS(i - 1, j, res);
    } else {
        getLCS(i, j - 1, res);
    }
}

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

    cin >> s >> t;

    CLR(dp, 0);

    FOR(i, 1, s.size()) {
        FOR(j, 1, t.size()) {
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    string ans;
    getLCS(s.size(), t.size(), ans);
    cout << ans << endl;

    return 0;
}


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

    #define ll long long
    #define ff first
    #define ss second
    #define pb push_back
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define MOD 1000000007
    #define pll pair<ll,ll>
constexpr ll INF = 1999999999999999997; 
    #define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
    int main() {
        fastio;

        int a;
        cin>>a;
        cout<<a+pow(a,3)+pow(a,2)<<endl;
    }

Measured memory_bytes: 4216
N, M, X, Y = map(int, input().split())
x = list( map(int, input().split()))
y = list( map(int, input().split()))

max_x = max(x)
min_y = min(y)

if min_y <= max_x:
  print("War")
else:#max_xとmin_yの間の数が存在する。それがXとYの間という条件も満たせばOK
  if Y <= max_x:
    print("War")
  elif X >= min_y:
    print("War")
  else:
    print("No War")

Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    while(1){
        int a,b;
        cin >> a >> b;
        if(a+b == 0) break;
        short flg[20][20] = {{0}};
        int n,A,B;

        cin >> n;
        for(int i = 0; i < n; i++){
            cin >> A >> B;
            flg[A][B] = 1;
        }
        int dp[20][20] = {{0}};
        dp[0][1] = 1;
        for(int i = 1; i <= a; i++){
            for(int j = 1; j <= b; j++){
                dp[i][j] = dp[i][j-1] + dp[i-1][j];
                if(flg[i][j] == 1) dp[i][j] = 0;
            }
        }
        cout << dp[a][b] << endl;
    }
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<math.h>
#include<limits.h>
typedef long long int lli;
int main(void){
  lli n;
  lli min=LLONG_MAX;
  scanf("%lld",&n);
  for(int i=1;i<(int)sqrt(n)+1;i++){
    if(n%i==0){
      if(min>n/i+i-2){
        min=n/i+i-2;
      }
    }
  }
  printf("%lld\n",min);
  return 0;
}

Measured memory_bytes: 128
// Area belongs to Integer
#include <iostream>
#include <vector>
using namespace std;

int main() {
    vector<int> a;
    for(int i(0); i < 3; i += 1) {
        int tmp(0); cin >> tmp;
        a.push_back(tmp);
    }

    if(a.at(0) < a.at(1)) {
        cout << a[0] * a[2] + (a[1] - a[0]) * a[2] / 2 << endl; 
    } else if(a.at(0) > a.at(1)) {
        cout << a[1] * a[2] + (a[0] - a[1]) * a[2] / 2 << endl;
    } else {
        cout << a.at(0) * a.at(2) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import math
def ip():return int(input())
def imp():return map(int,input().split())
def impstr():return map(str,input().split())
def limp():return list(map(int,input().split()))
def limpstr():return list(map(str,input().split()))

l=limp()
for i in range(1,6):
    if l[i-1]==i:
        continue
    else:
        print(i)
        exit()

Measured memory_bytes: 61916
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
using namespace std;

int main(){

  double x1, y1, x2, y2, x3, y3;
  scanf("%lf,%lf", &x1, &y1);
  scanf("%lf,%lf", &x2, &y2);
  double sum = 0.0;
  while( scanf("%lf,%lf", &x3, &y3) != EOF ){
    double a = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
    double b = sqrt( (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) );
    double c = sqrt( (x3-x1)*(x3-x1) + (y3-y1)*(y3-y1) );
    double z = a + b + c;
    z /= 2;
    sum += sqrt( z * (z-a) * (z-b) * (z-c) );
    // cerr << sum << endl;
    x2 = x3;
    y2 = y3;
  }
  printf("%.10lf\n", sum);

  return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n,m,s,t1,t2;
  while(cin>>n>>m>>s>>t1>>t2,n) {
    s--;t1--;t2--;
    int g[n][n], dis[n][n];
    REP(i,n)REP(j,n){
      if (i==j) g[i][j] = 0;
      else
        g[i][j] = INF;
    }
    REP(i,m) {
      int a,b,c;
      cin >> a>>b>>c;
      a--;b--;
      g[a][b] = c;
    }
    memcpy(dis, g, sizeof(g));
    REP(k,n) REP(i,n) REP(j,n)
      if (dis[i][j] > dis[i][k]+dis[k][j])
        dis[i][j] = dis[i][k]+dis[k][j];
    int res = INF;
    // REP(i,n) REP(j,n) {
    //   printf("%d,%d %d\n",i,j,dis[i][j]);
    // }
    REP(i,n) {
      res = min(res, dis[s][i]+dis[i][t1]+dis[i][t2]);
    }
    cout << res <<endl;
  }
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair	
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld;	
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
	 
const ll MAX = 10000000;
const ll inf = 1e9;


int main() {
	fastio;
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
	}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] pos = new int[26];
        String in = sc.next();
        for (int i = 0; i < in.length(); i++) {
            pos[in.charAt(i) - 'a'] = i + 1;
        }
        if (in.length() < 26) {
            System.out.print(in);
            for (int i = 0; i < 26; i++) {
                if (pos[i] == 0) {
                    System.out.println((char) (i + 'a'));
                    return;
                }
            }
        }
        for (int i = 25; i >= 0; i--) {
            for (int j = in.charAt(i) - 'a' + 1; j < 26; j++) {
                if (pos[j] > i + 1) {
                    System.out.print(in.substring(0, i));
                    System.out.println((char) (j + 'a'));
                    return;
                }
            }
        }
        System.out.println(-1);
    }
}


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

using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
#define inf 1ll<<60
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
#define int llong
#define be(x) x.begin(), x.end()
typedef pair<int, int> P;

signed main(){
	int cnt[4] = {};
	int in;
	for(int i = 0; i < 6; i++){
		cin >> in;
		cnt[in-1]++;
	}

	sort(cnt, cnt+4);
	if(cnt[0] == 1 && cnt[1] == 1 && cnt[2] == 2 && cnt[3] == 2)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

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

string S[2002];
int dp[4][2002][2002];

int main()
{
    ios::sync_with_stdio(0);
    
    int H, W;
    cin >> H >> W;

    for(int i=0; i<H; i++)
        cin >> S[i];
    
    for(int i=0; i<H; i++)
        for(int j=0; j<W; j++)
        {
            if(S[i][j] == '#')
                continue;
            
            dp[0][i][j] = 1 + (i >= 1 ? dp[0][i-1][j] : 0);
            dp[1][i][j] = 1 + (j >= 1 ? dp[1][i][j-1] : 0);
        }
    
    for(int i=H-1; i>=0; i--)
        for(int j=W-1; j>=0; j--)
        {
            if(S[i][j] == '#')
                continue;
            
            dp[2][i][j] = 1 + dp[2][i+1][j];
            dp[3][i][j] = 1 + dp[3][i][j+1];
        }
    
    int ans = 0;

    for(int i=0; i<H; i++)
        for(int j=0; j<W; j++)
        {
            if(S[i][j] == '#')
                continue;
            
            ans = max(ans, dp[0][i][j] + dp[1][i][j] + dp[2][i][j] + dp[3][i][j] - 3);
        }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 67200
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>

#define M 1050011
#define L 14

char H[M][L];

long long h1(long long k){
  return k % M;
}

long long h2(long long k){
  return 1 + (k % (M - 1));
}

long long h(long long k, long long i){
  return (h1(k) + i * h2(k)) % M;
}

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

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int find(char str[]){
  long long key, i, id;

  key = getKey(str);
  i = 0;

  while(true){
    id = h(key, i);
    if(strcmp(H[id], str) == 0) return 1;
    else if(strlen(H[id]) == 0) return 0;
    i++;
  }
  return 0;
}

int insert(char str[]){
  long long key, i, id;

  key = getKey(str);
  i = 0;

  while(true){
    id = h(key, i);
    if(strcmp(H[id], str) == 0) return 1;
    else if(strlen(H[id]) == 0){
      strcpy(H[id], str);
      return 0;
    }
    i++;
  }
  return 0;
}

int main(){

  int n;
  char str[L], command[10];

  for (int i = 0; i < M; i++ ) H[i][0] = '\0';

  scanf("%d", &n);
  for(int i = 0;i < n;i++){
    scanf("%s %s", command, str);

    if(command[0] == 'i') insert(str);
    else{
      if(find(str)) printf("yes\n");
      else printf("no\n");
    }
  }


  return 0;
}



Measured memory_bytes: 17520
import java.util.ArrayList;
import java.util.Scanner;

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

        int n = scanner.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        int ans = 0;

        // Aの要素を取得する
        for (int i = 0; i < n; i++) {
            list.add(scanner.nextInt());
        }

        // 要素に奇数が含まれるまで処理を続ける
        int flg = 0;
        do {
            for (int i = 0; i < list.size(); i++) {
                int elem = list.get(i);
                if (elem % 2 != 0) {
                    flg = 1;
                } else {
                    list.set(i, elem / 2);
                }
            }

            if (flg == 0) {
                ans++;
            }
        } while (flg == 0);

        System.out.println(ans);

    }
}

Measured memory_bytes: 23124
#include <stdio.h>

int main() {
    int _500, _100, _50, x;
    int sum = 0;
    scanf("%d", &_500);
    scanf("%d", &_100);
    scanf("%d", &_50);
    scanf("%d", &x);
    
    while(1){
        if(x%50!=0){
            printf("unexpected number, please try again\n");
            scanf("%d", &x);
        }
        else break;
    }

    for(int i=0;i<_500+1;i++){
        for(int j=0;j<_100+1;j++){
            for(int k=0;k<_50+1;k++){
                if(i*500+j*100+k*50==x)sum+=1;
            }
        }
    }
    printf("%d\n", sum);
    
    
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

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

int main() {
    int n, q;
    int A[100000];
    int key;
    int sum = 0;
    scanf("%d", &n);

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

    printf("%d\n", sum);
    return 0;
}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (ll i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    ll N, X, T;
    cin >> N >> X >> T;
    if(N%X==0) cout << N/X*T << endl;
    else cout << ((N/X)+1)*T << endl;

    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;



int main(){
    int cnt = 0;
    ll MIN = 1e9 + 7;
    ll MAX = 0;
    int N;
    int T;
    cin >> N;
    cin >> T;
    ll A[N];
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        MIN = min(MIN, A[i]);
        if (A[i]-MIN==MAX){
            cnt++;
        }
        else if (A[i]-MIN>MAX){
            MAX = A[i] - MIN;
            cnt = 1;
        }
    }
    cout << cnt << endl;

}


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

int main(void){
    int i, j, N, H[30], ANS=0, see=0;
    scanf("%d", &N);
    for(i=0; i<N; i++){
        scanf("%d", H+i);
        if(H[i] >= see){
            see = H[i];
            ANS++;
        }
    }

    printf("%d\n", ANS);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int
main()
{
	int x, y;
	int k;

	int n, m, l;	
	long long int a[100][100] = {0};
	long long int b[100][100] = {0};
	long long int c[100][100] = {0};

	scanf("%d %d %d", &n, &m, &l);
	for (y = 0; y < n; y++)
	{
		for (x = 0; x < m; x++)
		{
			scanf("%lld", &a[y][x]);
		}
	}
	for (y = 0; y < m; y++)
	{
		for (x = 0; x < l; x++)
		{
			scanf("%lld", &b[y][x]);
		}
	}
	for (y = 0; y < n; y++)
	{
		for (x = 0; x < l; x++)
		{
			for (k = 0; k < m; k++)
			{
				c[y][x] += a[y][k] * b[k][x];
			}
		}
	}

	for (y = 0; y < n; y++)
	{
		for (x = 0; x < l; x++)
		{
			if (x != 0)
			{
				printf(" ");
			}
			printf("%lld", c[y][x]);
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	long long mod=(1e+9)+7;
	long long n,m;
	cin>>n>>m;
	static long long sum_x,sum_y;
	vector<long long> x(n+10),y(m+10);
	for(ll i=1;i<=n;i++) cin>>x[i];
	for(ll i=1;i<=m;i++) cin>>y[i];
	for(ll xx=1;xx<=n;xx++){
		sum_x+=(2*xx-n-1)*x[xx];
		sum_x%=mod;
	}
	for(ll yy=1;yy<=m;yy++){
		sum_y+=(2*yy-m-1)*y[yy];
		sum_y%=mod;
	}
	cout<<(sum_x*sum_y)%mod<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
    int x[n],mx=0,smax=0;
  	for(int i=0;i<n;i++){
      cin>>x[i]; 
      if(x[i]>mx) smax=mx;
      else if(x[i]>smax)smax=x[i];
      mx=max(x[i],mx);
      //cout<<mx<<" "<<smax<<endl;
    }
  	for(int i=0;i<n;i++){
    	if(x[i]==mx) cout<<smax;
      	else cout<<mx;
      	cout<<endl;
    }
}

Measured memory_bytes: 2432
n, a, b = map(int, input().split())
less = []
for i in range(a, n+1):
    num = 0
    digit = len(str(i))
    if digit > 1:
        string = str(i)
        for j in range(digit):
            num += int(string[j])
    else:
        num = i

    if a <= num <= b:
        less.append(i)

print(sum(less))

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

int main()
{
    cin >> N;
    if (N % 1000 == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << ((N / 1000) + 1) * 1000 - N << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7 ;
int main()
{
	ll n,k,ans=0;
	cin>>n>>k;
	for(ll i=k;i<=n+1;i++)
		ans=(ans+i*n-i*(i-1)+1)%mod;		
	cout<<ans<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,k;
    cin >> n >> k;
    if(k % 2 == 1){
        cout << (n/k)*(n/k)*(n/k) << endl;
    }else{
        ll ans = 0;
        ans += (n/k)*(n/k)*(n/k);
        ll kk = k/2;
        kk = n/kk - n/k;
        ans += kk*kk*kk;
        cout << ans << endl;
    }
}

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

const int mod=1000000007;
int f[300010][3][4][2],n,t[3],ans;
char s[300010];

void add(int &x,int y) {x=(x+y>=mod?x+y-mod:x+y);}

int main()
{
	scanf("%s",s+1),n=strlen(s+1);
	f[0][0][1][0]=1,t[0]=t[2]=1,t[1]=2;
	for (int i=1; i<=n; i++)
	{
		if (s[i]!='1')
		{
			for (int j=0; j<3; j++)
				for (int k=0; k<4; k++)
					for (int l=0; l<2; l++)
						add(f[i][t[j]][k][l],f[i-1][j][k][l]);
		}
		if (s[i]!='0')
		{
			for (int j=0; j<3; j++)
				for (int k=0; k<4; k++)
					for (int l=0; l<2; l++) if (f[i-1][j][k][l])
					{
						if (j==0) add(f[i][0][min(k+1,3)][0],f[i-1][j][k][l]); else
						if (j==1) add(f[i][0][k][l],f[i-1][j][k][l]); else
						{
							if (l==0) add(f[i][0][k-1][1],f[i-1][j][k][l]);
							else add(f[i][0][min(k+1,3)][0],f[i-1][j][k][l]);
						}
					}
		}
	}
	ans=0;
	for (int j=0; j<3; j++)
		for (int k=0; k<4; k++)
			for (int l=0; l<2; l++) if (f[n][j][k][l])
			{
				if (j==0) {if (k>0) add(ans,f[n][j][k][l]);} else
				if (j==1) {if (k>1) add(ans,f[n][j][k][l]);} else
				{
					if (l==0) {if (k>2) add(ans,f[n][j][k][l]);} 
					else {if (k>0) add(ans,f[n][j][k][l]);}
				}
			}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 28672
#include <iostream>

using namespace std;

int main (void)
{
    int a, b;
    string post;

    cin >> a >> b;
    cin >> post;

    a--;
    b--;
    
    for (int i = 0; i <= a; i++) {
        if (post[i] < '0' || post[i] > '9') {
            cout << "No" << endl;
            return 0;
        }
    }
    if (post[a + 1] != '-') {
        cout << "No" << endl;
        return 0;
    }
    for (int i = a + 2; i < post.length(); i++) {
        if (post[i] < '0' || post[i] > '9') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

// ====================================================================

int main() {
  int n, t;
  cin >> n >> t;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  ll ans = 0;
  // i番目の人が押してから、i+1番目の人が押すまでにお湯がでている時間を求める
  for (int i = 0; i < n - 1; i++) {
    if (v[i + 1] - v[i] >= t)
      ans += t;
    else
      ans += v[i + 1] - v[i];
  }
  ans += t;
  cout << ans << endl;
}


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

typedef long long ll;

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

    for (int i = 0; i <= K; ++i)
    {
        if (A < B * pow(2, i) && B * pow(2, i) < C * pow(2, K - i))
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3908
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <climits>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;

#define ten(n) (1e##n)
#define COUT cout <<
#define SPACE_COUT << " "  <<
#define COMMA_COUT << ", " <<
#define ENDL << endl;

int
main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, K;
    cin >> N >> K;
    vector<ll> a, c, s;
    a.resize(N);
    c.resize(N+1);
    s.resize(N+1);
    c[0] = s[0] = 0;
    
    ll tmp;
    for (int i = 0; i < N; ++i) {
      cin >> tmp;
      a[i] = tmp;
      c[i+1] = c[i] + max(0LL, tmp);
      s[i+1] = s[i] + tmp;
    }
    
    ll ans = 0;
    for (int i = 0; i < N - K + 1; ++i) {
      ll l = i;
      ll r = i + K;
      ll other = c[l] + c[N] - c[r];
      ans = max(other + max(0LL, s[r] - s[l]), ans);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    if(abs(a-c)<=d || (abs(b-a)<=d && abs(c-b)<=d)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3600
#include <stdio.h>

int main(void)
{
    int i, j, n, max, sum;
    int a[2][100], min;

    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%d", &a[0][i]);
    }
    for (i=0; i<n; i++) {
        scanf("%d", &a[1][i]);
    }

    max = 0;
    for (i=0; i<n; i++) {
        sum = 0;
        for (j=0; j<=i; j++)    sum += a[0][j];
        for (j=i; j<n; j++)     sum += a[1][j];
        if (max<sum)    max = sum;
    }

    printf("%d\n", max);

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (auto& e : p) {
        cin >> e;
    }

    int ans = 0;
    for (int i = 1; i < n-1; i++) {
        if ((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int len = s.length();
    int sum[26];
    memset(sum, 0, sizeof(sum));
    for(int i=0; i<len; i++){
        int tmp = s[i] - 97;
        sum[tmp]++;
        //cout << tmp << endl;
    }
    string ans = "Yes";
    for(int i=0; i<26; i++){
        if(sum[i]%2==1){
            ans ="No";
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    string s;
    string srev;
    int b,e;
    int count = 0;


    cin >> s;
    b = 0;
    e = s.size()-1;

    while(b<e){
        if(s[b]!=s[e]){
            if(s[b]=='x'){
                count++;
                b++;
            }
            else if(s[e]=='x'){
                count++;
                e--;
            }
            else{
                cout << -1 << endl;
                return 0;
            }
        }
        else{
            b++;
            e--;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define el "\n"
#define F first
#define S second
#define PI 3.14159265358979323846  /* pi */
#define FOR(i,a,b) for(int i = a; i < b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
#define all(v)  	((v).begin()),((v).end())
#define degreesToRadians(angleDegrees) (angleDegrees * PI / 180.0) // Converts degrees to radians.
#define radiansToDegrees(angleRadians) (angleRadians * 180.0 / PI) // Converts radians to degrees.
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
const double EPS = 1e-9;
const int N = 1e3+2, M = 3e5+5, OO = 0x3f3f3f3f;
// int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
// int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Direction
// int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; // Knight Direction
// int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; // Hexagonal Direction

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
  int s,w;
  cin>>s>>w;
  if(w>=s){
    cout<<"unsafe"<<endl;
  }
  else{
    cout<<"safe"<<endl;
  }
	return 0;

}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    int p1 = 0;
    int p = a / b;
    if (p != 0)
        p1 = log2(p) + 1;
    b = b * pow(2, p1);
    k -= p1;
    if (k < 0)
    {
        cout << "No" << endl;
        exit(0);
    }
    else
    {
        int p2 = 0;
        int q = b / c;
        if (q != 0)
            p2 = log2(q) + 1;
        if (k >= p2)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
        //cout << p1 << " " << p2 << endl;
    }
}

Measured memory_bytes: 3860
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#include <vector>
#include <limits.h>
#include <stack>
#include <queue>
#define maxn 1e9
#define pi acos(-1)
#define LL long long
using namespace std;
double aabs(double x)
{
	if(x<0)return -x;
	return x;
}
int gcd(int a,int b)
{
	if(a%b==0)return b;
	return gcd(b,a%b);
}
struct card{char suit,value;};
void bubble(struct card A[],int N)///冒泡排序；
{
	for(int i=0;i<N;i++)
		for(int j=N-1;j>=i+1;j--)
			if(A[j].value<A[j-1].value)
			{
				card t=A[j];
				A[j]=A[j-1];
				A[j-1]=t;
			}
}
void selection(struct card A[],int N)///选择排序；
{
	for(int i=0;i<N;i++)
	{
		int minj=i;
		for(int j=i;j<N;j++)
		{
			if(A[j].value<A[minj].value)minj=j;
		}
		card t=A[i];
		A[i]=A[minj];
		A[minj]=t;
	}
}
LL cnt;
int l;
int a[1000000];
int n;
vector<int>G;
void insertionSort(int A[],int n,int g)///指定了间隔g的插入排序
{
	for(int i=g;i<n;i++)
	{
		int v=A[i];
		int j=i-g;
		while (j>=0&&A[j]>v) {
			A[j+g]=A[j];
			j-=g;
			cnt++;
		}
		A[j+g]=v;
	}
}
void shellSort(int A[],int n)///希尔排序；
{
	for(int h=1;;)//生成数列G={1,4,13,40,121,364,1093,.....}
	{
		if(h>n)break;
		G.push_back(h);
		h=3*h+1;
	}
	for(int i=G.size()-1;i>=0;i--)///按逆序指定G[i]=g;
	{
		insertionSort(A, n, G[i]);
	}
}
bool isStable(struct card c1[],struct card c2[],int N)///判断稳定；
{
	for(int i=0;i<N;i++)
	{
		if(c1[i].suit!=c2[i].suit)return false;
	}
	return true;
}
int main()
{
	card c1[107],c2[107];
	int n;
	char ch;
	cin>>n;
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	cnt=0;
	shellSort(a, n);
	cout<<G.size()<<endl;
	for(int i=G.size()-1;i>=0;i--)
	{
		printf("%d",G[i]);
		if(i)printf(" ");
	}
	printf("\n");
	printf("%lld\n",cnt);
	for(int i=0;i<n;i++)printf("%d\n",a[i]);
	return 0;
}



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

		signed main()
		{
		
			int n;
			scanf("%d",&n);
			int a[n];
			map<int,int> mp1;
			int ans=0;
			for(int i=0;i<n;i++)
			{
				scanf("%d",&a[i]);
				mp1[a[i]]++;
			}
			/*if(mp1[1])
			{
				if(mp1[1]==1)
				{
					cout<<1;
					return 0;
				}
				else
				{
					cout<<0;
					return 0;
				}
			}*/
			for(int i=0;i<n;i++)
			{
				int f=0;
			
        				if(mp1[a[i]]>1)
        				{
        				    continue;
        				}
        				if(a[i]==1)
        				{
        				    ans++;
        				    continue;
        				}
				for(int j=1;j*j<=a[i];j++)
				{
					if(a[i]%j==0)
					{
						if(mp1[j])
						{
							f=1;
							break;
						}
						
						if(mp1[a[i]/j] && j>1)
						{
							f=1;
							break;
						}
					}
				}
				if(f==0)
				ans++;
			}
			printf("%d",ans);
		}

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

int main()
{
  int N, K, i;
  int init = 1;
  cin >> N;
  cin >> K;
  
  for(i=0; i<N; i++)
  {
    if(init*2 < init+K)
    {
      init *= 2;
    }
    else
    {
      init += K;
    }
  }
  cout << init << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll A[200009], B[200009];
int P[200009], R[200009];
int N;

void pri(ll nums[200009]){
    rep1(i,N){
        if(i>1) cout<<" ";
        cout<<nums[i];
    }
    cout<<endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    
    rep1(i,N) cin>>P[i];
    rep1(i,N) R[P[i]]=i;
    rep1(i,N) A[i]=30000*i;
    rep1(i,N) B[i]=30000*(N-i)+R[i];
    
    pri(A);
    pri(B);
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    while (true){
        C -= B;
        if (C <= 0 ){ cout << "Yes" << endl; return 0;}
        A -= D;
        if(A<=0){ cout << "No" << endl; return 0;}
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <utility>

using namespace std;

int main(){
  int X,Y;
  cin >> X >> Y;
  int sum = 0;
  if(X<=3){
    sum += (4-X)*100000;
  }
  if(Y<=3){
    sum += (4-Y)*100000;
  }
  if(sum == 600000){
    sum += 400000;
  }
  cout << sum << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main()
{
	int n, k;

	cin >> n >> k;

	vector<int> vec(n+1);
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		vec[a]++;
	}

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

	int ret = n;
	for (int i = 0; i < k; i++) {
		ret -= vec[i];
	}
	   
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  
  cin >> a;
  cin >> b;
  
  int p = a * b;
  
  if ((p / 2 * 2) == p) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3680
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		StringTokenizer stk;
		int[] go=new int[5];
		String aa="";

		try {
			str=bfr.readLine();
			str=str.toUpperCase();
			System.out.println(str);
		}catch(IOException e) {

		}
	}
}



Measured memory_bytes: 23912
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 998244353;
ll dp[3010][3010];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	dp[a][b] = 1;
	for (ll i = a; i <= c; i++) {
		for (ll j = b; j <= d; j++) {
			if (i == a && j == b) continue;
			dp[i][j] += dp[i][j - 1] * i;
			dp[i][j] += dp[i - 1][j] * j;
			if (i > a && j > b) dp[i][j] -= dp[i - 1][j - 1] * (i - 1) * (j - 1);
			dp[i][j] %= mod;
			if (dp[i][j] < 0) dp[i][j] += mod;
		}
	}
	cout << dp[c][d] << '\n';
}

Measured memory_bytes: 74184
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String [] inp = buffer.readLine().split(" ");
        int d = Integer.parseInt(inp[0]), t = Integer.parseInt(inp[1]), s = Integer.parseInt(inp[2]);
        if(s*t>=d){
            System.out.println("Yes");
        }
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 32616
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
        Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int a = sc.nextInt();
			if (a != 0){
				int count = 0;
				while(a != 1){
					count++;
					if(a%2 == 0){
						a = a / 2;
					}else{
						a = a * 3 + 1;
					}
					//System.out.println(count + "回目：" + a);
				}
				System.out.println(count);
			}
		}
	}
}

Measured memory_bytes: 15360
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,i,h[25],hmax,ans=1;
  cin >> n;
  for (i=0;i<n;i++) cin >> h[i];
  hmax=h[0];
  for (i=1;i<n;i++){
    if (h[i]>=hmax) ans++;
    if (hmax<h[i]) hmax=h[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int  main(){
        long long  n, w; cin>>n>>w;
        long long wt[10000],val[10000];
        for(int i=0;i<n;i++)cin>>wt[i]>>val[i];
        long long  dp[n+1][w+1];
        memset(dp, 0, sizeof(dp));
        for(int i=1; i<n+1; i++){
        	for(int j=1; j<w+1; j++){
        		if(j>=wt[i-1])dp[i][j]=max(dp[i-1][j], val[i-1]+dp[i-1][j-wt[i-1]]);
        		else dp[i][j]=dp[i-1][j];
        	}
        }
        cout<<dp[n][w]<<endl;
 
     
}

Measured memory_bytes: 82556
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    int N, t, c = 1, m = 0;
    cin >> N;
    rep(i, N) {
        cin >> t;
        if(t)
            c++;
        else {
            m = max(m, c);
            c = 1;
        }
    }
    m = max(m, c);
    cout << m << endl;
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int64_t K;
  cin >> K;
  int64_t res = 0;
  for (int64_t i = 1; i < K + 1; i++) {
    for (int64_t j = 1; j < K + 1; j++) {
      for (int64_t k = 1; k < K + 1; k++) {
        res += gcd(i, gcd(j, k));
      }
    }
  }
  cout << res << '\n';
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  
  int n = s.size(), ans = 0;
  if (n%2 == 0){
    for (int i=0 ; i<n/2 ; i++){
      if (s.at(i) != s.at(n-1-i))
        ans++;
    }
  }
  else{
    for (int i=0 ; i<(n-1)/2 ; i++){
      if (s.at(i) != s.at(n-1-i))
        ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN=2e5;
ll a[MAXN+5],b[MAXN+5],f[MAXN+5];
ll n,k,tot,ans;
bool cmp(ll a,ll b)
{
	return a>b;
}
bool Check(ll x)
{
	for(int i=1;i<=n;i++)
		b[i]=x/f[i];//使a[i]小于等于x达到的上界
	ll res=0;//假设x是最大的a[i]*f[i]那么(b[i]=x/f[i])>=a[i]
	for(int i=1;i<=n;i++)
		res+=max(0ll,a[i]-b[i]);//a[i]-b[i]<0 b[i]>a[i]所以x大 
	return res<=k;
}
ll BS()
{
	ll l=0,r=(ll)1e12;
	while(l+1<=r)
	{
		ll mid=(l+r)>>1;
		if(Check(mid))//res<=k r(最大的a[i]*b[i])还可以继续小
			r=mid;
		else
			l=mid+1;//res>k x还需要变大
	}
	return r;
}
int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		tot+=a[i];
	}
	for(int i=1;i<=n;i++)
		scanf("%lld",&f[i]);
	if(tot<=k)//个人值可被减完
	{
		printf("0\n");
		return 0;
	}
	sort(a+1,a+n+1);//a[i]从小到大
	sort(f+1,f+n+1,cmp);//f[i]从大到小
	printf("%lld\n",BS());
	return 0;
} 

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;

    if (a+b == 15)
    {
        putchar('+');
    } else if (a*b == 15) {
        putchar('*');
    } else {
        putchar('x');
    }

    putchar('\n');
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<bitset>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();++itr)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
#define fac_init(n){fac[0]=fac[1]=inv[1]=fi[0]=fi[1]=1;fz(i,2,n){fac[i]=1ll*fac[i-1]*i%mod;inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;fi[i]=1ll*fi[i-1]*inv[i]%mod;}}
using namespace std;
inline void read(int &x)
{
	char c;int f=1;
	while(!isdigit(c=getchar()))if(c=='-')f=-1;
	x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
	x*=f;
}
const int mod=1e9+7;
int n,i,j,k,a[405],b[405],visa[405],visb[405],fac[405],inv[405],fi[405],ans,num[405][405],vis[405][405],dp[405][405],f[405][405][405],g[405];
int c(int x,int y)
{
	if(x<y) return 0;
	return 1ll*fac[x]*fi[y]%mod*fi[x-y]%mod;
}
int calc()
{
	int i,j;
	dp[1][2]=1;
	fz1(i,n/3-1){
		fz0g(j,i*2){
			fz0g(k,j){
				inc(dp[i+1][j+2-k],1ll*dp[i][j]*c(j,k)%mod*fac[k]%mod)
			} 
		}
	}
	int ans=0;
	fz0g(i,n/3*2){
		inc(ans,1ll*dp[n/3][i]*fac[i]%mod)
	}
	return ans;
}
int main()
{
	fac_init(400)
	read(n);
	fz1(i,n){
		read(a[i]);
	}
	fz1(i,n){
		read(b[i]);
	}
	fz1(i,n){
		visa[a[i]]=1;
		num[i][0]=i;
		memset(visb,0,sizeof(visb));
		fz1(j,n){
			visb[b[j]]=1;
			num[i][j]=num[i][j-1]+(!visa[b[j]]);
			if(!visa[b[j]]&&!visb[a[i]]){
				vis[i][j]=1;
			}
		}
	}
	fd1(k,n/3){
		memset(g,0,sizeof(g));
		fd1(i,n){
			int s=(k==n/3);
			fd1(j,n){
				if(vis[i][j]){
					f[k][i][j]=1ll*s*(k*3-num[i][j])%mod;
				}
				inc(s,g[j])
				inc(g[j],f[k+1][i][j])
			}
		}
	}
	int s=0;
	fz1(i,n)fz1(j,n){
		inc(s,f[1][i][j])
	}
	cout<<1ll*s*calc()%mod<<endl;
	return 0;
}

Measured memory_bytes: 88960
#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main(){
  ll n,a,b,c,d,e,f,g;
  cin>>n>>a>>b>>c>>d>>e;
  f=min(min(min(min(a,b),c),d),e);
  g=n/f;
  if(n%f>0) g++;
  cout<<g+4<<endl;
}

Measured memory_bytes: 3552
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c,a1,b1,c1,num=0;
	scanf("%d%d%d",&a,&b,&c);
	if(a%2!=0||b%2!=0||c%2!=0)
	{
		printf("0\n");
		return 0;
	}
	if(a==b&&b==c)
	{
		printf("-1\n");
		return 0;
	}
	while(1)
	{
		a1=b/2+c/2;
		b1=a/2+c/2;
		c1=a/2+b/2;
		a=a1;
		b=b1;
		c=c1;
		num++;
		if(a%2!=0||b%2!=0||c%2!=0)
		{
			printf("%d\n",num);
			return 0;
		}
	}
	return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M;
ll all[3][1005];
ll sum[8][1005];

int Get(int i, int j){
  int num = j;

  for (int k = 0; k < 3; k++){
    if (num % 2 == 0) sum[j][i] += all[k][i];
    else sum[j][i] -= all[k][i];
    num /= 2;
  }

  return 0;
}

int main(){
  cin >> N >> M;
  for (int i = 0; i < N; i++){
    ll X, Y, Z; cin >> X >> Y >> Z;
    all[0][i] = X; all[1][i] = Y; all[2][i] = Z;

    for (int j = 0; j < 8; j++) Get(i, j);
  }


  ll ans = 0;
  for (int k = 0; k < 8; k++){
    sort(sum[k], sum[k] + N, greater<ll>());
    ll now = 0;
    for (int j = 0; j < M; j++) now += sum[k][j];
    ans = max(ans, now);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int, int>
#define endl "\n"
using namespace std;
const int N = 3001;
int dp[N][N];
string s, t;
int LCS( int i, int j){

	if(i == s.size() or j == t.size() ) return 0;
	if(dp[i][j] != -1) return dp[i][j];

	if(s[i] == t[j]) return dp[i][j] = 1 + LCS( i + 1, j + 1);

	int one = LCS( i + 1, j);
	int two = LCS( i, j + 1);

	return dp[i][j] = max(one, two);
}

int main(){

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

	// int t; cin >> t; while(t--)
	{

		cin >> s >> t;
		memset(dp, -1, sizeof( dp ) );
		int ans = LCS( 0, 0);
		int i,j;
		i = j = 0;

		while(i < s.size() and j < t.size() ) {

			while(j < t.size() and i < s.size() ) {

				if(s[i] == t[j]) {
					cout << s[i];
					i++;
					j++;
				}
				else{
					if(dp[i + 1][j] > dp[i][j + 1]) i++;
					else j++;
				}
			}
		}


	}

	return 0;
}


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

int main()
{
	int n, k, sum = 0, x, s;
		cin >> n >> k;
	for ( n ; n > 0 ; n--)
	{
		cin >> x;
		
		s = k - x;
		s = s*s;
		s = sqrt (s);
		
			if ( s > x)
				sum += 2*x;
			else
				sum += 2*s;
		
	}
	cout << sum;
}


Measured memory_bytes: 256
import collections

n = int(input())
l = [input() for _ in [0] * n]

counted = collections.Counter(l)
#print(counted)

# 最頻値を求める
m = max(counted.values())
#print(m)

# 頻出数の文字を集める
chars = [key for key, value in counted.items()
             if value == m]

#chars = []
#for key, value in counted.items():
#    if value == m:
#        chars.append(key)

print(*sorted(chars),sep='\n')


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

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

	vector<int> seisuu(N);
	for (int i = 0; i < N; i++) {
		cin >> seisuu.at(i);
	}

	int counter = 0;
	bool thru = true;
	while (thru) {
		for (int i = 0; i < N; i++) {
			if (seisuu.at(i) % 2 == 0) {
				seisuu.at(i) /= 2;
			} else {
				thru = false;
				break;
			}
		}
      	if (thru == false) break;
		counter++;
	}

	cout << counter << endl;
}

Measured memory_bytes: 764