akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

constexpr int W = (int)1e+5, K = 9;

int dp[1 << 8][W + 1];

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

    int n;
    cin >> n;

    vector<int> v(n + 1), w(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> v[i] >> w[i];
    }

    if (n >= 1 << K) {
        for (int k = 0; k < 1 << (K - 1); k++) {
            for (int i = (1 << (K - 1)) + k; i; i /= 2) {
                for (int j = W; j >= w[i]; j--) {
                    chmax(dp[k][j], dp[k][j - w[i]] + v[i]);
                }
            }
        }
    }

    int q;
    cin >> q;

    while (q--) {
        int i, L;
        cin >> i >> L;

        int i0 = i;
        int t = i < 1 << K ? 1 : 1 << K;
        int r = 0;

        for (int l = 0; l < 1 << K; l++) {
            i = i0;
            int v1 = 0, w1 = 0;
            for (int m = 1; i >= t; m <<= 1, i /= 2) {
                if (l & m) {
                    v1 += v[i];
                    w1 += w[i];
                }
            }
            if (w1 > L) continue;
            int k = i - (1 << (K - 1));
            chmax(r, (k < 0 ? 0 : dp[k][L - w1]) + v1);
        }

        cout << r << '\n';
    }

    return 0;
}

Measured memory_bytes: 105108
#include<stdio.h>

int main(void)
{
	int m = 0, f = 0, r = 0;

	while ((m != -1) || (f != -1) || (r != -1))
	{
		scanf("%d %d %d", &m, &f, &r);
		{
			if ((m == -1) && (f == -1) && (r == -1))
			{
				return 0;
			}
			else
			{
				if ((m == -1) || (f == -1))
				{
					printf("F\n");
				}
				else
				{
					if (m + f >= 80)
					{
						printf("A\n");
					}
					else
					{
						if ((m + f >= 65) && (80 > m + f))
						{
							printf("B\n");
						}
						else
						{
							if ((m + f >= 50) && (65 > m + f) || (r >= 50))
							{
								printf("C\n");
							}
							else
							{
								if ((m + f >= 30) && (50 > m + f))
								{
									printf("D\n");
								}
								else
								{
									if ((m + f < 30))
									{
										printf("F\n");
									}


								}
							}
						}
					}
				}
			}


		}
	}
	return 0;
}


Measured memory_bytes: 2044
n,d = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(n)]
ans = 0

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

for i in range(n-1):
    for j in range(i+1,n):
        t = 0
        for x in range(d):
            t += (X[i][x]-X[j][x])**2
        t **= 0.5
        if is_integer_num(t):
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define INF (int) 2e18
#define N (int) 2e5
using namespace std;
int X, Y, A, B, C;
int a[N], b[N], c[N];

bool cmp (const int & x, const int & y) {
	return x > y;
}

signed main () {
	cin >> X >> Y >> A >> B >> C;
	for (int i = 1; i <= A; i ++) cin >> a[i];
	for (int i = 1; i <= B; i ++) cin >> b[i];
	for (int i = 1; i <= C; i ++) cin >> c[i];
	
	sort (a+1, a+A+1, cmp);
	sort (b+1, b+B+1, cmp);
	sort (c+1, c+C+1, cmp);
	
	int i, j, ans = 0;
	for (i = 1; i <= X; i ++) ans += a[i];
	for (j = 1; j <= Y; j ++) ans += b[j];
	
	i --, j --;
	
	int k = 1;
	a[0] = b[0] = INF;
	for (; i >= 1 || j >= 1 && k <= C;) {
		if (a[i] < b[j]) {
			if (c[k] > a[i]) ans += c[k ++], ans -= a[i --];
		} else {
			if (c[k] > b[j]) ans += c[k ++], ans -= b[j --];
		}
		if (a[i] >= c[k] && b[j] >= c[k]) break;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main(void){
    int n,col[9]={};
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a>3200) a=3200;
        col[a/400] ++;
    }

    int ans=0;
    for(int i=0;i<8;i++){
        ans += (col[i]>0);
    }
    cout<<(ans>0?ans:1)<<" "<<(ans+col[8])<<endl;

}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
 
    h,w,k = map(int,input().split())
    mod = 10**9+7
 
    if w == 1:
        print(1)
        return
 
    fib = [1,2,3,5]
    for i in range(100):
        fib.append(fib[len(fib)-1]+fib[len(fib)-2])
    fib.append(1)
    fib.append(1)
    fib.append(1)
 
 
    dp = [[0]*w for _ in [0]*h]
    dp[0][0] = fib[w-2]
    dp[0][1] = fib[w-3]
 
    for i in range(1,h):
        for j in range(w):
            dp[i][j] = (dp[i-1][j]*fib[j-1]*fib[w-2-j])%mod
            if j >= 1:
                dp[i][j] = (dp[i][j] + dp[i-1][j-1]*fib[j-2]*fib[w-2-j])%mod
            if j <= w-2:
                dp[i][j] = (dp[i][j] + dp[i-1][j+1]*fib[j-1]*fib[w-3-j])%mod
    
    print(dp[-1][k-1])
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <bitset>
#include <queue>
#include <set>

