akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define            ll              long long
#define            pb              push_back
#define            mp              make_pair
#define            loop(i,a,n)     for(int i=a;i<n;++i)
#define            clr(x)          memset(x,0,sizeof x)
#define            min3(a,b,c)     min(a,min(b,c))
#define            max3(a,b,c)     max(a,max(b,c))
#define            min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define            max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define            fast            ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define            pii             pair<int,int>
#define            pll             pair<ll,ll>
#define            pli             pair<ll,int>
#define            pil             pair<int,ll>
#define            FF              first
#define            SS              second
#define            PI              acos(-1.0)
#define            bug             cout<<"ok"<<endl;

using namespace std;
using namespace __gnu_pbds;

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

const int MOD = 1e9 + 7;
const ll MX= 1e9;
const ll INF = 1e9;
int n,we;

vector<int>w(105),v(105);
ll dp[109][100005];

ll fun(int id,int wt)
{
    if(id==n)return 0;
    if(dp[id][wt]!=-1)return dp[id][wt];

    ll ans=fun(id+1,wt);
    if(w[id]+wt<=we)
        ans=max(ans,fun(id+1,wt+w[id])+v[id]);
    return dp[id][wt]=ans;
}
main()
{
    memset(dp,-1,sizeof dp);
    cin>>n>>we;
    loop(i,0,n)
    {
        cin>>w[i]>>v[i];
    }

    cout<<fun(0,0)<<endl;

}


Measured memory_bytes: 85376
# coding: utf-8

import sys
import math
import collections
import itertools
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
MOD = 10 **9 + 7

# N = int(input())
# S = input()
N, K = map(int, input().split())
# 横
A = [int(x) for x in input().split()]
# 縦
# A = [int(input()) for _ in range(N)]
# 多次元
# L = [[int(x) for x in input().split()] for _ in range(N)]

ans = 0
tmp = 0

for i, a in enumerate(A) :
    for aa in range(i + 1, N) :
        if a > A[aa] :
            ans += 1

for a in A :
    for aa in A :
        if a > aa :
            tmp += 1

