akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(i, v) for(auto i =  v.begin(); i !=  v.end(); ++i)
#define RFOR(i, v) for(auto i = v.rbegin(); i != v.rend(); ++i)

template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T> ostream & operator<<(ostream & os, const vector<T> & v) {
	os << "[";
	FOR(it, v) {
		if(it != v.begin()) { os << ", "; }
		os << *it;
	}
	os << "]";
	return os;
}
template<typename F, typename S> ostream & operator<<(ostream & os, const pair<F, S> & p) {
	os << "<" << p.FI << ", " << p.SE << ">";
	return os;
}

// ---- ----

const int MOD = 1000000007;
int n, a, b, c, d;
LL dp[2][1001];

LL ex_gcd(LL a, LL b, LL & x, LL & y) {
	LL d = a;
	if(b != 0) {
		d = ex_gcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else { x = 1, y = 0; }
	return d;
}

LL divmod(LL x, LL y) {
	LL inv, m;
	ex_gcd(y, MOD, inv, m);
	if(inv < 0) { inv += MOD; }
	return x * inv % MOD;
}

int main() {
	cin >> n >> a >> b >> c >> d;
	
	int to = 0, fr = 1;
	dp[to][0] = 1;
	incII(i, a, b) { LL e = 1; swap(to, fr); inc(k, n + 1) { dp[to][k] = dp[fr][k]; }
	incII(j, 1, d) {
		if(i * j > n) { break; }
		inc1(k, i) {
			(e *= i * (j - 1) + k) %= MOD;
			e = divmod(e, k);
		}
		e = divmod(e, j);
		
		LL f = e;
		if(c <= j) {
			int l = 1;
			decII(k, 0, n - i * j) {
				(dp[to][k + i * j] += dp[fr][k] * f) %= MOD;
				(f *= i * j + l) %= MOD;
				f = divmod(f, l);
				l++;
			}
		}
		// cout << i << ": "; inc(k, n + 1) { cout << dp[to][k] << " "; } cout << endl;
	}
	}
	
	cout << dp[to][n] << endl;
	
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

//# include <ext/pb_ds/assoc_container.hpp>
//# include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;
//	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	shuffle(permutation.begin(), permutation.end(), rng);



int main () {
	SpeedForce;
	cin >> s;
	n = sz(s);
	string t = s;
	reverse(every(t));
	if (s == t && s.substr(0, n / 2) == s.substr(n/2+1)) puts("Yes");
	else puts("No");
	return Accepted;
}

// B...a

Measured memory_bytes: 18688
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>

using namespace std;

int main() {
	string str;

	cin >> str;

	int cnt = 0;
	for (int i = 0; i < str.length(); i++) {
		if (str[i] == '1') {
			cnt++;
		}
	}

	cout << cnt << endl;





	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, M=-1;
  cin >> n;
  vl a(n);
  rep(i, n) {
    cin >> a[i];
    chmax(M, a[i]);
  }
  ll m=INF, num;
  rep(i, n) if(a[i]!=M && chmin(m, abs(a[i]*2-M))) num=i;
  cout << M << " " << a[num] << newl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N, cnt = 0;
    int p[50], pp[50];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> p[i];
        pp[i] = p[i];
    }
    sort(p, p + N);
    for(int i = 0; i < N; i++){
        if(p[i] != pp[i]){
            cnt++;
        }
    }
    if(cnt == 2 || cnt == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

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

int main(){
	
	int n; cin>>n;
	vector num(n,0);
	for(int i=0; i<n-1; i++){
		int a; cin>>a;
		num.at(--a)++;
	}
	for(auto &i:num) cout << i << endl;
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int h[3][3], n, b;
  bool a[100] = {};
  REP(i, 3) REP(j, 3) {
    cin >> h[j][i];
  }

  cin >> n;
  REP(i, n) {
    cin >> b;
    a[b] = true;
  }
  if (a[h[0][0]] && a[h[0][1]] && a[h[0][2]]
    || a[h[1][0]] && a[h[1][1]] && a[h[1][2]]
    || a[h[2][0]] && a[h[2][1]] && a[h[2][2]]
    || a[h[0][0]] && a[h[1][0]] && a[h[2][0]]
    || a[h[0][1]] && a[h[1][1]] && a[h[2][1]]
    || a[h[0][2]] && a[h[1][2]] && a[h[2][2]]
    || a[h[0][0]] && a[h[1][1]] && a[h[2][2]]
    || a[h[2][0]] && a[h[1][1]] && a[h[0][2]]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int A,B,x;
	scanf("%d %d",&A,&B);
	x=B/A;
	if(A==1){
		printf("%d\n",B);
	}
	else if(A>B||A==B){
		printf("%d\n",1);
	}
	else if(B%A!=0){
		printf("%d\n",x+1);
	}
	else{
		printf("%d\n",B/A);
	}
	return 0;
}


Measured memory_bytes: 2760
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var aa = new int[n, 2];
        for (int i = 0; i < n; i++)
        {
            var w = (i + a[i]) % n;
            aa[i, 1] = w;
            aa[w, 0]++;
        }
        getAns(n, aa);
    }
    static void getAns(int n, int[,] aa)
    {
        var t = new List<int>();
        for (int i = 0; i < n; i++)
            if (aa[i, 0] == 0) t.Add(i);
        var count = 0;
        foreach (var x in t)
        {
            var y = x;
            while (true)
            {
                var yy = aa[y, 1];
                aa[yy, 0]--;
                count++;
                if (aa[yy, 0] == 0) y = yy;
                else break;
            }
        }
        Console.WriteLine(n - count);
    }
}



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

int main()
{
  int k, n;
  cin >> k >> n;
  int a, a0, t, m;
  cin >> a;
  a0 = a;
  m = 0;
  for(int i = 1; i < n; ++i){
    cin >> t;
    if(m <(t - a)) m = t-a;
    a = t;
  }
  if(m <(a0+ k - a)) m = a0+ k - a;
  cout << k -m  << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	static class Restaurant{
		public Restaurant(int id, String name, int score) {
			this.id = id;
			this.name = name;
			this.score = score;
		}
		int id;
		String name;
		int score;
	}
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int N = sc.nextInt();
			List<Restaurant> restaurants = new ArrayList<>();
			for(int i = 0; i < N; i++) {
				restaurants.add(new Restaurant(i + 1, sc.next(), sc.nextInt()));
			}
			Collections.sort(restaurants, (l, r) -> {
				int c = l.name.compareTo(r.name);
				if(c != 0) return c;
				return r.score - l.score;
			});
			restaurants.forEach(r -> System.out.println(r.id));
		}
	}
}


