akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int h,n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    int max_a = 0;
    rep(i,n) {
        cin >> a[i] >> b[i];
        chmax(max_a,a[i]);
    }
    int INF = INT32_MAX>>2;
    vector<int> dp(h+max_a,INF);
    dp[0] = 0;
    rep(i,h) rep(j,n) {
            chmin(dp[i+a[j]], dp[i]+b[j]);
    }
    int ans = INF>>2;
    rep(i,max_a) {
        chmin(ans, dp[h+i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
long long n;
int main()
{
	cin>>n;
	long long min=1000000000001;
	for(long long i=1;i*i<=n;i++)
	{
		if(n%i!=0)
		{
			continue;
		}
		if((i+n/i-2)<min)
		{
			min=i+n/i-2;
		}
	}
	cout<<min;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll low,ll high,ll d){
  ll ans=0;
  while(low<=high){
    ll mid=(low+high)/2;
    ll val=(mid*(mid+1))/2;
    if(val<d){ ans=mid; low=mid+1; }
    else if(val==d) { ans=mid; break;}
    else {high=mid-1;}
  }
  return ans;
 }
int main(){
  long long a; cin>>a;
  if(a==1){ cout<<0<<endl; return 0;}
  long long ans=0;
  ll tmp=a;
  for(long long i=2;i*i<a;i++){
     if(tmp%i==0){ 
       int cnt=0;
       while(tmp%i==0) tmp/=i, cnt++; 
       //cout<<i<<" "<<cnt<<endl;
        ans+=f(1,cnt,cnt);
     }
  }
  if(tmp!=1) ans++;
  cout<<max(1ll,ans)<<endl;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair


int main() {
    ll n,k;
    cin>>n>>k;
    string str;
    cin>>str;
    ll i,j,ans=0;
    for(i=1;i<str.length();i++){
        if(str[i]==str[i-1])ans++;
    }
    cout<<min(n-1,ans+2*k);
    return 0;  
}

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

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

const int MAX = 2*1000*100 + 10 ;
const ll INF = 1e18 ;
const int MOD = 998244353 ;

vector<ll>jumps ;
ll ar[MAX], dp[MAX], n, k ;

ll BIT[MAX] ;

void update( ll pos, ll val ){
    while( pos>0 and pos < MAX ){
        BIT[pos] += val ;
        if(BIT[pos] >= MOD)
            BIT[pos] %= MOD ;
        pos += (pos&-pos) ;
    }
}

ll get( ll pos ){
    ll ans=0 ;
    while( pos>0 ){
        ans += BIT[pos] ;
        if( ans >= MOD )
            ans %= MOD ;
        pos -= (pos&-pos) ;
    }
    return ans ;
}

void sol( ){
    cin >> n >> k ;
    vector< pair<ll,ll>> v(k) ;
    for( auto &i : v )cin >> i.F >> i.S ;
    update( 1, 1 ) ;
    for( ll i=2; i<=n; i++ ){
        ll tmp = 0 ;
        for( auto k : v ){
            ll r = i-k.F, l = i-k.S ;
            ll ans = (get( r ) - get( l-1 ) + MOD )%MOD ;
            tmp += ans ;
            if( tmp >= MOD )
                tmp %= MOD ;
        }
        update( i, tmp ) ;
    }
    cout << (get(n)-get(n-1) + MOD )%MOD << nl ;
}

signed main( ){
  timesaver ;
//  int t = 1 ; cin >> t ; while(t--)
  {
      sol( );
  }
}

Measured memory_bytes: 5160
n,k=map(int,input().split())
P=list(map(int,input().split()))
R=[0]*(n-k+1)
R[0]=sum(P[:k])
for i in range(n-k):
    R[i+1]=R[i]-P[i]+P[i+k]
print((max(R)+k)/2)


Measured memory_bytes: 25060
import java.util.Scanner;
public class Main{
    public static void main(String[] arags){
        Scanner scan = new Scanner(System.in);
        while(true){
            int m = scan.nextInt();
            int f = scan.nextInt();
            int r = scan.nextInt();
            int check = m+f;
 
            if(m==-1&&f==-1&&r==-1){
                break;
            }
 
            if(m==-1||f==-1){
                System.out.println("F");
            }else if(check>=80){
                System.out.println("A");
            }else if(check>=65&&check<80){
                System.out.println("B");
            }else if(check>=50&&check<65){
                System.out.println("C");
            }else if(check>=30&&check<50){
                if(r>=50){
                    System.out.println("C");
                }else{
                    System.out.println("D");
                }
            }else if(check<30){
                System.out.println("F");
            }
        }
        scan.close(); 
    }
}


Measured memory_bytes: 26008
import numpy as np
from numba import njit
from numba.types import Array, int64
i4 = np.int32
i8 = np.int64


@njit((Array(int64, 1, 'C'), Array(int64, 1, 'C'), int64, int64), cache=True)
def solve(a, b, H, W):
    ret = np.empty(H, i8)
    for i in range(H):
        ret[i] = -1
    dp0 = np.arange(W)
    dp = np.arange(W)
    arg0 = W - 1
    arg = 0
    for i in range(H):
        r1 = np.searchsorted(dp, a[i])
        r2 = np.searchsorted(dp, b[i])
        if b[i] == W:
            if r1 == 0:
                return ret
            else:
                dp0 = dp0[: r1]
                dp = dp[: r1]
        else:
            dp[r1:r2] = b[i]

        if arg0 > -1:
            if r1 <= arg0 < r2:
                for j in range(r1 - 1, -1, -1):
                    if dp[j] == dp0[j]:
                        arg0 = j
                        ret[i] = i + 1
                        break
                else:
                    arg0 = -1
                    arg = np.argmin(dp - dp0)
                    ret[i] = dp[arg] - dp0[arg] + i + 1
            else:
                ret[i] = i + 1
        else:
            if r1 <= arg < r2:
                arg = np.argmin(dp - dp0)
            ret[i] = dp[arg] - dp0[arg] + i + 1

        if i % 1000 == 999:
            m = 0
            prev = dp[0]
            for k in range(1, dp.shape[0]):
                if dp[k] > prev:
                    dp0[m] = dp0[k - 1]
                    dp[m] = prev
                    m += 1
                    prev = dp[k]
            else:
                dp0[m] = dp0[dp0.shape[0] - 1]
                dp[m] = prev
                m += 1
            dp0 = dp0[: m]
            dp = dp[: m]
            if arg0 > -1:
                for j in range(m - 1, -1, -1):
                    if dp[j] == dp0[j]:
                        arg0 = j
                        break
            else:
                arg = np.argmin(dp - dp0)
    return ret


def main(in_file):
    stdin = open(in_file)
    H, W = [int(x) for x in stdin.readline().split()]
    ab = np.fromstring(stdin.read(), i8, sep=' ').reshape((-1, 2)).T
    ans = solve(ab[0] - 1, ab[1].copy(), H, W)
    p = '\n'.join([str(x) for x in ans.tolist()])
    print(p)


if __name__ == '__main__':
    main('/dev/stdin')

Measured memory_bytes: 136864
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll H,W; cin>>H>>W;
    if(H==1 or W==1){
        cout<< 1 <<"\n"; return;
    }
    if(H%2==0 or W%2==0){
        cout<< H*W/2 <<"\n"; return;
    }
    cout<< (H-1)*W/2 + (W+1)/2 <<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  int N;
  cin >> N;
  vector<pii> R(N);
  for (int i = 0; i < N; i++) {
    cin >> R[i].first >> R[i].second;
  }
  sort(R.begin(), R.end());
  vector<int> dp(N + 1, 0);
  stack<int> right_st;
  dp[N - 1] = 2;
  dp[N] = 1;
  ll mod = 998244353;
  ll right_most = R[N - 1].first;
  right_st.push(N - 1);
  for (int i = N - 2; i >= 0; i--) {
    ll go = R[i].first + R[i].second;
    while (!right_st.empty() && R[right_st.top()].first < go) {
      right_st.pop();
    }
    int right = N;
    if (!right_st.empty()) {
      right = right_st.top();
    }
    right_st.push(i);
    ll n_sets = (ll)dp[right] + dp[i + 1];
    n_sets %= mod;
    dp[i] = n_sets;
  }
  cout << dp[0] << endl;
  return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<vector>

using namespace std;

#define long long long
#define ft(i, a, b) for (int i = (long)a ; i <= (long)b ; i++)
#define fd(i, a, b) for (int i = (long)a ; i >= (long)b ; i--)

const int MAXN = 1e2 + 5;
const int MAXM = 1e5 + 5;
const long oo = 1e15;

long ans , n , m;
long dp[MAXN][MAXM] , w[MAXN] , v[MAXN];

void Solve() {
    ft(i , 1 , n) {
        ft(j , 1 , m) {
            dp[i][j] = max(dp[i][j] , dp[i - 1][j]);
            if (j >= w[i]) dp[i][j] = max(dp[i][j] , dp[i - 1][j - w[i]] + v[i]);
            ans = max(ans , dp[i][j]);
        }
    }
    cout << ans;
}

void FastInput() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
}

void Input() {
    cin >> n >> m;
    ft(i , 1 , n) cin >> w[i] >> v[i];
}

int main() {
    FastInput();
    Input();
    Solve();
}

Measured memory_bytes: 79360
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        boolean[][] g = new boolean[h][w];
        for (int i = 0; i < h; i++) {
            char[] a = sc.next().toCharArray();
            for (int j = 0; j < w; j++) {
                if(a[j] == '.') g[i][j] = true;
            }
        }
        ArrayDeque<int[]> q = new ArrayDeque<>();
        q.add(new int[]{0, 0});
        int[][] cost = new int[h][w];
        for (int i = 0; i < h; i++) {
            Arrays.fill(cost[i], 10000);
        }
        cost[0][0] = g[0][0] ? 0 : 1;
        boolean[][] used = new boolean[h][w];
        while(!q.isEmpty()){
            int r = q.peek()[0];
            int c = q.poll()[1];
            if(r < h-1){
                int nco = cost[r][c];
                if(g[r][c] && !g[r+1][c]){
                    nco++;
                }
                if(nco < cost[r+1][c]) cost[r+1][c] = nco;
                if(!used[r+1][c]){
                    q.add(new int[]{r+1, c});
                    used[r+1][c] = true;
                }
            }
            if(c < w-1){
                int nco = cost[r][c];
                if(g[r][c] && !g[r][c+1]){
                    nco++;
                }
                if(nco < cost[r][c+1]) cost[r][c+1] = nco;
                if(used[r][c+1])continue;
                q.add(new int[]{r, c+1});
                used[r][c+1] = true;
            }
        }
        System.out.println(cost[h-1][w-1]);
        sc.close();

    }

}


Measured memory_bytes: 23300
#include<cstdio>
#include<cstring>

bool valid(int y, int x) {
    return (0 <= x && x<8) && (0 <= y && y<8);
}

void markdir(char map[8][8], int r, int c, int dy, int dx) {
    if(valid(r+dy, c+dx)) {
        map[r+dy][c+dx] = 'x';
        markdir(map, r+dy, c+dx, dy, dx);
    }
}

void mark(char map[8][8], int r, int c) {
    markdir(map, r, c, 1, 1);
    markdir(map, r, c, 1, 0);
    markdir(map, r, c, 1, -1);
    markdir(map, r, c, 0, 1);
    markdir(map, r, c, 0, -1);
    markdir(map, r, c, -1, 1);
    markdir(map, r, c, -1, 0);
    markdir(map, r, c, -1, -1);
}


void copy(char dst[8][8], const char src[8][8]) {
    memcpy(dst, src, 64);
}

bool dfs(const char map[8][8], int k) {
    if(k==8) {
        for(int i=0; i<8; i++) {
            for(int j=0; j<8; j++)
                printf("%c", map[i][j] == 'x' ? '.' : map[i][j]);
            puts("");
        }
        return true;
    }

    char mymap[8][8];
    for(int i=0; i<8; i++)
        for(int j=0; j<8; j++)
            if(map[i][j] == '.') {
                copy(mymap, map);
                mymap[i][j] = 'Q';
                mark(mymap, i, j);
                if(dfs(mymap, k+1)) return true;
            }
    return false;
}
int main(void) {
    char map[8][8];
    memset(map, '.', sizeof(map));

    int k;
    scanf("%d",&k);
    for(int i=0; i<k; i++) {
        int r,c;
        scanf("%d%d",&r,&c);
        map[r][c] = 'Q';
        mark(map,r,c);
    }
    dfs(map,k);
    return 0;
}

Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  vll a(n);
  string s;
  cin>>s;
  int e=0;
  int w=0;
  rep(i,n){
    if(s[i]=='W') w++;
    if(s[i]=='E') e++;
  }
  if(s[0]=='W'){
    w--;
    a[0]=e;
    w++;
  }
  else{
    e--;
    a[0]=e;
    e++;
  }
  int wr=w;
  int wl=0;
  int er=e;
  int el=0;
  for(int i=1;i<n;i++){
    if(s[i-1]=='W'){
      if(s[i]=='W'){
        wl++;
        wr--;
        a[i]=wl+er;
      }
      else{
        wl++;
        wr--;
        er--;
        a[i]=er+wl;
        er++;
      }
    }
    else{
      if(s[i]=='W'){
        el++;
        er--;
        a[i]=wl+er;
      }
      else{
        el++;
        er--;
        er--;
        a[i]=er+wl;
        er++;
      }
    }
  }
  ll ans=INF;
  for(int i=0;i<n;i++){
    ans=min(ans,a[i]);
  }
  COUT(ans);
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

class Data{
public:
	int x,y;
	bool operator<(const Data& rhs)const{
		return x==rhs.x ? y<rhs.y : x<rhs.x;
	}
};

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

	int N=in();
	vector<int> x(N),y(N);
	REP(i,N){
		x[i]=in(),y[i]=in();
	}
	map<Data,int> flag;

	int max_cost = 0;
	for(int n=0;n<N;n++){
		for(int k=0;k<N;k++){
			if(n==k) continue;
			Data d;
			d.x = (x[k]-x[n]), d.y = (y[k]-y[n]);
			auto res = flag.insert(make_pair(d,1));
			if(!res.second) flag[d]++;
		}
	}
	for(auto& x:flag){
		max_cost = max(max_cost,x.second);
	}
	cout << N-max_cost << endl;
	return 0;
}


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

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(in.readLine());
        int n = Integer.parseInt(st.nextToken()) + 1;
        int m = Integer.parseInt(st.nextToken());
        String string = in.readLine();
        boolean[] bad = new boolean[n];
        for (int i = 0; i < n; i++) {
            if (string.charAt(i) == '1') {
                bad[i] = true;
            }
        }
        int[] par = new int[n];
        Arrays.fill(par, (int)1e9);
        par[0] = 0;
        Queue<Integer> pq = new LinkedList<>();
        pq.offer(0);
        for (int i = 1; i < n; i++) {
            if (bad[i]) {
                continue;
            }
            if (!pq.isEmpty()) {
                while (!pq.isEmpty() && i - pq.peek() > m) {
                    pq.poll();
                }
                if (!pq.isEmpty()) {
                    par[i] = pq.peek();
                    pq.offer(i);
                }
            }
        }
        if (par[n-1] == (int)1e9) {
            System.out.println("-1");
            return;
        }
        Stack<Integer> stack = new Stack<>();
        for (int i = n-1; i != 0; i = par[i]) {
            stack.push(i-par[i]);
        }
        int res = stack.size();
        for (int i = 0; i < res; i++) {
            if (i > 0) {
                System.out.print(' ');
            }
            System.out.print(stack.pop());
        }
        System.out.print('\n');
    }


}
/*


 */