ans = (ans * K) % MOD
ans += (tmp * ((K * (K - 1)) // 2) % MOD)
ans %= MOD

print(ans)


Measured memory_bytes: 41708
#include<bits/stdc++.h>
// use gp_hash_table<int,int,custom_hash> m;
// in place of map
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
// This custom_hash is for unordered_map 
// use map<int, int, custom_hash> mp;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
    //	freopen("input.txt", "r", stdin);
  //  	freopen("output.txt", "w", stdout);
//
	//#endif
	ll a,b,k;
	cin>>a>>b>>k;
	if(a >= k)a-=k;
	else {
		k -= a;
		a=0;
		b -= k;
		b = max(b,0ll);
	}
	cout<<a<<" "<<b;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

// const int mod = 1000000007;
const int mod = 998244353;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

class Main {
    int N, K;
    vector<ll> L, R;
    void input() {
        cin >> N >> K;
        L.resize(K);
        R.resize(K);
        REP(i, K) { cin >> L[i] >> R[i]; }
    }
    void output() {
        vector<mint> dp(N + 1);
        dp[1] = 1;
        dp[2] = -1;
        FOR(i, 1, N) {
            REP(j, K) {
                if (i + L[j] <= N) { dp[i + L[j]] += dp[i]; }
                if (i + R[j] + 1 <= N) { dp[i + R[j] + 1] -= dp[i]; }
            }
            dp[i + 1] += dp[i];
        }
        cout << dp[N] << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 4792
#include <stdio.h>

int main(void) {
	int n, flg=0;
	int fact[20];
	char buf[256];
		
	for (int i=0; i<20; i++)  fact[i]=0;
	fact[0]=1;
	
	fgets(buf, sizeof(buf), stdin);
	sscanf(buf, "%d", &n);
	
	if (n<1 || n>20) return 1;
	
	
	for (int i=2; i<=n; i++) {
		for (int j=19; j>=0; j--) {
			fact[j] *= i;
			for (int k=0; k<20; k++) {
				if (fact[k]/10 >= 1) {
					fact[k+1] += fact[k]/10;
					fact[k] = fact[k]%10;
				}
			}
		}
	}
	
	for (int i=19; i>=0; i--) {
		if (flg==0 && fact[i]==0)  continue;
		flg=1;
		printf("%d", fact[i]);
	}
	
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 1036
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll INF = 1LL << 60;

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

    ll n, x;
    cin >> n >> x;

    ll sm[n+1];
    sm[0] = 0;
    for (int i = 1; i <= n; i++) {
        ll a;
        cin >> a;
        sm[i] = sm[i-1] + a;
    }

    ll ans = INF;
    for (ll i = 1; i <= n; i++) {
        // i回往復する
        ll cost = (n + i) * x;
        ll pos = n;
        cost += sm[pos] * 5;
        pos -= i * 2;
        while (pos > 0) {
            cost += sm[pos] * 2;
            pos -= i;
            if (cost < 0) {
                cost = INF;
                break;
            }
        }
        ans = min(ans, cost);
    }

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

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#define inf 1000000000

using namespace std;

struct State{
	vector<int> vec;
	State(){
		vec.resize(10);
	}
	bool operator<(const State &obj)const{
		int sum = 0, sum2 = 0;
		for(int i = 0; i < vec.size(); i++) sum += vec[i];
		for(int i = 0; i < obj.vec.size(); i++) sum2 += obj.vec[i];
		if(sum < sum2) return true;
		if(sum > sum2) return false;
		return vec < obj.vec;
	}
};

int n, m;
int a[10005];
int c[] = {inf, 2, 5, 5, 4, 5, 6, 3, 7, 6};
State dp[10005];

int main(void)
{
	cin >> n >> m;
	for(int i = 0; i < m; i++) cin >> a[i];
	sort(a, a+m);
	reverse(a, a+m);
	
	for(int i = 1; i <= n; i++) dp[i].vec.front() = -inf;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			State tmp = dp[i];
			tmp.vec[j]++;
			if(i+c[a[j]] <= n) dp[i+c[a[j]]] = max(dp[i+c[a[j]]], tmp);
		}
	}
	
	State ans = dp[n];
	for(int i = 0; i < m; i++){
		for(int j = 0; j < ans.vec[i]; j++) cout << a[i];
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define inf 2e9
#define f first
#define s second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

ll lcm(ll a, ll b){
    return a*b/gcd(a,b);
}


int main (){
    int n;
    cin >> n;
    vector<int> w(n);
    int wa = 0;
    Rep(i,n){
        cin >> w[i];
        wa += w[i];
    }
    int tmp = 0;
    int ans = inf;
    Rep(i,n){
        tmp += w[i];
        ans = min(ans,abs(wa-2*tmp));
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
        public static void main(String[] args){
                try(Scanner sc = new Scanner(System.in)){
                        int x = sc.nextInt(), y = sc.nextInt();
                        if((x==2&& y == 2)||(check(x)&&check(y))||(x!=2&&y!=2&&!check(x)&&!check(y)) ){
                                System.out.println("Yes");
                        }else{
                                System.out.println("No");
                        }
                }
        }
        private static boolean check(int a){
                if(a==4||a==6||a==9||a==11){
                        return true;
                }else{
                        return false;
                }
        }
}


Measured memory_bytes: 23636
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

s = input()
K = int(input())

N = len(s)

ans = []
for i in range(1,K+1):
    for j in range(N-i+1):
        ans.append(s[j:j+i])

ans = list(set(ans))
ans.sort()
print(ans[K-1])

Measured memory_bytes: 13988
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main() {
  int a;
  int b;
  cin >> a >> b;
  double r = (a + b) / 2.0;
  double m = r / 2;
  if (m > 0.0) {
    r = ceil(r);
  } 
  cout << (int) r << endl;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String fm[] = sc.nextLine().split("\\+|=");
			int init = 0;
			if (fm[0].charAt(0) == 'X' && fm[0].length() > 1
					|| fm[1].charAt(0) == 'X' && fm[1].length() > 1
					|| fm[2].charAt(0) == 'X' && fm[2].length() > 1) {
				init = 1;
			}
			for (int i = init; i < 10; i++) {
				if (((new BigInteger(fm[0].replace('X', (char) (i + '0'))))
						.add(new BigInteger(fm[1]
								.replace('X', (char) (i + '0')))))
						.equals(new BigInteger((fm[2].replace('X',
								(char) (i + '0')))))) {
					System.out.println(i);
					break;
				} else if (i == 9)
					System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


vector<P> primes(ll n){
    vector<P> ans;
    for(ll i=2; i*i<=n; i++){
        int cnt = 0;
        if(n%i!=0)continue;
        while(n%i==0){
            n/=i;
            cnt++;
        }
        ans.push_back(P(i,cnt));
    }
    if(n!=1)ans.push_back(P(n,1));
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    auto pr = primes(n);
    ll ans = 0;

    for(P p:pr){
        for(int cnt = 1; p.second>=cnt; cnt++){
            p.second-=cnt;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	string s,t;
	cin>>s>>t;
	cout<<t+s<<endl;
	return 0;
}



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

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < int(k); i++ )
#define FOR(i, a, b) for(int i = (a); i <= int(b); i++)
#define TRAV(a, e) for(auto x : e)

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define INF (int)INT_MAX
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long L;
typedef unsigned long UL;
typedef long long LL;
typedef unsigned long long ULL;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void solve(__attribute__((unused)) int tc = 0) {
    int n, k;
    cin >> n >> k;
    if (k == 1) cout << 0 << endl;
    else cout << n - (k - 1) - 1 << endl;
    return;
}

int main() {
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    /*int TC;
      cin >> TC;
      REP(tc, TC) {
      solve(tc);
      }*/
    solve();
#ifdef TIME
    cout << "Execution time(second) : " << int(clock() * 1000.0 / CLOCKS_PER_SEC) << " ms" << endl;
#endif
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }



signed main()
{
	int x, t;
	cin >> x >> t;
	cout << max(0LL, x - t) << endl;
}



Measured memory_bytes: 3628
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val b = IntArray(n + 1)
    (1 until n).forEach { i -> b[i] = scanner.nextInt() }
    b[0] = b[1]
    b[n] = b[n - 1]

    val ret = (1..n).map { i ->
        Math.min(b[i - 1], b[i])
    }.sum()


    println(ret)
}

Measured memory_bytes: 31396
#include<cmath>
#include<stack>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int gcd(int x,int y){
    return y?gcd(y,x%y):x;
}

int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9')f|=c=='-',c=getchar();
    while(c>='0'&&c<='9')x=x*10+(c^48),c=getchar();
    return f?-x:x;
}

#define MAXN 100000
char str[MAXN+5];
int L[MAXN+5],R[MAXN+5];

int cnt[MAXN+5];

int main(){
    scanf("%s",str+1);
    int N=strlen(str+1);
    for(int i=1;i<=N;i++){
        if(str[i]=='L')
            L[i]=str[i-1]=='R'?i-1:L[i-1];
    }
    for(int i=N;i>=1;i--){
        if(str[i]=='R')
            R[i]=str[i+1]=='L'?i+1:R[i+1];
    }
    for(int i=1;i<=N;i++){
        if(str[i]=='L'){
            if((i-L[i])%2==0)
                cnt[L[i]]++;
            else
                cnt[L[i]+1]++;
        }
        else{
            if((R[i]-i)%2==0)
                cnt[R[i]]++;
            else
                cnt[R[i]-1]++;
        }
    }
    for(int i=1;i<=N;i++)
        printf("%d ",cnt[i]);
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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;}

int main(){
    int n,k;cin>>n>>k;
    vi a(n);
    rep(i,n)cin>>a[i];
        int ANS=0;
        for(int i=min(n,k);i>=0;--i){
            for(int j=0;j<i;++j){
                int ans=0;
                priority_queue< int,vector<int>,greater<int> > q;
                for(int k=0;k<i-j;++k){ans+=a[k];q.push(a[k]);}
                for(int k=n-1;k>=n-j;--k){ans+=a[k];q.push(a[k]);}
                int cnt=k-i;
                while(cnt>0&&!q.empty()){
                    int x=q.top();
                    q.pop();
                    if(x>=0)break;
                    ans-=x;
                    cnt--;
                }
                if(ANS<ans)ANS=ans;
            }
        }
        cout<<ANS<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define int long long
const int N=2010,mod=924844033;
int n,k,g[N<<1],f[N<<1][N][2],cnt,fac[N],ans;

signed main(){
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=k;i++){
        for(int j=i;j<=n;j+=k)g[++cnt]=(j==i);
        for(int j=i;j<=n;j+=k)g[++cnt]=(j==i);
    }
    f[0][0][0]=fac[0]=1;
    for(int i=1;i<=n;i++)fac[i]=1LL*i*fac[i-1]%mod;
    for(int i=0;i<n*2;i++)
        for(int j=0;j<=min(i,n);j++){
            f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%mod;
            if(!g[i+1])f[i+1][j+1][1]=f[i][j][0];
        }
    for(int i=0;i<=n;i++){
        int tmp=1LL*(f[n<<1][i][0]+f[n<<1][i][1])*fac[n-i]%mod;
        ans=(mod+(ans+(i&1?-1:1)*tmp)%mod)%mod;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 124160
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;
char s[100050];
int w;
int main(){
	scanf("%s",s+1);
	scanf("%d",&w);
	int len=strlen(s+1);
	for(int i=1;i<=len;i+=w){
		printf("%c",s[i]);
	}
	printf("\n");
}

Measured memory_bytes: 256
import Data.List

main = do
  [_,x] <- map read . words <$> getLine
  as <- map read . words <$> getLine
  print (candies x as)

candies x = fst . foldl' (eat x) (0,0)

eat x (acc,rest) a = let n = max 0 (rest+a-x) in (acc+n, a-n)

Measured memory_bytes: 94588
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <cmath>
#include <tuple>
using namespace std;
#define fio ios::sync_with_stdio(0),cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
map<vector<int>,int> mp;
ll mod=1e9+7;
int N;
ll A[100005];
ll facL[100005],facR[100005],P[100005],psum[100005],cnt[100005],ans;
int main(){
    scanf("%d",&N);
    for(int i=1;i<=N;i++){
    	scanf("%lld",A+i);
    }
    facL[0]=facR[N+1]=1;
    for(int i=1;i<=N;i++)
    	facL[i]=facL[i-1]*i%mod;
    for(int i=N;i>=1;i--)
    	facR[i]=facR[i+1]*i%mod;
    for(int i=2;i<=N;i++){
    	P[i]=facL[i-1]*facR[i+1]%mod;
    	psum[i]=(psum[i-1]+P[i])%mod;
    }
    for(int i=1;i<=N;i++){
    	cnt[i]=(psum[N-i+1]+psum[i]+facL[N])%mod;
    	ans+=cnt[i]*A[i]%mod;
    	ans%=mod;
    }
    printf("%lld",ans);

}

Measured memory_bytes: 4992
use std::io;
use std::cmp;
use io_ext::Reader;

fn main() {
    let stdin = io::stdin();
    let mut r = Reader::new(io::BufReader::new(stdin.lock()));
    let (a, b): (usize, usize) = {
        let mut i = r.read_line().split_whitespace().map(|s| s.parse().unwrap());
        (i.next().unwrap(), i.next().unwrap())
    };

    if a < 10 && b < 10 {
        println!("{}", a * b);
    } else {
        println!("{}", -1);
    }
}

/// Extension of io module.
pub mod io_ext {
    use std::io::BufRead;

    pub struct Reader<R> {
        buf: String,
        inner: R,
    }

    impl<R> Reader<R> {
        #[inline]
        pub fn new(inner: R) -> Self {
            Reader { buf: String::new(), inner: inner }
        }

        #[inline]
        pub fn into_inner(self) -> R {
            self.inner
        }
    }

    impl<R: BufRead> Reader<R> {
        #[allow(deprecated)]
        #[inline]
        pub fn read_line(&mut self) -> &str {
            self.buf.clear();
            self.inner.read_line(&mut self.buf).unwrap_or_else(|e| panic!("{}", e));
            self.buf.trim_right()
        }
    }
}

/// Module supporting to parse strings.
pub mod parse {
    use std::str::FromStr;
    use std::borrow::Borrow;

    pub trait ParseNext: Iterator {
        fn parse_next<F: FromStr>(&mut self) -> F;
    }

    impl<'a, S: Borrow<str>, I: Iterator<Item=S>> ParseNext for I {
        fn parse_next<F: FromStr>(&mut self) -> F {
            if let Some(s) = self.next() {
                match s.borrow().parse() {
                    Ok(x) => x,
                    Err(_) => panic!("provided string cannot be parsed")
                }
            } else {
                panic!("iterator has no next element")
            }
        }
    }
}


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

int main() {
  int a,b,t;
  cin >> a >> b >> t;
  int k=(t+0.5)/a;
  cout << k*b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

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

int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  --a, --b, --c, --d;
  int ans = 1000000000;
  rep (i, n) {
    if (i == 0) continue;
    ans = min(ans, (int)(abs(a / i - b / i) + abs(a % i - b % i) + abs(c / i - d / i) + abs(c % i - d % i)));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1164
import logging

logging.basicConfig(level=logging.INFO)
logging.info('info')


def main():
    H, W, K=map(int, input().split())
    C_ij=[input() for i in range(H)]

    logging.info("hello")

    blacks = 0
    ans = 0

    for i in range(2 ** H):
        for j in range(2 ** W):
            blacks = 0
            for i_2 in range(H):
                for j_2 in range(W):
                    if ((i >> i_2) & 1) and ((j >> j_2) & 1):
                        if C_ij[i_2][j_2] == "#":
                            blacks += 1
            if blacks == K:
                ans += 1
    
    print(ans)
                   

if __name__ == "__main__":
    main()

Measured memory_bytes: 10784
program ABC157B
    implicit none
    integer(8)::A(3,3),C(3,3),N,i,j,k,b,flg=0
    read*,A,N
    C=0
    do k=1,N
        read*,b
        do i=1,3
            do j=1,3
                if(A(j,i)==b)C(j,i)=1
            end do
        end do
    end do

    do i=1,3
        if(sum(C(i,:))==3.or.sum(C(:,i))==3)flg=1
    end do
    if(C(1,1)+C(2,2)+C(3,3)==3.or.C(1,3)+C(2,2)+C(3,1)==3)flg=1
    if(flg==1)print'(A)',"Yes"
    if(flg==0)print'(A)',"No"
end program ABC157B

Measured memory_bytes: 2784
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int n;
    cin>>n;
    ll ans=0;
    rep(i,1,n) rep(j,1,n) rep(k,1,n){
        ans+=__gcd(__gcd(i,j),k);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int s = sc.nextInt();
			int a = s / 100;
			int b = s % 100;

			if ((a == 0 && b == 0) || (a == 0 && b > 12) || (a > 12 && b == 0) || (a > 12 && b > 12)) {
				System.out.println("NA");
			} else if ((a == 0 || a > 12) && 1 <= b && b <= 12) {
				System.out.println("YYMM");
			} else if (1 <= a && a <= 12 && (b == 0 || b > 12)) {
				System.out.println("MMYY");
			} else if (1 <= a && a <= 12 && 1 <= b && b <= 12) {
				System.out.println("AMBIGUOUS");
			}
		}
	}
}

Measured memory_bytes: 21972
from collections import deque
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

tree = [[] for _ in range(N+1)]

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

ans = 1
went = [0] * (N+1)
go = deque()
go.append([1, -2])

while len(go) > 0:
    now, brother = go.popleft()
    went[now] = 1
    ans *= (K-2-brother)
    ans %= MOD

    c = 0 if now != 1 else -1
    for b in tree[now]:
        if went[b] == 0:
            go.appendleft([b, c])
            c += 1

    if ans == 0:
        break

print(ans)





Measured memory_bytes: 36528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            String[] line = S.Split(' ');
            int A = int.Parse(line[0]);
            int B = int.Parse(line[1]);
            int socket = 1;
            int ans = 0;
            while (true)
            {
                if (socket >= B)
                {
                    break;
                }
                socket--;
                socket = socket + A;
                ans++;

            }
            Console.WriteLine(ans);

        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define double long double
using namespace std;
const ll inf = 1000000000000000000;

ll ns, nt, mun = inf, kol;
string s, t;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    cin >> t;
    ns = (ll)s.size();
    nt = (ll)t.size();
    for (ll i = 0; i < ns - nt + 1; ++i) {
        kol = 0;
        for (ll j = i; j < i + nt; ++j)
            kol += (s[j] != t[j - i]);
        mun = min(mun, kol);
    }
    cout << mun;
    return 0;
}


Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
# A

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = int(input())

a = n // 1000
if n % 1000 > 0 :
    a = a + 1

# print(a)
print(a*1000 - n)


Measured memory_bytes: 65212
import scala.io.StdIn._

trait Solver extends App {
  implicit class Pipe[T](x: T) {
    def |>[U](f: T => U) = f(x)
  }
}

object Main extends Solver {
  readLine().split(" ").map(_.toInt).product |> { x =>
    if(x % 2 == 0) println("Even")
    else println("Odd")
  }
}

Measured memory_bytes: 25408
if __name__ == "__main__":
    A, B, C = list(map(int, input().split()))
    K = int(input())

for i in range(K):
    if B >= C:
        C = C * 2
    elif A >= B:
        B = B * 2
    else:
        C = C * 2

if A < B and B < C:
    print("Yes")
else:
    print("No")

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

long long int K;
string s;

int main(){
    cin >> s >> K;
    for(auto i : s){
        --K;
        if(i != '1' || K == 0){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    IOS
    int a,b;
    cin>>a>>b;
    for(int c=1;c<=3;c++)
    {
        int x = a*b*c;
        if(x%2)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

//res[i] = n : iがn個
std::map<long long, int> PrimeFactorDecomposition(long long num) {
    std::map<long long, int> res;
    for (long long i = 2; i * i <= num; i++) {
        int cnt = 0;
        while(num % i == 0) cnt++, num /= i;
        if (cnt) res[i] = cnt;
    }
    if (num != 1) res[num] = 1;
    return res;
}

int N;
map<long long, LL> pfs;

int main(void) {
    cin >> N;
    FOR(i, 1, N + 1) {
        auto mp = PrimeFactorDecomposition(i);
        FORE(e, mp) pfs[e.first] += e.second;
    }
    LL ans = 1;
    FORE(e, pfs) (ans *= e.second + 1) %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
import numpy as np
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n,m = MI()
num = [-1]*(n+1)
num[0] = 0
bool = True
for i in range(m):
    s,c = MI()
    if n != 1 and s == 1 and c == 0:
      bool = False
      break
    if num[s] == -1 or num[s] == c:
        num[s] = c
    else:
        bool = False
        break
if bool:
  for i in range(n+1):
    if num[i] == -1:
      num[i] = 0
    if n > 1 and num[1] == 0:
      num[1] = 1
  ans = num[1:]
  m = map(str, ans)
  print(''.join(m))
else:
    print(-1)


Measured memory_bytes: 27180
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};


int main(){
    CIN(N);
    I vec;
    LL ans = 0;
    REP(a,N){
        CIN(b);
        ans += b-1;
        vec.push_back(b);
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int N;
  int t[110000], x[110000], y[110000];
  std::cin >> N;
  t[0] = x[0] = y[0] = 0;
  for (int i = 0; i < N; ++i) std::cin >> t[i+1] >> x[i+1] >> y[i+1];

  bool can = true;
  for (int i = 0; i < N; ++i) {
    int dt = t[i+1] - t[i];
    int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if (dt < dist) can = false;
    if (dist % 2 != dt % 2) can = false;
  }

  if (can) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<string>
#include<cstdlib>
using namespace std;


struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;


	z = (Node *)malloc(sizeof(Node));

	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;

		}
		else {
			y->right = z;
		}
	}
}

Node* find(Node *x, int k) {

	while (x != NIL && k != x->key) {
		if (k < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	return x;
}

void inorder(Node *u) {
	if (u == NIL)return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node *u) {
	if (u == NIL)return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);

}

int main() {
	int n, i, x;
	string com;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> com;
		if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");

		}
		else if (com == "find") {
			scanf("%d", &x);
			Node* no=find(root, x);
			if (no == NIL) {
				printf("no\n");
			}
			else {
				printf("yes\n");
			}

		}
	}

	return 0;

}


Measured memory_bytes: 22032
class DisjointSet:
    def __init__(self, size):
        self.parent = list(range(size))
        self.rank = [0]*size
    
    def find(self, x):
        stack = []
        parent = self.parent
        while parent[x] != x:
            stack.append(x)
            x = parent[x]
        for y in stack:
            parent[y] = x
        return x

    def union(self, x, y):
        xr, yr = self.find(x), self.find(y)
        
        if self.rank[xr] > self.rank[yr]:
            self.parent[yr] = xr
        elif self.rank[xr] < self.rank[yr]:
            self.parent[xr] = yr
        elif xr != yr:
            self.parent[yr] = xr
            self.rank[xr] += 1


max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

def solve(points):
    N = len(points)
    XI = [0]*N
    YI = [0]*N

    for i,(x,y) in enumerate(points):
        XI[x] = i
        YI[y] = i

    ds = DisjointSet(N)

    offset = N
    y_max_connected = -1
    rep = -1
    for i in YI:
        x0,y0 = points[i]
        if x0 >= offset:
            continue

        t = y0
        for j in XI[x0+1:offset]:
            x,y = points[j]
            if y >= y0:
                ds.union(i,j)
                t = max2(t, y)
        offset = x0

        if y_max_connected >= y0:
            ds.union(rep, i)
            y_max_connected = max2(y_max_connected,t)
        else:
            y_max_connected = t
            rep = i
        # print(y0, y_max_connected)


    cnt = [0]*N
    for i in range(N):
        cnt[ds.find(i)] += 1

    return [cnt[ds.find(i)] for i in range(N)]

# import numpy as np
# from itertools import combinations
# def naive(points):
#     N = len(points)
#     grid = np.zeros((N,N), dtype=bool)
#     for x,y in points:
#         grid[x,y] = True
#     ds = DisjointSet(N)
#     for i,j in combinations(range(N),2):
#         x0,y0 = points[i]
#         x1,y1 = points[j]
#         if np.any(grid[max(x0,x1):,max(y0,y1):]) or np.any(grid[:min(x0,x1),:min(y0,y1)]):
#             ds.union(i,j)

#     cnt = [0]*N
#     for i in range(N):
#         cnt[ds.find(i)] += 1

#     return [cnt[ds.find(i)] for i in range(N)]

# from random import shuffle

if __name__ == '__main__':
    N = int(readline())
    m = map(lambda x: int(x)-1, read().split())

    points = tuple(zip(m,m))

    print(*solve(points), sep='\n')

    # N = 12

    # X = list(range(N))
    # for k in range(100000):
    #     if k % 10000:
    #         print(k)
    #     Y = list(range(N))
    #     shuffle(Y)
    #     points = [(x,y) for x,y in zip(X,Y)]
    #     r1,r2 = solve(points),naive(points)
    #     if r1 != r2:
    #         print(Y)
    #         print(r1)
    #         print(r2)
    #         break


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

int main() {
	// your code goes here
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1){
		c=c-b;
		if(c<=0){
			cout<<"Yes";
			break;
		}
		a=a-d;
		if(a<=0){
			cout<<"No";
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3624
#前計算
#素数のリスト作成
#必要パラメータ
# ------------------------------------------------------------------
MAX_N = 10 ** 5 + 10 #最低限必要な数 = 10 ** 5 + 1(今回の問題の場合)
# ------------------------------------------------------------------
def primes(n):
    import math
    count_lst = [0] * (n + 1)
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(math.sqrt(n)) + 1):
        if not is_prime[i]: #自分自身が素数出ない時
            count_lst[i] = count_lst[i - 1]
            continue
        #素数のとき
        if i != 2 and is_prime[(i + 1)//2]: #2017数である時
            count_lst[i] = count_lst[i - 1] + 1
        else: #2017数でない時
            count_lst[i] = count_lst[i - 1]
        #ある素数の倍数をすべて素数ではないとする
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    #これ以降は、新しい素数は出てこない
    for i in range(int(math.sqrt(n)) + 1, n + 1):
        if is_prime[i] and is_prime[(i + 1)//2]: #条件を満たす時
            count_lst[i] = count_lst[i - 1] + 1
        else:
            count_lst[i] = count_lst[i - 1]

    return count_lst
    # return [i for i in range(n + 1) if is_prime[i]]

count_lst = primes(MAX_N)
# print (count_lst[:20])
#答える部分
Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print (count_lst[r] - count_lst[l - 1]) #累積和の全体 - 累積和の不要部分    

Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;
#include <unordered_set>

int main(void){
    Cin(int, n, a, b);
    int x = 0, y = 0, z = 0;
    Rep(n){
        Cin(int, p);
        (p <= a ? x : p <= b ? y : z) ++;
    }
    Cout(min({x, y, z}));
}





Measured memory_bytes: 256
n = int(input())
x = map(float, input().strip().split())
y = map(float, input().strip().split())
d = tuple(map(lambda i,j: abs(i-j), x, y))
print(sum(d))
print(sum(map(pow, d, [2]*n))**0.5)
print(sum(map(pow, d, [3]*n))**(1/3))
print(max(d))

Measured memory_bytes: 7812
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
int a,b,x;
cin>>x>>a>>b;
if (a>=b)
{
    cout<<"delicious"<<endl;
}

else if (b-a<=x)
{
    cout<<"safe"<<endl;
}
else cout<<"dangerous"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

////////////////////////////////////////////////////////////////////

int main()
{
    ll N; cin >> N;
    
    FOR(n,1,5000){
        FOR(w,1,5000){
            ll H1 = N*n*w;
            ll H2 = 4*n*w-N*w-N*n;
            if(H2>0 and H1%H2==0 and H1/H2<=3500){
                cout << H1/H2 << " " << n << " " << w << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256