Measured memory_bytes: 26704
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int a,b;
    cin >> a >> b;
    //処理
  
    //出力
    if(a+b<10) cout << a+b << ENT;
    else cout << "error" << ENT;
    return 0;
}

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static StringTokenizer st;

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        int N = readInt();

        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = readInt();
        }

        int gg = gcd(a[0], a[1]);
        for (int i = 2; i < N; i++) {
            gg = gcd(gg, a[i]);
        }
        if (gg != 1) {
            System.out.println("not coprime");
            return;
        }

        HashSet<Integer> ps = simpleSieve(1000000);

        for (int i = 0; i < N; i++) {
            int c = a[i];
            if (c > 1) {
                if (ps.contains(c)) {
                    ps.remove(c);
                    continue;
                }
                while (true) {
                    int toRemove = -1;
                    for (int p : ps) {
                        if (c % p == 0) {
                            toRemove = p;
                            do {
                                c /= p;
                            } while (c > 0 && c % p == 0);
                        }
                    }
                    if (toRemove > 0) {
                        ps.remove(toRemove);
                    } else break;
                }
                if (c > 1) {
                    System.out.println("setwise coprime");
                    return;
                }

            }
        }

        System.out.println("pairwise coprime");
    }

    static int gcd(int a, int b) {
        while (a != 0) {
            int tmp = a;
            a = b % a;
            b = tmp;
        }
        return b;
    }

    static HashSet<Integer> simpleSieve(int limit) {
        final int halfLimit = (limit - 1) / 2;
        // isComposite[p] will become true only if 2p + 3 is composite.
        boolean[] isComposite = new boolean[halfLimit];

        for (int p = 3, squareRoot = (int) Math.sqrt(limit); p <= squareRoot; p += 2) {
            if (!isComposite[(p - 3) / 2]) { // which means p is a prime.
                for (int j = (p * p - 3) / 2; j < halfLimit; j += p)
                    isComposite[j] = true;
            }
        }

        HashSet<Integer> primes = new HashSet<>();
        primes.add(2);
        for (int i = 0, j = 0; i < halfLimit; i += 1) {
            if (!isComposite[i]) primes.add(2 * i + 3);
        }

        return primes;
    }
}