constexpr long long INFLL = 1e18;

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    string s;
    cin >> s;
    int ans;
    if (s.at(0) == 'R')
    {
        if (s.at(1) == 'R')
        {
            if (s.at(2) == 'R')
            {
                ans = 3;
            }
            else
            {
                ans = 2;
            }
        }
        else
        {
            ans = 1;
        }
    }
    else
    {
        if (s.at(1) == 'R')
        {
            if (s.at(2) == 'R')
            {
                ans = 2;
            }
            else
            {
                ans = 1;
            }
        }
        else
        {
            if (s.at(2) == 'R')
            {
                ans = 1;
            }
            else
            {
                ans = 0;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n,h;
    cin>>n>>h;
    int chop[100000],cast[100000];
    int strongest=0;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>chop[i]>>cast[i];
        if(chop[strongest] == chop[i] && cast[strongest] < cast[i]){
            strongest = i;
        }else if(chop[strongest] < chop[i]){
            strongest = i;
        }
    }
    int superchop = chop[strongest];
    int supercast = cast[strongest];
    //cast[strongest] = 0;
    sort(cast,cast+n);
    for(int i=n; i>=0 && h>0 ;i--){
        if(cast[i]>superchop){
            h -= cast[i];
            ans++;
        }
    }
    if(h>0){
        ans += h/superchop;
        h -= superchop * (h/superchop);
    }
    if(h>0){
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);
long long int arith_sum1(long long int,long long int,long long int);
long long int arith_sum2(long long int,long long int,long long int);
long long int series_sum(long long int);

int main(){
    uset<int> set;
    int n,x;
    cin>>n;
    rep(i,n){
        scanf("%d",&x);
        if(set.count(x)){
            set.erase(x);
        }else{
            set.insert(x);
        }
    }
    cout<<set.size()<<endl;
}

Measured memory_bytes: 7364
import java.util.*;

public class Main {
    public static int solve() {
        return 0;
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if (c >= a && c <= b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21716
#include<cstdio>
#include<iostream>
#include<cstring>

using namespace std;

char s[1005];
int w;

int main()
{
	scanf("%s", s);
	scanf("%d", &w);
	for (int i = 0, j = strlen(s); i < j; i += w) printf("%c", s[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

int dp[5005][5005];
void solve(){  
	int n;
	cin>>n;
	string s;
	cin>>s;
	rep(i,0,sz(s)){
		rep(j,0,sz(s)){
			if(s[i]==s[j]){
				dp[i+1][j+1]=dp[i][j]+1;
			}
		}
	}  
	int ans=0;
	rep(i,0,sz(s)+1){
		rep(j,i,sz(s)+1){
			ans=max(ans,min(dp[i][j],j-i));
		}
	}
	cout<<ans<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 98048
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{

    int k;
    string s;
    cin >> k >> s;

    if(s.size() <= k)
        cout << s << endl;
    else{
        string new_s = s.substr(0,k); 
        cout << new_s << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ull unsigned long long
#define db double
#define vi vector<ll>
#define vvi vector<vector<int> >
#define vvii vector<vector<pii> >
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl "\n"
#define pii pair<ll,ll>
#define piii pair<ll,pair<ll,ll> >
#define mem(a,b) memset(a , b , sizeof a ) ; 
#define pb push_back
#define pf push_front
#define F first 
#define S second 
#define mp make_pair
#define all(v) v.begin(),v.end()

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}



#define deb1(a) cout<<#a<<"=*"<<a<<endl;
#define deb2(a) cout<<#a<<"=@"<<a<<endl;
#define deb3(a) cout<<#a<<"=#"<<a<<endl;
#define deb4(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;
#define deb5(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


ll mod=1000000007;
ll vis[212345]={0};
vvi v(212345);
ll d[212345]={0};


ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}





int main()
{
speed

ll n;
cin>>n;
ll a[n];
rep(i,0,n) cin>>a[i];
sort(a,a+n);
ll c=0;
rep(i,0,n)
{
	rep(j,i+1,n)
	{
		if(a[j]==a[i]) continue;
		rep(k,j+1,n)
		{
			if(a[k]==a[j]) continue;
			if(a[i]+a[j]>a[k]) c++;
		}
	}
}

cout<<c<<endl;
}


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

fn main() {
    let o = read_v();
    let e = read_v();

    let on = o.iter().len();
    let en = e.iter().len();

    let out = stdout();
    let mut out = BufWriter::new(out.lock());

    for c in 0..en {
        write!(out, "{}", o[c]);
        write!(out, "{}", e[c]);
    }
    if on > en {
        write!(out, "{}", o[on - 1]);
    }
}

fn read_v() -> Vec<char> {
    let s = stdin();
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<Vec<char>>();
    b
}



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

int main()
{
	vector<int> key(1000,0);
	int n;
	string s;
	cin >> n;
	cin >> s;
	vector<int> si(n);
	{
		for (int i = 0; i < n; ++i) {
			if (s[i] == '0') {
				si[i] = 0;
			}else if (s[i] == '1') {
				si[i] = 1;
			}
			else if (s[i] == '2') {
				si[i] = 2;
			}
			else if (s[i] == '3') {
				si[i] = 3;
			}
			else if (s[i] == '4') {
				si[i] = 4;
			}
			else if (s[i] == '5') {
				si[i] = 5;
			}
			else if (s[i] == '6') {
				si[i] = 6;
			}
			else if (s[i] == '7') {
				si[i] = 7;
			}
			else if (s[i] == '8') {
				si[i] = 8;
			}
			else if (s[i] == '9') {
				si[i] = 9;
			}
		}
	}

	int ret = 0;
	int imax = n - 3;
	int jmax = n - 2;
	int kmax = n - 1;
	int num = 0;
	vector<int> restoreI(10, 0);
	for (int i = 0; i <= imax; ++i) 
	{
		if (restoreI[si[i]] == 1) {
			continue;
		}
		restoreI[si[i]] = 1;
		vector<int> restoreJ(10, 0);
		for (int j = i+1; j <= jmax; ++j)
		{
			if (restoreJ[si[j]] == 1) {
				continue;
			}
			restoreJ[si[j]] = 1;
			vector<int> restoreK(10, 0);
			for (int k =j+1; k <= kmax; ++k)
			{
				if (restoreK[si[k]] == 1) {
					continue;
				}
				restoreK[si[k]] = 1;

				num = si[i] * 100 + si[j] * 10 + si[k];
				if (key[num] == 0) {
					key[num] = 1;
					++ret;
				}
			}
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a,b,n;
	cin >> a >> b >> n;
	long long int t=1000000;
	double aa,bb,xx,bbb=b,nn;
	xx=n;nn=n;
	long long int p,q;
	long long int ans=(-1000000);
	xx=min(n,b-1);
	aa=xx*a;aa/=bbb;p=aa;
	bb=xx/bbb;q=bb;q*=a;
	p-=q;
	ans=max(ans,p);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3512
import itertools
import math
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]

sm=0

for i in itertools.permutations(A):
    for j in range(1,N):
        sm+=(abs(i[j-1][0]-i[j][0])**2+abs(i[j-1][1]-i[j][1])**2)**0.5

print(sm/math.factorial(N))


Measured memory_bytes: 74772
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 2e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}
map<int,int> prime_factor(int n){
  map<int,int> res;
  for (int i(2);i*i<=n;i++){
    while(n%i==0){
      ++res[i];
      n/=i;
    }
  }
  if (n!=1) res[n]=1;
  return res;
}

int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  rep(i,N) cin>>a[i];
  reverse(a.begin(),a.end());
  int dp[100001];
  fill(dp,dp+N+1,INFint);
  for (int i(0);i<N;i++){
    *upper_bound(dp,dp+N,a[i]) = a[i];
  }
  cout << lower_bound(dp,dp+N,INFint) - dp << endl;
  return 0;
}


Measured memory_bytes: 1024
#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 1001001001
typedef pair<int,int> P;
#define mod 1000000007


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b&&b!=c) {
        cout << "Yes";
        return 0;
    }
    else if (b==c&&c!=a){
         cout << "Yes";
        return 0;
    }
    else if (c==a&&a!=b){
         cout << "Yes";
        return 0;
    }
    else{
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return x*f;
}
inline void print(int x){
	if(x<0) x=-x,putchar('-');
	if(x>=10) print(x/10);
	putchar(x%10+48);
}
char s[1010],t[1010];
int main(){
	int ans=0x3f3f3f3f;
	scanf("%s",s+1);scanf("%s",t+1);
	int lens=strlen(s+1);int lent=strlen(t+1);
	for(int i=1;i+lent-1<=lens;++i){
		int res=lent;
		for(int j=1;j<=lent;++j){
			if(s[i+j-1]==t[j]) --res;
		}
		ans=min(ans,res);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <cmath>
#include <utility>
#include <queue>
#include <map>
#include <list>
#include <set>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

const static int MAX_N = 200000;
vector<ll> c(MAX_N, 0);

ll count(ll x) {
  return x * (x - 1) / 2;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> as(n);
  ll total = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    as[i] = a;
    ++c[a];
  }
  for (const auto x : c) {
    total += count(x);
  }

  for (const auto a : as) {
    cout << total - count(c[a]) + count(c[a] - 1) << endl;
  }

  return 0;
}




Measured memory_bytes: 4992
#include <cstdio>

int n,m,d1,d2,cnt,vis[605][605];

void solve(int d){
	int tim=0; while(d%4==0) d/=4,++tim;
	if(d&1){
		for(int i=0;i<m;++i) for(int j=0;j<m;++j){
			if(((i>>tim)+(j>>tim))&1) vis[i][j]=1;
		}
	}
	else{
		for(int i=0;i<m;++i) for(int j=0;j<m;++j){
			if((i>>tim)&1) vis[i][j]=1;
		}
	}
}

int main(){
	scanf("%d%d%d",&n,&d1,&d2); m=n<<1; solve(d1); solve(d2);
	for(int i=0;i<m;++i) for(int j=0;j<m;++j){
		if(!vis[i][j]) printf("%d %d\n",i,j),++cnt;
		if(cnt==n*n) return 0;
	}
}

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

const ll INF = 1LL << 40;
int N;
int A[310][310];
ll dis[310][310];
ll sum;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A[i][j];
    }
  }
  fill_n((ll*)dis, 310*310, INF);
  for (int i = 0; i < N; i++)
    dis[i][i] = 0;

  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      if (i == j) continue;
      bool flag = true;
      for (int k = 0; k < N; k++) {
        if (k == i || k == j) continue;
        if (A[i][j] == A[i][k] + A[k][j]) flag = false;
      }
      if (flag) {
        dis[i][j] = dis[j][i] = A[i][j];
        sum += A[i][j];
      }
    }
  }
  for (int k = 0; k < N; k++)
    for (int i = 0; i < N; i++)
      for (int j = 0; j < N; j++)
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (dis[i][j] != A[i][j]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << sum << endl;

  return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	
	if (a > b) {
		for (int i = 0; i < a; i++) {
			cout << b;
		}
		cout << endl;
	}
	else {
		for (int i = 0; i < b; i++) {
			cout << a;
		}
		cout << endl;

	}
}


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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

void solve(long long N, long long M, std::vector<long long> H, std::vector<long long> A, std::vector<long long> B){
    // かく展望台に、道をなめながらそっちのほうがよければポイントをあたえる。ポイントと本数がおなじならok
    // shift
    for(int i=0; i < M; i++){
        A.at(i)--;
        B.at(i)--;
    }
    
    // グラフをつくる。そしてポイントをあたえる。
    vec<set<int>> conn(N);
    vec<ll> points(N);
    for(int i=0; i < M; i++){
        if(conn.at(A.at(i)).find(B.at(i)) == conn.at(A.at(i)).end()){
            // あたらしい道にかぎる
            conn.at(A.at(i)).insert(B.at(i));
            conn.at(B.at(i)).insert(A.at(i));
            // ポイントをあたえる
            if(H.at(A.at(i)) > H.at(B.at(i))){
                points.at(A.at(i))++;
            }else if(H.at(A.at(i)) < H.at(B.at(i))){
                points.at(B.at(i))++;
            }
        }
        

    }

    ll res = 0;
    // ポイントをくらべる
    for(int i=0; i < N; i++){
        if(conn.at(i).size() == points.at(i)){
            res++;
        }
    }

    cout << res << endl;
    


    // みちを

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(H), std::move(A), std::move(B));
    return 0;
}


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

int main() {

    int N, K;
    cin >> N >> K;
    int p[N];
    rep(i,N){
        cin >> p[i];
    }

    sort(p, p+N);

    int ans = 0;
    for(int i = 0; i < K; i++){
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
import sys
from collections import deque
s=sys.stdin.readlines()
q=int(s[0].split()[1])
f=lambda x,y:(x,int(y))
d=deque(f(*e.split())for e in s[1:])
t=0
while d:
 k,v=d.popleft()
 if v>q:v-=q;t+=q;d.append([k,v])
 else:t+=v;print(k,t)


Measured memory_bytes: 16300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,n) for(int i = 0;i<n;i++)

int main(){
	ll n,q;
	cin >> n;
	vector<ll>a(n);
	vector<ll>num(1e5,0);
	ll sum = 0;

	rep(i,n){
		cin >> a[i];
		sum += a[i];
		num[a[i]] += 1;
	}

	cin >> q;
	std::vector<ll> b(q);
	std::vector<ll> c(q);
	rep(i,q){
		cin >> b[i] >> c[i];
	}
	rep(i,q){
		sum = sum + num[b[i]]*(c[i]-b[i]);
		num[c[i]] += num[b[i]];
		num[b[i]] = 0;
		cout << sum << endl;
	}

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  bool flag = false;
  for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
      if(i*j==N){flag = true; break;}
    }
  }
  if(flag)cout << "Yes" <<endl;
  if(!flag)cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 55
using namespace std;

int n,m, s;
char a[N][N];
int main()
{
	int i,j, k, w;
	cin >> n >> m;
	for (i = 1; i <= n; i++) {
		scanf ("%s", &a[i][1]);
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			if (a[i][j] == '#') continue;
			s = 0;
			for (k = -1; k <= 1; k++) {
				for (w = -1; w <= 1; w++) {
					if (a[i + k][j + w] == '#') s++;
				}
			}
			a[i][j] = (char)(s + '0');
		}
	}
	for (i = 1;i<= n; i++) {
		for (j = 1; j <= m; j++) {
			printf("%c", a[i][j]);
		}
		puts("");
	}
	return 0;
}



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

using namespace std;

//#define RED_FILE

#ifdef RED_FILE
ifstream ifs("input.txt");
ofstream ofs("output.txt");
#define cin ifs
#define cout ofs
#endif

const int MAX_V=1000;
const int INF=1000000000;
const int MAX_E=200000;

struct edge{
	int to,cap,rev,id;
	int flow;
	edge(int to_,int cap_,int rev_,int id_){
		to=to_;
		cap=cap_;
		rev=rev_;
		id=id_;
		flow=0;
	}
};

vector<edge> G[MAX_V];
bool used[MAX_V];
// Ü¾¶«Äéü©Ç¤©
bool isUsable[MAX_E];
// idxðßé
int lineIdx[MAX_V][MAX_V];

// edgeðÇÁ
void add_edge(int from,int to,int cap,int id){
	G[from].push_back(edge(to,cap,G[to].size(),id));
	G[to].push_back(edge(from,cap,G[from].size()-1,id));
}

// ÁpXðTõ
int dfs(int v,int t,int f){
	if(v==t) return f;
	used[v]=true;
	for(int i=0;i<(int)G[v].size();i++){
		edge &e=G[v][i];
		// ØfÏÝ
		if(!isUsable[e.id])continue;
		// Ü¾t[ð¬¹éÈçÎA¬·
		if(!used[e.to]&&e.flow<e.cap){
			// ¡ñÌ¬Ê
			int quan=e.cap-e.flow;
			//if(e.flow<0)quan=-(e.flow);
			int d=dfs(e.to,t,min(f,quan));
			if(d>0){
				e.flow+=d;
				// ½ÎÉÍ}CiXÌvfðüêÄ¨­
				G[e.to][e.rev].flow=-e.flow;
				return d;
			}
		}
	}
	return 0;
}// ¸­pXðTõ
int dfs2(int v,int t){
	if(v==t) return 1;
	used[v]=true;
	for(int i=0;i<(int)G[v].size();i++){
		edge &e=G[v][i];
		if(!isUsable[e.id])continue;
		// 0æè¬³¯êÎAß·
		if(!used[e.to]&&e.flow<0){
			int d=dfs2(e.to,t);
			if(d>0){
				e.flow+=1;
				G[e.to][e.rev].flow=-e.flow;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow=0;
	while(1){
		memset(used,0,sizeof(used));
		int f=dfs(s,t,INF);
		if(f==0)return flow;
		else flow+=f;
	}
	return 0;
}

int main(){
	int n,ee,q;
	cin>>n>>ee>>q;
	for(int i=0;i<ee;i++){
		int f,t;
		cin>>f>>t;
		// Æè ¦¸ÇÁ
		add_edge(f,t,1,i);
		isUsable[i]=true;
		lineIdx[f][t]=lineIdx[t][f]=i;
	}
	// »ÝÌÅåflowðßé
	int cflow=max_flow(1,n);
	for(int j=0;j<q;j++){
		int m,a,b;
		cin>>m>>a>>b;
		if(m==1){
			add_edge(a,b,1,ee);
			lineIdx[a][b]=lineIdx[b][a]=ee;
			isUsable[ee]=true;
			ee++;
			cflow+=max_flow(1,n);
		}
		else{
			// Ú±ªØê½Æ«AØê½êÉt[ª¬êÄ¢é©»¤ÅÈ¢©Åêª¯
			int eidx=lineIdx[a][b];
			for(int i=0;i<(int)G[a].size();i++){
				edge &e=G[a][i];
				if(!isUsable[e.id])continue;
				if(eidx==e.id){
					// ¬êÄ¢È¢ê,tOðÜé¾¯
					if(e.flow==0)isUsable[eidx]=false;
					// ¬êÄ¢éê
					else{
						int from=a;
						int to=b;
						if(e.flow>0) swap(from,to);
						// flowð0Éú»
						e.flow=G[e.to][e.rev].flow=0;
						// ûüÉµ½ªÁÄtü«Éflowð¬·
						isUsable[eidx]=false;
						memset(used,0,sizeof(used));
						int num=dfs(to,from,1);
						// ¬¹½ê
						if(num==1)
							break;
						// ¬¹È©Á½ê,ß·
						//dfs2(from,to);
						memset(used,0,sizeof(used));
						dfs2(n,from);
						memset(used,0,sizeof(used));
						dfs2(to,1);
						// Øf
						cflow--;
						cflow+=max_flow(1,n);
					}
					break;
				}
			}
		}
		cout<<cflow<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi; 

    int main(){
                
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);   
    // #endif 
 
        fast;
        int t=1;
        // cin>>t;  
        while(t--){     
            int n,m;
            cin>>n>>m;
            cout<<(m>=n?"unsafe":"safe");

        } 
        return 0;   
    }       


    //keep it simple stupid 

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return (a / gcd(a,b)) * b; }
ll extended_gcd(ll a, ll b, ll &x, ll &y) {
    if (b == 0) { x = 1; y = 0; return a; }
    ll xx, yy;
    ll res = extended_gcd(b, a%b, xx, yy); x = yy; y = xx - yy * (a / b);
    return res;
}

// const ll sz = 1e5 + 5;
// vector<ll> fac(sz, 1);

// ll nCr(ll n, ll r) {
//     return ( ( ( (fac[n] * powmod(fac[n-r], mod-2)) % mod ) * powmod(fac[r], mod-2) ) % mod );
// }

// * ALways PASS arrays, strings etc to functions BY REFERENCE

// const ll sz = 1e6 + 6;
// vector<bool> p(sz, true);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // for (int i = 1; i < sz; i++)
    //     fac[i] = (fac[i-1] * i) % mod;
    
    // p[0] = p[1] = false;
    // for (ll i = 2; i*i <= sz; i++) if (p[i]) {
    //     for (ll j = i*i; j <= sz; j += i)
    //         p[j] = false;
    // }
    
    int t = 1;
    // cin >> t;

    while(t--) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        ll res = max({a*c, a*d, b*c, b*d});
        cout << res << endl;
    }
    
	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using vec_i = std::vector<int>;
using vec_ll = std::vector<ll>;
using vec_ld = std::vector<ld>;

#define in(i) int i; cin >> i
#define in_ll(i) ll i; cin >> i
#define in_ld(i) ll i; cin >> i
#define in_c(c) char c; cin >> c
#define in_str(s) std::string s; cin >> s

#define vec_in(v, n)    auto v=vec_i(n); for(auto &x:v){cin>>x;}
#define vec_in_ll(v, n) auto v=vec_ll(n);for(auto &x:v){cin>>x;}
#define vec_in_ld(v, n) auto v=vec_ld(n);for(auto &x:v){cin>>x;}

#define print(x)   cout << (x)
#define println(x) cout << (x) << "\n"

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

using namespace std;
int main () {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    in(N);
    vec_in(v, N);
    int all = v[N - 1];
    rep(i, N - 1) {
        all ^= v[i];
    }
    rep(i, N) {
        println(v[i] ^ all);
    }
    return 0;
}


Measured memory_bytes: 3932
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, a[1009], c[1009]; bool vis[1009];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (a[i] > a[j]) c[i]++;
		}
	}
	int z = *min_element(a, a + n);
	int ret = 0;
	for (int i = 0; i < n; i++) {
		if (vis[i]) continue;
		int pos = i, m = 1012345678, cnt = 0;
		while (!vis[pos]) {
			vis[pos] = true;
			ret += a[pos];
			m = min(m, a[pos]);
			pos = c[pos];
			cnt++;
		}
		ret += min(m * (cnt - 2), z * (cnt + 1) + m);
	}
	printf("%d\n", ret);
	return 0;
}

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


int main() {
  int N, M, X;
  cin >> N >> M >> X;

  vector<int> C(N);
  vector< vector<int> > A(N, vector<int>(M, 0));
  rep(i, N) {
    cin >> C[i];
    rep(j, M) cin >> A[i][j];
  }

  ll ans = 100000000;
  for (int bits = 1; bits < (1 << N); bits++) {  // 2^3 の全ての場合を探索する
    vector<int> skills(M, 0);
    ll cost = 0;
    for (int i = 0; i < N; i++) {
      int mask = 1 << i;
      if (bits & mask) {  // i番目のbitが立っていれば加算する
        cost += C[i];
        rep(j, M) skills[j] += A[i][j];
      }
    }
    bool ok = true;
    rep(j, M) if (skills[j] < X) ok = false;
    if (ok) ans = min(ans, cost);
  }

  if (ans == 100000000) ans = -1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

void dump(vector<ll> &a){
    for(ll e : a){
        cout << e << " ";
    }
    cout << endl;
}
int main()
{
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n),f(n);
    repi(i,n,0)cin >> a[i];
    repi(i,n,0)cin >> f[i];
    sort(a.begin(),a.end());
    sort(f.rbegin(),f.rend());
    ll l = -1,r = 1e12;
    while(l + 1 < r){
        ll c = (l + r) / 2;
        ll sum = 0;
        repi(i,n,0)sum += max(0ll, (a[i] - c/f[i]));
        if(sum <= k)r = c;
        else l = c;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <cmath>
#include <string.h>
#include <string>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
int a,s,f=0;
int d=0;
cin>>a>>s>>d;
for(int z=0;z<10;z++){
    d=(a*d)-s;
    cout<<d<<endl;
}

    return 0;
}


Measured memory_bytes: 256
import sys

a = [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]
K = int(sys.stdin.readline().strip())
print(a[K-1])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, a[200010];
bool bl[200010];
vector<int> ans;

signed main(){
	cin >> n;
	rep(i, n)cin >> a[i];
	for (int i = n; i > 0; i--) {
		int cnt = 0;
		for (int j = i * 2; j <= n; j += i) {
			if (bl[j])cnt++;
		}
		if (cnt % 2 != a[i - 1]) {
			ans.push_back(i);
			bl[i] = true;
		}
	}
	cout << ans.size() << endl;
	rep(i, ans.size()) {
		if (i != ans.size() - 1)cout << ans[i] << " ";
		else cout << ans[i] << endl;
	}
}

Measured memory_bytes: 3700
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    string L;
    cin >> L;
    int N = L.size();
    ll res = 0, cnt = 0;
    REP(i, N) {
        if (L[i] == '1') {
            res += modpow(2, cnt, MOD) * modpow(3, N - i - 1, MOD);
            res %= MOD;
            cnt++;
        }
    }
    res += modpow(2, cnt, MOD);
    res %= MOD;
    cout << res << endl;
    return 0;
}


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

int main(){
    int n; cin >> n;
    pair<string, int> p[n];
    for(int i = 0; i < n; i++) {
        string music; int time; cin >> music >> time;
        p[i] = make_pair(music, time);
    }
    string t; cin >> t;
    int ans = 0;
    bool sleep = false;
    for(int i = 0; i < n; i++) {
        if(p[i].first == t){
            sleep = true;
            continue;
        }
        if(sleep){
            ans += p[i].second;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math

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

def decompose(n):
	result = []
	
	i = 2
	n2 = math.floor(math.sqrt(n)) + 1
	while i <= n2:
		if n % i == 0:
			result.append(i)
			n //= i
			n2 = math.floor(math.sqrt(n)) + 1
		else:
			i += 1
	if n > 1:
		result.append(n)
	return result

def calc_gcm(a, b):
	if a > b:
		r = a % b
		a = r
	
	while a > 0:
		r = b % a
		b = a
		a = r
	
	return b

primes = decompose(calc_gcm(A, B))
count = 1
prev = 0
for p in primes:
	if prev != p:
		count += 1
	prev = p
print(count)


Measured memory_bytes: 3064
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using StructLayoutAttribute = System.Runtime.InteropServices.StructLayoutAttribute;
using FieldOffsetAttribute = System.Runtime.InteropServices.FieldOffsetAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var xyh = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        for (int cx = 0; cx <= 100; cx++)
        {
            for (int cy = 0; cy <= 100; cy++)
            {
                int hmax = int.MaxValue;
                int h = -1;
                foreach (var item in xyh)
                {
                    var dist = Abs(item[0] - cx) + Abs(item[1] - cy);
                    if(item[2] == 0) hmax = Min(hmax, dist);
                    else
                    {
                        if (h == -1) h = dist + item[2];
                        else if (h != dist + item[2]) goto end;
                    }
                }
                if (h > hmax || hmax < 1) goto end;
                if (h == -1) h = hmax;
                Console.WriteLine($"{cx} {cy} {h}");
                return;
            end:;
            }
        }
    }
}


Measured memory_bytes: 13524
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()


int main() {
	ll N, T;
	cin >> N >> T;
	vll c(N), t(N);
	rep(i, N) cin >> c[i] >> t[i];

	ll ans = INF;
	rep(i, N) if (t[i] <= T) ans = min(ans, c[i]);
	cout << (ans == INF ? "TLE" : to_string(ans)) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int n, k;
  double a[200000], ans = 0.0, sum = 0.0;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%lf", &a[i]);
  }
  for (int i = 0; i < k; i++) {
    sum += a[i];
  }
  ans = sum;
  for (int i = k; i < n; i++) {
    sum += a[i];
    sum -= a[i - k];
    ans = max(ans, sum);
  }
  ans += k;
  printf("%f\n", ans / 2);
}

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

int main() {
    lli X, K, D;
    cin >> X >> K >> D;

    if (X < 0LL) X = -X;

    lli t = X / D;
    X -= D * min(K, t);
    K -= min(K, t);
    if (K % 2) X -= D;

    cout << llabs(X) << "\n";
    return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, mn = -1e18 - 1, mx = 1e18 + 1;
  scanf("%lld%lld", &n, &k);
  ll a[n];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  sort(a, a + n);
  while(mx - mn != 1) {
    ll now = (mn + mx) / 2, cnt = 0;
    for(i = 0; i < n; ++i) {
      ll tmp = 0;
      if(a[i] < 0) {
        if(lower_bound(a, a + n, (now % a[i] && now < 0) ? now / a[i] + 1 : now / a[i]) > a + i) cnt += n - (lower_bound(a, a + n, (now % a[i] && now < 0) ? now / a[i] + 1 : now / a[i]) - a);
        else cnt += n - i - 1;
      } else if(a[i] == 0) {
        if(now >= 0) cnt += n - i - 1;
      } else {
        if(upper_bound(a, a + n, (now % a[i] && now < 0) ? now / a[i] - 1 : now / a[i]) > a + i) cnt += upper_bound(a, a + n, (now % a[i] && now < 0) ? now / a[i] - 1 : now / a[i]) - a - i - 1;
      }
    }
    if(k <= cnt) mx = now;
    else mn = now;
  }
  printf("%lld", mx);
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

int f(int l, int r){
    switch(r-l){
        case 1: return 2;
        case 2: return 3;
        case 3: return 5;
        case 4: return 8;
        case 5: return 13;
        case 6: return 21;
        case 7: return 34;
        default: return 1;
    }
    return 1;
}

int main(void){
    Cin(int, h);
    Cin(int, w);
    Cin(int, k);
    vector<vector<ll>> dp(h+1, vector<ll>(w+1, 0));
    dp[0][1] = 1;
    
    for(int i = 1; i <= h; i ++){
        for(int j = 1; j <= w; j ++){
            dp[i][j]
                = ((j > 1) ? (dp[i-1][j-1] * f(1, j-2) * f(j+1, w)) % P : 0)
                + (dp[i-1][j] * f(1, j-1) * f(j+1, w))
                + ((j < w) ? (dp[i-1][j+1] * f(1, j-1) * f(j+2, w)) % P : 0);
            dp[i][j] %= P;
        }
    }
    Cout(dp[h][k]);
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

ll abs(ll a) {
  return a > 0 ? a : -a;
}

ll min(ll a, ll b) {
  return a < b ? a : b;
}

int main(void) {
  ll i, j, k, n;
  scanf("%lld", &n);
  ll dp[n], h[n];
  for(i = 0; i < n; ++i) scanf("%lld", &h[i]);
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  for(i = 2; i < n; ++i) dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2]);
  printf("%lld", dp[n - 1]);
  return 0;
}

Measured memory_bytes: 1664
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 3e18
#define ULMAX 18446744073709551615
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define deb1(x) cout << #x <<"="<< x <<endl;
#define deb2(x,y) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<endl;
#define deb3(x,y,z) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<<endl;
#define deb4(x,y,z,a) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<< ", "<<#a <<"="<<a << endl;
#define debarr(x) cout << #x<<"::"<<endl;for(int i : x){cout << i <<" ";} cout <<endl;

inline int add(int a, int b){a = (a+b); if(a>=mod)a-=mod; return a;}
inline int sub(int a, int b){a = a-b; if(a<0)a+=mod; return a;}
inline int mul(int a, int b){a = (a*b)%mod; return a;}



void mymain(){
  int n,m,x;
  cin >> n >> m >> x;
  vi cost(n);
  vector<vi> mat(n,vi(m));
  for(int i=0;i<n;i++){
        cin >> cost[i];
        for(int j=0;j<m;j++)
            cin >> mat[i][j];
  }
  int ans = 1e18;
  for(int i = 1;i < (1<<n) ;i++){
        int temp = 0;
        //deb(i);
        map<int,int> algo;
        for(int j =0;j<n;j++){
            if((1<<j)&i){
                //deb2(i,j)
                temp += cost[j];
                for(int k=0;k<m;k++)
                    algo[k] += mat[j][k];
            }
        }
        //deb3(i,temp,ans)
        bool ok = true;
        for(auto it : algo){
            ////deb4(it.F,it.S,ok,x)
            if(it.S < x)
                ok = false;
        }

        if(ok){
            ans = min(temp,ans);
        }
  }

  if(ans == 1e18) ans = -1;
  cout <<ans <<endl;
}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
//cin>>t;

for(int tt=0;tt<t;tt++){
   //cout << "Case #" << tt+1 <<": ";
   mymain();
}
return 0;
}
/*

*/


Measured memory_bytes: 3668
n=int(input())
ab=[tuple(map(int,input().split())) for _ in [0]*n]
cd=[tuple(map(int,input().split())) for _ in [0]*n]

ab.sort(reverse=True)
cd.sort(key=lambda x:x[1])

cnt=0

for a,b in ab:
    flag=False
    for c,d in cd:
        if a<c and b<d:
            cnt+=1
            flag=True
            break
    if flag==True:
        cd.remove((c,d))
print(cnt)

Measured memory_bytes: 3064
eval"N,*D="+`dd`.split*?,
A=[0]*N
m=998244353
f=->a,b{b>0?a**b[0]*f[a,b/2]**2%m:1}
D.map{|d|A[d]+=1}
s=q=1
A.map{|a|s=s*f[q,q=a]%m}
p A[0]==1&&D[0]==0?s:0

Measured memory_bytes: 23816
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(0, a + 1):
    for j in range(0, b + 1):
        for k in range(0, c + 1):
            if i * 500 + j * 100 + k * 50 == x:
                count += 1
print(count)

Measured memory_bytes: 9128
# include <iostream>
#include <math.h>
#include <string>
#include <vector>

# include <map>

using namespace std;

typedef long long ll;

int main() {
	int x;
	cin >> x;
	if (x) {
		cout << 0;
	}
	else {
		cout << 1;
	}
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];

  ll ans = (n-1)/(k-1); //n <= k+(k-1)(g-1)
  if((n-1)%(k-1)!=0) ans++;

  cout << ans << endl;
}


Measured memory_bytes: 640