Measured memory_bytes: 47668
# -*- coding: utf-8 -*-

# 青い点を探して処理する関数
def search_bluedot(end_x, end_y):
	# 更新する値をグローバル宣言
	global ans
	global field
	# Y軸向きには値の大きい方から優先して取るために、逆順でループ回す
	for y in range(end_y-1, -1, -1):
		for x in range(end_x):
			# 赤い点を見つけたら、答えを+1して赤い点を消す
			if field[y][x] == 1:
				ans += 1
				field[y][x] = 0
				return

dot_count = int(input())
# 点を置くフィールドを作成
field = [[0 for i in range(dot_count*2)] for j in range(dot_count*2)]
# 赤い点の配置
for i in range(dot_count):
	x, y = map(int, input().split())
	field[y][x] = 1
# 青い点の配置
for i in range(dot_count):
	x, y = map(int, input().split())
	field[y][x] = 2

ans = 0
for x in range(dot_count*2):
	# X軸向きに最も値の小さいものから取るために、Y軸ループを内側にする
	for y in range(dot_count*2):
		# 青い点を見つけたら、そこより内側で赤い点を探す
		if field[y][x] == 2:
			search_bluedot(x, y)

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n,m;
    cin >> n >> m;
    if(n < m){
        rep(i,m) cout << n;
        cout << endl;
    }else if(n >= m){
        rep(i,n) cout << m;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100005
#define task "t"
#define mu(x) x*x

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using piii=pair<int,pii>;
const int inf=1e9+7;

string s,t;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();cout.tie();
    #ifndef ONLINE_JUDGE
  //  freopen(task".inp","r",stdin);
 //   freopen(task".out","w",stdout);
    #endif // ONLINE_JUDGE
    cin>>s>>t;
    int res=0;
    for (int i=0;i<3;i++) if (s[i]==t[i]) res++;
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
<?php

    // AtCoder Beginner Contest 161
    // C - Replacing Integer

    list($n, $k) = in_ints();

    $n = $n % $k;
    while(true) {
        $wk = abs($n - $k);
        if ($n <= $wk) {
            break;
        }
        $n = $wk;
    }
    out($n);


    /**
    * お手伝い関数さんたち
    */
    function in() {
        return trim(fgets(STDIN));
    }
    function in_int() {
        return (int)in();
    }
    function in_vals() {
        return explode(' ', in());
    }
    function in_ints() {
        return array_map('intval', in_vals());
    }
    function out($s) {
        echo $s . PHP_EOL;
    }
    function yes() {
        out('Yes');
    }
    function no() {
        out('No');
    }



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

using namespace std;

int main(){

    int n, m;

    cin >> n >> m;

    int c[m];
    int dp[50001];

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

    dp[0] = 0;

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

    for(int i = 0; i < m; ++i){
        for(int j = c[i]; j <= n; j++){
            dp[j] = min(dp[j], dp[j - c[i]] + 1);
        }
    }

    cout << dp[n] << endl;

}

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

int main(){
  
  int N = 3;
  string s;
  int count = 0;
  cin >> s;
  
  for(int i=0; i<N; i++){
    if(s[i] == '1'){
      count++;
    }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
template <class T> void corner(bool flg, T hoge) {
    if(flg) {
        cout << hoge << endl;
        exit(0);
    }
}
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n;
    inputv(A,n);
    x=INF;
    rep(i,n){
        if(x>A[i]){
            x=A[i];
            ans++;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 2420
var
	i:Longint;
	s:String;
begin
	readln(s);
	for i:=2 to length(s)do begin
		if s[i]=s[i-1]then begin
			writeln(i-1,' ',i);
			exit;
		end;
		if s[i]=s[i-2]then begin
			writeln(i-2,' ',i);
			exit;
		end;
	end;
	writeln('-1 -1');
end.


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

int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

int main() {
	int		b,c,i,j,k,n,m,x,y,ans = 0;
	string	str;
	
	cin >> k;


	cout << a[k-1] << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>


double absolute(double x) {
  return (x < 0) ? (x * -1) : x;
}

double chebyshev_distance(double *x, double *y, int size) {
  double dis = -1, temp;
  for (int i = 0; i < size; i ++) {
    temp = absolute(x[i] - y[i]);
    if (temp > dis) dis = temp;
  }
  return dis;
}

double distance(double *x, double *y, int size, int p) {
  double summation = 0;
  for (int i = 0; i < size; i ++) {
    summation += pow(absolute(x[i] - y[i]), p);
    // std::cout << " " << summation << " " << x[i] << " " << y[i] << std::endl;
  }
  return pow(summation, 1 / (double)p);
}


int main() {
  double x[1000], y[1000];
  int n;
  std::cin >> n;

  for (int i = 0; i < n; i ++) {
    std::cin >> x[i];
  }
  for (int i = 0; i < n; i ++) {
    std::cin >> y[i];
  }
  
  for (int i = 1; i <= 3; i ++) {
    std::cout << std::fixed << std::setprecision(8)
      << distance(x, y, n, i) << std::endl;
  }
  std::cout << chebyshev_distance(x, y, n) << std::endl;

  return 0;
}



Measured memory_bytes: 3456
use num::integer::gcd;
use proconio::*;
use std::collections::HashMap;

fn main() {
    #![allow(non_snake_case)]
    let MOD: i64 = 1_000_000_007;
    input! {
        n: usize,
        ab: [(i64, i64); n],
    }

    let mut map = HashMap::new();

    // # of (0, 0)
    let mut ans1 = 0i64;
    // # of (0, x)
    let mut ans2 = 0i64;
    // # of (x, 0)
    let mut ans3 = 0i64;

    for (a, b) in ab {
        if (a, b) == (0, 0) {
            ans1 += 1;
            continue;
        }
        if a == 0 {
            ans2 += 1;
            continue;
        }
        if b == 0 {
            ans3 += 1;
            continue;
        }
        let mut aa = a / gcd(a, b);
        let mut bb = b / gcd(a, b);

        if aa < 0 {
            aa *= -1;
            bb *= -1;
        }

        *map.entry((aa, bb)).or_insert(0) += 1;
    }

    let mut pow2 = [1i64; 300001];
    for i in 1..300001 {
        pow2[i] = pow2[i - 1] * 2;
        pow2[i] %= MOD;
    }

    let mut ans = 1i64;
    ans *= (pow2[ans2 as usize] + pow2[ans3 as usize] - 1) % MOD;
    ans %= MOD;

    let tmap = map.clone();
    for (key, _) in tmap.iter() {
        let key1 = *key;
        let key2 = (key1.1.abs(), key1.0 * if key1.1 < 0 { 1 } else { -1 });
        let val1 = map.entry(key1).or_default().clone();
        let val2 = map.entry(key2).or_default().clone();

        let mut tmp = pow2[val1 as usize] + pow2[val2 as usize] - 1;
        tmp %= MOD;
        ans *= tmp;
        ans %= MOD;

        map.entry(key1).and_modify(|x| *x = 0);
        map.entry(key2).and_modify(|x| *x = 0);
    }

    println!("{}", (ans - 1 + ans1 + MOD) % MOD);
}


Measured memory_bytes: 37596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[]k = new int[8];
		int cnt = 0;
		for(int i = 0; i < N; i++) {
			int a = sc.nextInt();
			if(a < 400) k[0]++;
			else if(a < 800) k[1]++;
			else if(a < 1200) k[2]++;
			else if(a < 1600) k[3]++;
			else if(a < 2000) k[4]++;
			else if(a < 2400) k[5]++;
			else if(a < 2800) k[6]++;
			else if(a < 3200) k[7]++;
			else cnt++;
		}
		sc.close();
		int t = 0;
		for(int i = 0; i < 8; i++) {
			if(k[i] != 0) {
				t++;
			}
		}
		System.out.println(Math.max(t, 1) +" " + (t + cnt));
	}
}

Measured memory_bytes: 21844
#![allow(dead_code)]
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let a: isize = sc.read();
    let b: isize = sc.read();

    format!("{}\n", std::cmp::max(0, a-2*b))
}
#[test]
fn test_solve() {
   assert_eq!(solve("12 4\n"), "4\n");
   assert_eq!(solve("20 15\n"), "0\n");
   assert_eq!(solve("20 30\n"), "0\n");
}
fn main() {
    let mut buf = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut buf).unwrap();
    use std::io::Write;
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<I> {
    src: I,
}
impl<'a> Scanner<std::str::SplitWhitespace<'a>> {
    fn from_str(src: &'a str) -> Self {
        Scanner {
            src: src.split_whitespace(),
        }
    }
}
impl<'a, I> Scanner<I>
where
    I: std::iter::Iterator<Item = &'a str>,
{
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.src.next().unwrap().parse().ok().expect("Parse error")
    }
    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    fn chars(&mut self) -> Vec<char> {
        self.src.next().unwrap().chars().collect()
    }
}

Measured memory_bytes: 4352
#include <stdio.h>

int main()
{
 int a,b,c;
 scanf("%d" ,&a);
 scanf("%d" ,&b);
 scanf("%d" ,&c);
 
 if (a < b&&b < c)
 printf("Yes\n");
 else
 printf("No\n");
 return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int field[1000][1000];
int W, H;
int tmp;

void dfs(int x, int y){
  field[y][x] = -1;
  for(int i = 0 ; i < 4 ; i++){
    if(x+dx[i]<0 || W <= x+dx[i] || y+dy[i] < 0 || H <= y+dy[i]) continue;
    if(field[y+dy[i]][x+dx[i]] != tmp) continue;
    dfs(x+dx[i], y+dy[i]);
  }
}
    
int main(){
  int sx, sy, gx, gy, n;
  int c, d, x, y;

  while(cin >> W >> H){
    if(W == 0 && H == 0) break;
    memset(field, 0, sizeof(field));
    cin >> sx >> sy >> gx >> gy >> n;
    sx--, sy--, gx--, gy--;
    for(int i = 0 ; i < n ; i++){
      cin >> c >> d >> x >> y;
      x--, y--;
      
      if(d == 1){
	for(int i = y ; i < y+4 ; i++){
	  for(int j = x ; j < x+2 ; j++){
	    field[i][j] = c;
	  }
	}
      }
      else{
	for(int i = y ; i < y+2 ; i++){
	  for(int j = x ; j < x+4 ; j++){
	    field[i][j] = c;
	  }
	}
      }
    }
    if(field[sy][sx] == 0){
      cout << "NG" << endl;
      continue;
    }
    
    tmp = field[sy][sx];
    dfs(sx, sy);
    
    if(field[gy][gx] == -1) cout << "OK" << endl;
    else cout << "NG" << endl;
  }
  return 0;
}
      

Measured memory_bytes: 5068
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;

const int N = 1e6+7;
const int MOD = 1e9+7;
const int INF = (~(1<<31));

int fre(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}

inline int read(){
	int x=0,f=-1;char ch=getchar();
	for(;ch<'0'||'9'<ch;ch=getchar())if(ch=='-') f=-1;
	for(;'0'<=ch&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}

#define lal puts("****");
#define pb  push_back
#define mp  make_pair

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

int n,m;
int a[111][111];

int main(){
	cin>>n>>m;
	if(n+m>=10) puts("error");
	else        printf("%d\n",n+m );
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <unordered_map>
#include <cstring>
#include <cstdio>
using namespace std;
int a, b, c, d;
int main()
{
    cin>>a>>b>>c>>d;
    for(int i = 0 ; i < c-a ; i++ ) cout<<"R";
    for(int i = 0 ; i < d-b ; i++ ) cout<<"U";
    for(int i = 0 ; i < c-a ; i++ ) cout<<"L";
    for(int i = 0 ; i < d-b ; i++ ) cout<<"D";
    cout<<"D"; for(int i = 0 ; i <= c-a ; i++ ) cout<<"R";
    for(int i = 0 ; i <= d-b ; i++ ) cout<<"U"; cout<<"L";
    cout<<"U"; for(int i = 0 ; i <= c-a ; i++ ) cout<<"L";
    for(int i = 0 ; i <= d-b ; i++ ) cout<<"D"; cout<< "R";
    cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Y cout<<"YES"<<endl;
#define N cout<<"NO"<<endl;
#define tc int t; cin>>t; while(t--)
#define eki int n; cin>>n;
#define loop for(int i=0; i<n; i++)
int main()
{  
   
   float a, sum1=0, sum2=0;
   string s;
   tc {
   cin>>a>>s;
   if(s=="JPY")
   sum1=sum1+a;
   else sum2=sum2+a;
   }
   sum2=sum2*380000.0;
   sum1= sum1+sum2;
   cout<<sum1<<endl;
   
   
}




Measured memory_bytes: 3824
#include<iostream>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b;
	long long d=0;
	for(int i=1;i<=b;i++){
		cin>>c;
		d=d+c;
	}
	if(d>a){
		cout<<"-1"<<endl;
	}
	else cout<<a-d;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt();
    long[] a=new long[3*n];
    long sum=0;
    for(int i=0;i<3*n;i++){
      a[i]=sc.nextLong();
    }
    Arrays.sort(a);
    for(int i=3*n-2;i>=n;i-=2){
      sum+=a[i];
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 99488
#include <bits/stdc++.h>
    using namespace std;
     
    #define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL)
     
    int main()
    {
    	fastIO;

    	int n,ans=0,i,j;
    	cin>>n;
    	for(i=1;i<=n;i+=2)
    	{
    		int x=sqrt(i);
    		int c=0;
    		for(j=1;j<=x;j++)
    		{
    			if(i%j==0)
    			{
    				c++;
    				if(j!=(i/j))
    					c++;
    			}
    		}
    		
    		if(c==8)
    			ans++;
    	}
    	cout<<ans;
    	return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e17;
using namespace std;

int N,M,L,Q;
int dis[305][305];
int gas[305][305];
int s[100010],t[100010];
int A[100000],B[100000],C[100000];

void input() {
    cin >> N >> M >> L;
    rep(i,M) {cin >> A[i] >> B[i] >> C[i]; A[i]--; B[i]--;}
    cin >> Q;
    rep(i,Q) {cin >> s[i] >> t[i]; s[i]--; t[i]--;}
}


signed main() {
    input();
    rep(i,N){
        rep(j,N){
            dis[i][j]=INF;
            gas[i][j]=INF;
            if(i==j) {dis[i][j]=0; gas[i][j]=0;}
        }
    }
    rep(i,M){
        dis[A[i]][B[i]] = C[i];
        dis[B[i]][A[i]] = C[i];
    }
    rep(i,N) 
        rep(j,N) 
            rep(k,N) 
                dis[j][k] = min(dis[j][k],dis[j][i]+dis[i][k]);

    rep(i,N) rep(j,N){
        if(i==j) continue;
        if(dis[i][j] <= L) gas[i][j] = min(gas[i][j],(long)1);
    }

    rep(i,N) 
        rep(j,N) 
            rep(k,N) 
                gas[j][k] = min(gas[j][k],gas[j][i]+gas[i][k]);

    rep(i,Q){
        if(gas[t[i]][s[i]] < INF) cout << gas[t[i]][s[i]] - 1 << endl;
        else cout << -1 << endl; 
    }

}

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

int main(){

    int N;
    int d[110];

    cin >> N;
    for(int i = 0; i < N; ++i) cin >> d[i];

    int num[110] = {0};

    for(int i = 0 ; i < N; ++i){
        num[d[i]]++;
    }

    int res = 0;
    for (int i = 1; i <= 100; ++i){
        if(num[i]){
            ++res;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
using std::swap;


int main()
{	
	int r,D,x,a;
	cin >> r >> D >> x;
	for (int i = 0; i < 10; ++i) {
		a = r * x - D;
		cout << a << "\n";
		x = a;
	}
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> V(N);
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		V[A - 1] = i + 1;
	}
	for (int i = 0; i < N; i++) {
		cout << V[i];
		if (i < N - 1)
			cout << " ";
		else
			cout << endl;
	}
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,m,dp[5010][5010];
string s;
signed main(){
    cin>>n>>s;
    m=s.size();
    dp[0][0]=1;
    rep(i,n){
        rep(j,n){
            if(j==0){
                //dp[i][j]->dp[i+1][j+1],dp[i+1][j]
                dp[i+1][j+1]+=dp[i][j]*2;
                dp[i+1][j]+=dp[i][j];
                dp[i+1][j+1]%=mod;
                dp[i+1][j]%=mod;
            }
            else{
                dp[i+1][j+1]+=dp[i][j]*2;
                dp[i+1][j-1]+=dp[i][j];
                dp[i+1][j+1]%=mod;
                dp[i+1][j-1]%=mod;
            }
        }
    }
    int ans=dp[n][m]*inv(modpow(2,m))%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 196864
#include <bits/stdc++.h>
using namespace std;
const int MAXN=30;
int h,w,ans,mz[MAXN][MAXN],vis[MAXN][MAXN],dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
char c[MAXN];
queue < pair< pair <int,int> ,int> > q;
int avail (int x,int y) {return mz[x][y]|(x==0)|(y==0)|(x==h+1)|(y==w+1);}
void bfs (int x,int y) {
	memset(vis,0,sizeof(vis));
	while (!q.empty()) {q.pop();}
	vis[x][y]=1;
	q.push(make_pair(make_pair(x,y),0));
	while (!q.empty()) {
		pair< pair<int,int>,int> a=q.front();
		q.pop();
		ans=max(ans,a.second);
		pair<int,int> b=a.first;
		for (int i=0;i<4;i++) {
			int dx=b.first+dir[i][0],dy=b.second+dir[i][1];
			if (avail(dx,dy)) {continue;}
			if (vis[dx][dy]) {continue;}
			vis[dx][dy]=1;
			q.push(make_pair(make_pair(dx,dy),a.second+1)); 
		}
	}
	return; 
}
int main () {
	scanf("%d%d",&h,&w);
	for (int i=1;i<=h;i++) {
		scanf("%s",c+1);
		for (int j=1;j<=w;j++) {mz[i][j]=(c[j]=='#'?1:0);}
	}
	for (int i=1;i<=h;i++) {
		for (int j=1;j<=w;j++) {
			if (!avail(i,j)) {
				bfs(i,j);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long llong;

int main() {
	int n;
  	cin >> n;
  	for (int i = 1; i <= 3500; ++i) {
     	for (int j = 1; j <= i; ++j) {
        	llong a = (llong)i * j * n;
        	llong b = 4ll * i * j - (i + j) * n;
        	if (b <= 0) continue;
        	if (a % b) continue;
        	printf("%d %d %lld\n", i, j, a / b);
        	return 0;
        }
    }
	return 1;
}

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

#define MAX 100000

int partition(int A[],int p,int r) {
  int x = A[r],i = p - 1;
  for(int j = p; j < r; j++) {
    if(A[j] <= x) {
      i++;
      swap(A[j],A[i]);
    }
  }
  swap(A[i + 1],A[r]);
  return i + 1;
}


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

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

  int q = partition(A,0,n - 1);

  for(int i = 0; i < n; i++) {
    if(i) cout << " ";
    if(i == q) cout << '[';
    cout << A[i];
    if(i == q) cout << ']';
  }
  cout << endl;

 
}




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

using namespace std;

typedef long long ll;

template<typename T>
void _dump(const char* s, T&& head)
{
  cerr << s << "=" << head << endl;
}

template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail)
{
  while (*s != ',')
    cerr << *s++;
  cerr << "=" << head << ",";
  _dump(s + 1, tail...);
}

template<typename T>
void _dumpv(const char* s, T&& v)
{
  cerr << *s << "=";
  for (auto it = v.begin(); it != v.end(); it++) {
    cerr << *it << " ";
  }
  cerr << endl;
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__)
#define dumpv(...) _dumpv(#__VA_ARGS__, __VA_ARGS__)

const ll MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("template.1", "r", stdin);

  string S;
  cin >> S;
  int year, month, day;
  sscanf(S.c_str(), "%d/%d/%d", &year, &month, &day);
  dump(year, month, day);
  if (year <= 2019) {
    if (month <= 4) {
      if (day <= 30) {
        cout << "Heisei" << endl;
        return 0;
      }
    }
  }
  cout << "TBD" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string>

#define _CRT_SECURE_NO_WARNINGS

int main() {
	int N;
	scanf("%d", &N);

	for (int i = 3500; i >= 1; i--) {
		if ((float)(1.0 / i)  > (float)(4.0 / N)) {
			break;
		}
		for (int j = i; j >= 1; j--) {
			if ((float)(1.0 / i) + (float)(1.0 / j) > (float)(4.0 / N)) {
				break;
			}
			int k = 1750;
			int l=1,r = 3500;
			while(true){
				if (4 * i*j*k == N*(i*j + j*k + k*i)) {
					printf("%d %d %d\n", i, j, k);
					return 0;
				}
				else if ((float)(1.0 / i) + (float)(1.0 / j) + (float)(1.0 / k) < (float)(4.0 / N)) {
					r = k;
					if (k == (l + k) / 2) {
						break;
					}
					k = (l + k) / 2;
				}
				else {
					l = k;
					if (k== (k + r) / 2) {
						break;
					}
					k = (k + r) / 2;
				}
			}
			
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,0,n)cin >> v[i];
	const int inf = 1e9;
	int best = inf;
	rep(i,1,100+1){
		int temp = 0;
		rep(j,0,n){
			temp += (v[j]-i)*(v[j]-i);
		}
		gmin(best,temp);
	}
	cout << best << '\n';
}


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

int main(){
    ll N;
    cin>>N;
    vector<ll> a(3*N);
    for(ll i=0;i<3*N;i++){
        cin>>a.at(i);
    }
    //入力終わり
    vector<ll> before(N);
    vector<ll> after(N);
    for(ll i=0;i<N;i++){
        before.at(i) = a.at(i);
        after.at(i) = a.at(i+2*N);
    }
    ll Before = accumulate(before.begin(),before.end(),0LL);
    ll After = accumulate(after.begin(),after.end(),0LL);
    map<ll,ll> beforemap;
    map<ll,ll> aftermap;
    beforemap[0] = Before;
    aftermap[N] = After;
    priority_queue<ll, vector<ll>, greater<ll>> beforeque;
    priority_queue<ll> afterque;
    for(ll i=0;i<N;i++){
        beforeque.push(a.at(i));
        afterque.push(a.at(i+2*N));
    }
    for(ll i=0;i<N;i++){
        beforeque.push(a.at(i+N));
        beforemap[i+1] = beforemap[i] + a.at(i+N) - beforeque.top();
        beforeque.pop();
        afterque.push(a.at(2*N-i-1));
        aftermap[N-i-1] = aftermap[N-i] + a.at(2*N-i-1) - afterque.top();
        afterque.pop();
    }
    vector<ll> ans(N+1);
    for(ll i=0;i<N+1;i++){
        ans.at(i)=beforemap[i]-aftermap[i];
    }
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());
    cout<<ans.at(0)<<endl;
}

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

int main() {
    long long A, B, N;
    cin >> A >> B >> N;
    if (B>N) cout << floor((A*N)/B)-A*floor(N/B);
    else cout << floor((A*(B-1))/B)-A*floor((B-1)/B);
}

Measured memory_bytes: 3784
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	string S,ans;
	cin >> S;
	if (S[0] != S[1] || S[1] != S[2]) {
		ans = "Yes";
	}
	else {
		ans = "No";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <vector>
#include <stdio.h>
#include <cmath>
#include <map> 
#include <climits>
#include <unordered_map> 
#include <string> 
#include <algorithm>
#include <stack>
#include <queue>
#include <list> 

using namespace std;

int main() {
	int n, h, w;
	cin >> n >> h >> w;
	int counter = 0, height, width;
	for (int i = 0; i < n; i++) {
		cin >> height >> width;
		if (height >= h && width >= w) {
			counter++;
		}
	}
	cout << counter << endl;
    return 0;
}

Measured memory_bytes: 888
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskD {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			char[] s = in.next().toCharArray();
			int[] d = new int[1 << 26];
			Arrays.fill(d, s.length);
			d[0] = 0;
			int mask = 0;
			int ans = s.length;
			for (int i = 0; i < s.length; i++) {
				int c = s[i] - 'a';
				mask ^= 1 << c;
				for (int j = -1; j < 26; j++) {
					int m = j < 0 ? 0 : (1 << j);
					int cur = 1 + d[m ^ mask];
					d[mask] = Math.min(d[mask], cur);
					if (i == s.length - 1) {
						ans = Math.min(ans, cur);
					}
				}
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(in.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

	}
}



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

//  a^b % m
long long powmod(long long a, long long b, long long m)
{
    long long r = 1;
    for (; b>0; b>>=1, a=a*a%m)
        if (b&1)
            r = r*a%m;
    return r;
}

int main()
{
    int B, W;
    cin>>B>>W;

    long long M = 1000000007;

    vector<long long> F(B+W+1);
    F[0] = 1;
    for (int i=1; i<=B+W; i++)
        F[i] = F[i-1]*i%M;

    long long b = 0;
    long long w = 0;
    for (int i=0; i<B+W; i++)
    {
        b = b*2%M;
        if (B<=i)
        {
            b += F[i-1]*powmod(F[B-1],M-2,M)%M*powmod(F[i-B],M-2,M)%M;
            b %= M;
        }
        w = w*2%M;
        if (W<=i)
        {
            w += F[i-1]*powmod(F[W-1],M-2,M)%M*powmod(F[i-W],M-2,M)%M;
            w %= M;
        }
        cout<<(powmod(2, i, M) - b + w + M)%M*powmod(powmod(2, i+1, M), M-2, M)%M<<endl;
    }
}


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

using namespace std;

typedef long long ll;

int main() {
    ll N, K;

    scanf("%lld %lld", &N, &K);

    if (N == K || N == 0) {
        puts("0");
    } else if (N < K) {
        printf("%lld\n", min(N, K - N));
    } else {
        ll t = N % K;
        printf("%lld\n", min(t, K - t));
    }


    return 0;
}

Measured memory_bytes: 256
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
n,a,b = map(int, input().split())

print(min(a,b), max(a + b - n, 0))




Measured memory_bytes: 6736
package main

import (
        "fmt"
        "strconv"
)

func main() {
        a := ""
        b := make([]string, 0)
        fmt.Scan(&a)
        run_cnt := 0
        cnt, _ := strconv.Atoi(a)
        if cnt > 200 {
                cnt = 200
        }
        for ii := 0; ii < cnt; ii++ {
                fmt.Scan(&a)
                b = append(b, a)
        }
next:
        for k, v := range b {
                z, _ := strconv.Atoi(v)
                if z == 0 {
                        goto term
                } else if z%2 == 0 {
                        b[k] = fmt.Sprintf("%d", (z / 2))
                } else {
                        goto term
                }
        }
        run_cnt++
        goto next
term:
        fmt.Println(run_cnt)
}

Measured memory_bytes: 640