Measured memory_bytes: 76520
import sys
inf = sys.maxsize
n = int(input())
x = [int(i) for i in input().split()]

ans = inf
for i in range(min(x), max(x) + 1): #座標
    tmp = 0
    for j in x:
        tmp += (j - i) ** 2
    ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 2940
N = int(input())

rank = []
score = []

for i in range(N):
    s = input()
    rank.append(int(s.split()[0]))
    score.append(int(s.split()[1]))

min_rank = max(rank)
min_key = max(enumerate(rank), key=lambda x: x[1])[0]

ans = min_rank + score[min_key]

print(ans)

Measured memory_bytes: 11044
n=int(input())
slist=[]
for i in range(n):
    slist.append(int(input()))

slist.sort()
total=sum(slist)

gisei=total
for i in range(n):
    if slist[i]%10!=0:
        gisei=slist[i]
        break

if total%10!=0:
    ans=total

else:
    ans=total-gisei

print(ans)

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

int min(int a, int b);

int main(void){
  int n,m;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  cin>>m;
  int B[m];
  for(int i=0;i<m;i++){
    cin>>B[i];
  }

  for(int i=0;i<min(n,m);i++){
    if(A[i]<B[i]){
      cout<<1<<endl;
      return 0;
    }
    else if(A[i]>B[i]){
      cout<<0<<endl;
      return 0;
    }
  }

  if(min(n,m)==m){
    cout<<0<<endl;
  }
  else{
    cout<<1<<endl;
  }
  return 0;


}


int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}



Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <bitset>
#include <utility>
#include <sstream>
#include <fstream>
#include <stack>
#include <cstdlib>
#include <complex>
#include <set>
#include <iomanip>

using namespace std;

#define INF 1070000000LL
#define pb push_back
#define irep(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) irep(i,0,n)

typedef long long lint;
typedef pair<int, int> pint;
struct Edge{
    int to,weight;
};
typedef vector<vector<Edge> > Graph;


int main(){
    lint a,b,k;
    cin >> a >> b >> k;
    if(a < k){
	cout << 0 << " " << max(lint(0), b-(k-a)) << endl;
    }
    else{
	cout << a-k << " " << b << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

Measured memory_bytes: 26196
import java.util.Queue;
import java.util.*;

public class Main {
     public static void main(String[] wjy){
            Scanner in = new Scanner(System.in);
            Queue<String[]> input = new ArrayDeque<String[]>();
            int num = Integer.parseInt(in.next()) ;
            int quan = Integer.parseInt(in.next());
            for (int i=0;i<num;i++) {
                String[] a = new String[2];
                a[0] = in.next();
                a[1] = in.next();
                input.add(a);
            }
            in.close();
            int calculate = 0;
            while (!input.isEmpty()){
                 String[] k = input.remove();
                 String name =(String) k[0];
                 int time =Integer.parseInt(k[1]);
                 if (time<=quan){
                    calculate=calculate+time;
                    System.out.println(name +" "+calculate);
                 }
                 else{
                    k[1]=Integer.toString((time-quan));
                    input.offer(k);
                    calculate=calculate+quan;
                 }
            }
     }
}



Measured memory_bytes: 73808
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define INF 2000'000'000
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll n, k;

bitset < 5'005 > vis;	
int p[5'001], c[5'001];

ll solve(vector < int > & v){
	if(v.empty())
		return -1e18;
	/*cout << "solving cycle:";
	for(int i : v)
		cout << i << " ";
	cout << endl;
	*/
	
	ll sz = v.size();
	vector < ll > pref(sz*3);
	for(int i = 0; i < 3*sz; i++){
		pref[i] = c[v[i % sz]] + (i ? pref[i-1] : 0);
	}
	/*cout << "done with pref:";
	for(ll i : pref)
		cout << i << " ";
	cout << endl;
	*/
	//cout << "Cycle : " << cycle << endl;
	ll cycle = pref[sz-1];	
	ll cnt_cycles = max(0ll, k / sz -1), sum_cycles = max(0ll, cnt_cycles * cycle);
	ll rem_cnt = k - cnt_cycles * sz;
	// find largest subsegment of size at most rem_cnt
	ll add = -INF;
	for(int start = 0; start < sz; start++){
		for(int end = start; end <= start + rem_cnt - 1; end++){
			add = max(add, pref[end] - (start ? pref[start-1] : 0));
		}
	}
	return sum_cycles + add;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	//freopen("in", "r", stdin);//freopen("out", "w", stdout);
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> p[i];
	
	for(int i = 1; i <= n; i++)
		cin >> c[i];
	
	ll ans = -1e18;
	for(int i = 1; i <= n; i++){		
		vector < int > cur;
		for(int u = i; !vis[u]; u = p[u]){
			vis[u] = true, cur.push_back(u);
		}
		ans = max(ans, solve(cur));	
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3792
def solve(n):
    l = []
    k = int(n**0.5)
    i = 2
    tmp = 0
    while i <= n and i <= k:
        if n % i == 0:
            n = n // i
            tmp += 1
        else:
            if tmp != 0:
                l.append(tmp)
                tmp = 0
            i += 1
    if n == 1:
        l.append(tmp)
    else:
        l.append(1)
    res = 0
    for z in l:
        i = 1
        z -= i
        while z >= 0:
            res += 1
            i += 1
            z -= i
    return res





if __name__ == '__main__':
    n = int(input())
    print(solve(n))

Measured memory_bytes: 9472
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
#include<iostream>
#include<cmath>
#include<queue>
#include<cctype>
#include<string>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF 2100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
int dp[4545][4545],a[454545],b[454545];
int main(void)
{
	int n,t,s,time,mx=-1;
	cin>>n>>t>>s;
	rep(i,0,n) cin>>a[i]>>b[i];
	rep(i,0,n) rep(j,0,t+1) dp[i][j]=-1;
	dp[0][0]=0;
	rep(i,0,n) {
		rep(j,0,t+1) {
			if(dp[i][j]!=-1) {
				if(j<s && j+b[i]>s) time=((s-j)+(j+b[i]))-j;
				else time=b[i];
				if(i+1<=n)dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
				if(i+1<=n&&j+time<=t)dp[i+1][j+time]=max(dp[i][j]+a[i],dp[i+1][j+time]);
			}
		}
	}
	/*rep(i,0,n) {
		rep(j,0,t) {
			printf("%5d",dp[i][j]);
		}
		cout<<endl;
	}*/
	rep(i,0,t+1) {
		mx=max(mx,dp[n][i]);
	}
	cout<<mx<<endl;
	return 0;
}
	
	

Measured memory_bytes: 50252
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n;cin>>n;
  int i=1;
  while(pow(i,2)<=n){
    i++;
  }
  cout<<ll(pow(i-1,2))<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <string>
#define x real() 
#define y imag() 
using namespace std;
typedef complex <double> point;
typedef complex<double> vectol;

double dot(point a,point b){
  return a.x*b.x+a.y*b.y;
}

double cross(point a,point b){
  return a.x*b.y-a.y*b.x;
}

string ccw(point a,point b,point c){
  point d = b-a;
  point e = c-a;
  if(cross(d,e)>0) return "COUNTER_CLOCKWISE";
  if(cross(d,e)<0) return "CLOCKWISE";
  if(dot(d,e)<0) return "ONLINE_BACK";
  if(abs(d) < abs(e)) return "ONLINE_FRONT";
  return "ON_SEGMENT";
}

int main() {
  double x0,y0,x1,y1;
  cin>>x0>>y0>>x1>>y1;
  point a = point( x0, y0);
  point b = point( x1, y1);
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x0 >> y0;
    cout << ccw(a,b,point(x0,y0)) <<endl;
  }

  return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int main(){
  int a,b;
  cin >> a >> b;
  cout << (a+b)%24 << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
t = [0]
x = [0]
y = [0]

ans = "Yes"

for i in range(N):
  a,b,c = map(int,input().split())
  t.append(a)
  x.append(b)
  y.append(c)

for i in range(1,N+1):
  dt = t[i] - t[i-1]
  dist = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1])
  if dt < dist:
    ans ="No"
  elif dt % 2 != dist % 2:
    ans = "No"
    
print(ans)

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

int k;

int min(int x,int y) {
    return (x > y) ? y : x;
}

int opA(int x) {
    return 2*x;
}

int opB(int x) {
    return x+k; 
}

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

    int res = 1;
    for (int i = 0;i < n;i++ ){
        res = min(opA(res),opB(res));
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); //freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);
using namespace std;


signed main()
{
    
    FLASH


    for(int i = 1; i <= 5; i++){
        int x;
        cin>>x;
        if(x == 0){
            return cout<<i<<'\n', 0;
        }
    }
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }
  for(j=0;j<n;j++){
    scanf("%hu",&A[j+1]);
    C[A[j+1]]++;
  }
  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    if (i>1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 9612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n;
  cin>>n;
  ll a[111111],b[111111];
  for(int i=0;i<n;i++)cin>>a[i]>>b[i];
  ll sum=0;
  for(int i=n-1;i>=0;i--){
    ll t=(b[i]-(a[i]+sum)%b[i])%b[i];
    sum+=t;
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    D,X=map(int,input().split())
    ans=X
    for i in range(N):
        A=int(input())
        ans+=(D-1)//A+1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
//cara pikir 
//pake recursive tapi gak 3 x
// C++ program for implementation of Ford Fulkerson algorithm 
#include <iostream> 
#include <limits.h> 
#include <string.h> 
#include <queue> 
#include <iostream> 
#include <set> 
#include <iterator> 
#include <algorithm>

using namespace std; 

int main(){
set<int>k;
int n;
cin>>n;
int num1;
int ct;
bool flag=true;
for(int i=0;i<n;i++){
  cin>>num1;
if(num1%2==0){
  ++ct;
  if((num1%3)==0||(num1%5)==0){
     flag=true;
  }else{
    cout<<"DENIED"<<endl;
    flag=false;
    goto fin;
  }
}
}

fin:
if(flag==true){
  cout<<"APPROVED"<<endl;
}

return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	long long int n, d, a;
	cin >> n >> d >> a;
	vector<pair<long long int, long long int>> vp;
	for (int i = 0; i < n; i++) {
		long long int x, h;
		cin >> x >> h;
		vp.push_back(make_pair(x, h));
	}
	sort(vp.begin(), vp.end());
	long long int res = 0;
	long long int kill = 0;
	deque<pair<long long int, long long int>> dq;
	for (int i = 0; i < n; i++) {
		while (dq.size() > 0 && dq.front().first < vp[i].first) {
			kill -= dq.front().second;
			dq.pop_front();
		}
		vp[i].second = max((long long int)0, vp[i].second - kill);
		long long int r = 0;
		r = vp[i].second / a + (vp[i].second % a > 0 ? 1 : 0);
		res += r;
		kill += r * a;
		dq.push_back(make_pair(vp[i].first + 2 * d, r * a));
	}
	cout << res << endl;
}









Measured memory_bytes: 6764
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        while(a > 0 || c > 0){
            c -= b;
            if(c <= 0){
                System.out.println("Yes");
                break;
            }
            a -= d;
            if(a <= 0){
                System.out.println("No");
                break;
            }
        }

    }
}


Measured memory_bytes: 35756
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

#define EPS 1e-5
#define INF 1e8

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

typedef complex<double> point; 
long double r;

struct straight
{
	point p1,p2;
	straight(){}
	straight(point a,point b):p1(a),p2(b){}
};

point GetCrossPoint(straight s1,straight s2)
{
	long double x1 = s1.p1.real(),y1 = s1.p1.imag(),x2 = s1.p2.real(),y2 = s1.p2.imag();
	long double x3 = s2.p1.real(),y3 = s2.p1.imag(),x4 = s2.p2.real(),y4 = s2.p2.imag();
	
	
	if((y2-y1) * (x4-x3) == (y4-y3) * (x2-x1))
	{
		point ret(INF,INF);
		return ret;
	}
	
	long double x13 = x3 - x1;
	long double y13 = y3 - y1;
	long double z = (x2-x1) * (y4-y3) - (y2-y1) * (x4-x3);
	r = ((y4-y3) * x13 - (x4-x3) * y13 ) / z;
	
	
	double x = x1 + r * (x2-x1);
	double y = y1 + r * (y2-y1);
	point ret(x,y);
	return ret;
	
}


int main()
{
	int N;cin >> N;
	while(N--)
	{
		
		double xa,xb,ya,yb;
		cin >> xa >> ya >> xb >> yb;
		straight par(point(xa,ya),point(xb,yb));
		int n;cin >> n;
		
		vector<pair<double,int> > v;
								
		REP(i,n)
		{
			double sx,sy,gx,gy;
			int o,l;
			cin >> sx >> sy >> gx >> gy >> o >> l;
			
			auto cross = GetCrossPoint(par,straight(point(sx,sy),point(gx,gy)));
			auto tmpx = cross.real();
			auto tmpy = cross.imag();
			
			if(tmpx == INF)continue;
			
			if(((((tmpx - sx > -EPS) && (gx - tmpx > -EPS)) || 
				((sx - tmpx > -EPS) && (tmpx - gx > -EPS))) &&
				(((tmpy - sy > -EPS) && (gy - tmpy > -EPS)) ||
				((sy - tmpy > -EPS) && (tmpy - gy > -EPS)))) &&
				((((tmpx - xa > -EPS) && (xb - tmpx > -EPS)) || 
				((xa - tmpx > -EPS) && (tmpx - xb > -EPS))) &&
				(((tmpy - ya > -EPS) && (yb - tmpy > -EPS)) ||
				((ya - tmpy > -EPS) && (tmpy - yb > -EPS)))))
				{
					v.PB(MP(r,((o+l)%2)));
				}
		}
				
		sort(ALL(v));
		
		if(v.size() == 0)
		{
			cout << 0 << endl;
			continue;
		}
		
		int ans = 0;
		int now = v[0].SE;
		
		REP(i,v.size())
		{
			if(v[i].SE != now)
			{
				now = v[i].SE;
				ans++;
			}
		}
	
		cout << ans << endl;
	
	}
	return 0;
}

Measured memory_bytes: 3040
#include<stdio.h>

int main(void)
{
	int a, b,c;
	scanf("%d",&c);
	scanf("%d %d", &a, &b);

	for (int i = 1;i * c <= b;i++) {
		if (a <= i * c && i * c <= b) {
			printf("OK");
			return 0;
		}
	}

	
		printf("NG");

	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define for_(i,n) for(int i=0;i<n;++i)
#define for_1(i,n) for(int i=1;i<=n;++i)
const int mod= 1e9 +7;
const int inf=1e7;
int n;
string s;

/*
dp[i][j]:- i th character of permutation is j
we need find sigma over j (dp[n][j])
i range from 0 to n-1

dp[i][j] = dp[i-1][1] + ... +dp[i-1][j-1] if(s[i-1] = '<')
         = dp[i-1][j+1] + ... +dp[i-1][n] if(s[i-1] = '>')
*/
void add_self(int &a, int b)
{
    a+=b;
    if(a>=mod)
    a-= mod;
}


/********************** Recursive Approach ***************************
int dp[3001][3001]; int pre[3001][3001];
int solve(int i, int j){

if(i==1 && j==1){ dp[i][j]=1; return 1;}
//else if(i==1) return 0;
else if(j>i) return 0;
else if(dp[i][j]!=-1) return dp[i][j];
else{
    dp[i][j]=0;
    if(s[i-2]=='<')
    {
        for_1(k,j-1)
        add_self(dp[i][j],solve(i-1,k));
    }
    else if(s[i-2]=='>')
    {
        for(int k=j;k<=n;++k)
        add_self(dp[i][j],solve(i-1,k));
    }
    
   return dp[i][j]; 
}
}

// --------------O(n^3)
*************************************** Recursive Approach ***************/
main()
{
   cin>>n>>s;
   
 /* memset(dp,-1,sizeof(dp));
    int ans=0;
    for_1(i,n)
        add_self(ans,solve(n,i));
    cout<<ans;
 */ 
 
 
 /*********** iterative ***********/
 vector<vector<int>> dpi(n+1,vector<int>(n+1));
 vector<vector<int>> pref(n+1,vector<int>(n+1));
dpi[1][1]=1;pref[1][1]=1;

 for(int len =2; len<=n;++len)
 {   for(int i =1;i<=len-1;++i)pref[len-1][i] = (pref[len-1][i-1] + dpi[len-1][i]) % mod;
     for(int b =1;b<=len;++b)
     { 
         int l,r;
         if(s[len-2]=='<') l=1,r=b-1;
         else l=b,r=len-1;
         if(l<=r) 
         {
             int tmp = (pref[len-1][r]+mod-pref[len-1][l-1])%mod;
             add_self(dpi[len][b],tmp);
         
     
         }
        
         }
 }

 int answer = 0;
    for(int b = 1; b <= n; ++b) {
        add_self(answer, dpi[n][b]);
    }
 cout<<answer<<endl;
}





/*
typedef struct structure{
    int x,y;
} pt;
pt p0;
bool cmp(pt a, pt b)
{
    return cw(p0,a,b);
}
bool cw(pt a, pt b, pt c){
    return ((c.y-a.y)*(b.x-a.x)-(b.y-a.y)*(c.x-a.x))>=0
}



convex_hull(vector<pt>& points)
{
   // sort(points.begin(),points.end, cmp);// sorted according to y cordinate
    p0=points[0];
    sort(points.begin(),points.end, cmp);
    vector<pt> convexHull;
    stack<pt> temp;
    convexHull.push_back(points[0]);
    
    temp.push(points[0]);temp.push(points[1]);//temp.push(points[2]);
    pt top,top0;
    for(int it=2;it<points.size();++it)
    {   
        top=temp.top(); temp.pop(); top0=temp.top();
        pt next=points[it];
        if(cw(top0,top,next))
        {
            convexHull.push_back(top);
            temp.push(top);
            top0=top;
            top=next;
        }
        else
        {
          temp.push(next);  
        }
        
    }
    
}*/












Measured memory_bytes: 70912
#include<iostream>
#include<algorithm>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define Z 10200
using namespace std;
int d[Z+1];
int main(){
	int n,m,k,r,l;
	while(true){
		cin>>n>>k>>m>>r;
		if(!(n+m+k+r))break;
		rep(i,0,Z)d[i]=0;
		k=1,l=n;
		rep(i,0,Z)d[i]+=k/l,k%=l,k*=10;
		if(m)rep(i,1,n){k=1,l=i*n;rep(j,0,Z)d[j]+=k/l,k%=l,k*=10;}
		for(int i=Z;i>0;i--)d[i-1]+=d[i]/10,d[i]%=10;
		cout<<d[0]<<".";
		rep(i,1,r+1)cout<<d[i];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

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

const int N = (int)3e5+5;
const int Q = 301;

vector<pi> dp[1<<18][2]; //(max_value, min_steps)
bool ch[1<<18][2];
void rec(int n, vector<int>& a, vector<int>& b, int i, int pos) {
    if (i==0 || ch[i][pos]) return;
    ch[i][pos] = true;
    int cnt = 0;
    REP(k,0,n-1) {
        if ((1<<k)&i) {
            int curr = ((pos==(k%2))?a[k]:b[k]);
            int mn = 10000;
            rec(n,a,b,i-(1<<k),1-pos);
            for (auto it:dp[i-(1<<k)][1-pos]) {
                if (it.first >= curr) {
                    mn = min(mn, it.second + cnt);
                }
            }
            dp[i][pos].pb({curr, mn});
            cnt++;
        }
    }
}
void solve() {
    int n;
    cin>>n;
    vector<int> a(n), b(n);
    REP(i,0,n-1) {
        cin>>a[i];
    }
    REP(i,0,n-1) {
        cin>>b[i];
    }
    REP(i,0,(1<<n)-1) {
        ch[i][0] = ch[i][1] = false;
    }
    dp[0][0].pb({100,0});
    dp[0][1].pb({100,0});
    rec(n,a,b,(1<<n)-1,0);

    int ans = INT_MAX;
    for (auto it:dp[(1<<n)-1][0]) {
        ans = min(ans, it.second);
    }
    if (ans >= 10000) {
        ans = -1;
    }
    cout<<ans;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        //cout<<"\n";
    }
}


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define PB push_back
#define F first
#define S secon

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

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

	for(int i = 0; i < 5; i++){
		int x; cin >> x;
		if(x == 0){
			cout << i+1 << '\n';
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
int N, K, Q, A[2010];
min_priority_queue<int> buf[2010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K >> Q;
    rep(i, 0, N) cin >> A[i];

    int ans = inf;
    rep(y, 0, N) { // Y=A[y]として取っていく
        int Y = A[y];

        vector<pair<int, int>> v;
        int pre = -1;
        rep(i, 0, N) {
            if (Y <= A[i]) {

            } else {
                if (pre + 1 < i) v.push_back({ pre + 1, i - 1 });
                pre = i;
            }
        }
        if (pre < N - 1) v.push_back({ pre + 1, N - 1 });

        int n = v.size();
        rep(i, 0, n) while (!buf[i].empty()) buf[i].pop();
        rep(i, 0, n) rep(j, v[i].first, v[i].second + 1) buf[i].push(A[j]);
        
        min_priority_queue<pair<int,int>> qu;
        rep(i, 0, n) if(K <= buf[i].size()) {
            qu.push({ buf[i].top(), i });
            buf[i].pop();
        }

        int X = Y;
        int q = Q;
        while (0 < q && !qu.empty()) {
            auto p = qu.top();
            qu.pop();

            int x = p.first;
            int i = p.second;

            chmax(X, x);

            q--;
            if (K <= buf[i].size()) {
                qu.push({ buf[i].top(), i });
                buf[i].pop();
            }
        }

        if (q == 0) chmin(ans, X - Y);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

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

  if (x % y) {
    cout << x << endl;
    return 0;
  }

  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,m,c;
    cin>>n>>m>>c;
    for(int i=0;i<=m;i++)for(int j=0;j<=n;j++){
        if(j*(m-i)+(n-j)*i==c){
            cout <<"Yes"<<endl;
            return 0;
        }
    }
    cout <<"No\n";
    return 0;
}


Measured memory_bytes: 256
#AtCoder
N = int(input())
A = list(map(int, input().split()))
ok = True

even = []
for i in A:
    if i % 2 == 0:
        even.append(i)

if even == []:
    print('APPROVED')
    exit()

for i in even:
    if i % 3 == 0 or i % 5 == 0:
        pass
    else:
        print('DENIED')
        exit()
    
print('APPROVED')

Measured memory_bytes: 3064
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  if (a < b) {
    return b - a;
  } else {
    return a - b;
  }
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a) {
    a = b;
  }
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b) {
    a = b;
  }
}
template <class F> class fix_point : private F {
public:
  explicit constexpr fix_point(F &&f) : F(std::forward<F>(f)) {}

  template <class... Args>
  constexpr decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};
template <class F> constexpr decltype(auto) make_fix(F &&f) {
  return fix_point<F>(std::forward<F>(f));
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const u32 h = scan<u32>();
  const u32 a = scan<u32>();
  std::cout << (h + a - 1) / a << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N;
    cin >> N;
    vector<int> V(N), C(N);
    REP(i, N) cin >> V[i];
    REP(i, N) cin >> C[i];

    int ans = 0;
    REP(i, N) {
        if (V[i] > C[i])
            ans += V[i] - C[i];
    }

    cout << ans << endl;

    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; i >= 0; i--) //逆ループ
#define FOR(i, m, n) for(int i = m; i < n; i++) //最初の数値を指定したループ

//型名省略
typedef long long ll;

using namespace std;

int main(){
    string S, sub;
    char c, three, four, five, six;

    cin >> S;
    if(S.length() != 6){
        //cout << "length error" << S.length();
        return 1;
    }

    REP(i, 6){
        c = S[i];
        if(isalpha(c)==0){
            //cout << "not alphabet" << c << isalpha(c);
            return 1;
        }
        if(i==2){
            three = c;
        }
        else if(i==3){
            four = c;
        }
        else if(i==4){
            five = c;
        }
        else if(i==5){
            six = c;
        }
    }

    //cout << three << four << five << six;

    if(three==four && five==six){
        cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
arg = list(map(int, input().split()))

if int(arg[0] / 2019) != int(arg[1] / 2019):
  arg[1] = arg[0] + 2019
  
min_value = 2019
for i in range(arg[0], arg[1]+1):
  for j in range(i+1, arg[1]+1):
    value = (i*j) % 2019
    if value < min_value:
      min_value = value
      
print(min_value)

Measured memory_bytes: 3064