akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    // Your code here!
    int limit = 0;
    int num = 0;
    scanf("%d", &limit);
    scanf("%d", &num);
    limit = limit / 2.0 + 0.5;
    if(num > limit){
        printf("NO");
    }else{
        printf("YES");
    }
}


Measured memory_bytes: 128
import Control.Monad
import Data.List

solveSub as [] = 0
solveSub as (qs:qss) =
    if (as!!(b-1)) - (as!!(a-1)) == c
        then d + solveSub as qss
        else solveSub as qss 
    where
        a = qs!!0
        b = qs!!1
        c = qs!!2
        d = qs!!3

solve [] qss = []
solve (as:ass) qss = solveSub as qss : solve ass qss

getass 0 m i = [[]]
getass n m i = [a:as | a <- [i..m], as <- getass (n-1) m a]

main = do
    [n,m,q] <- map read . words <$> getLine :: IO [Int]
    qss <- replicateM q (map read . words <$> getLine) :: IO [[Int]]
    let ass = getass n m 1
    print $ maximum $ solve ass qss


Measured memory_bytes: 6840
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MOD 1000000007

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

int g[1024][1024];
int dp[1024][1024];
int H, W, N;

int main(){
  while(1){
    scanf("%d%d%d", &H, &W, &N);
    if(!H && !W && !N) break;
    rep(i,H) rep(j,W) scanf("%d", &g[i][j]);
    
    memset(dp, 0, sizeof(dp));
    
    dp[0][0] = N-1;
    rep(i,H) rep(j,W){
      dp[i][j+1] += (dp[i][j]+g[i][j])/2;
      dp[i+1][j] += (dp[i][j]+!g[i][j])/2;
    }

    int h = 0, w = 0;
    while(h < H && w < W){
      if((dp[h][w]+g[h][w])%2) w++;
      else h++;
    }
    
    printf("%d %d\n", h+1, w+1);
  }
  return 0;
}

Measured memory_bytes: 9384
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define clr(a, b) memset(a, b, sizeof(a))
#define Error(x) cout << #x << " = " << x << endl
#define iDEBUG freopen("in.txt", "r", stdin)
#define oDEBUG freopen("output.txt","w",stdout)
#define pb push_back
#define x first
#define y second
#define all(x) x.begin(),x.end()
typedef long long ll;

using namespace std;
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

int main()
{_
    int n;
    cin >> n;
    int t0=0, x0=0, y0=0;
    bool ans = true;
    for(int i=0; i<n; i++)
    {
        int t, x, y;
        cin >> t >> x >> y;

        if((abs(x-x0) + abs(y-y0)) > abs(t-t0) && ans)
            ans = false;
        else if((abs(x-x0) == abs(y-y0)) && abs(t-t0)%2!=0 && ans)
            ans = false;
        t0=t, x0=x, y0=y;
    }
    if(ans)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DPテーブル
long long dp[100010];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> h[i];

  for (int i = 0; i < 100010; i++) dp[i] = INF;
  dp[0] = 0;

  for (int i = 1; i < N; i++) {
    chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
  }

  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()
    val hs = readLine()!!.split(" ").map { it.toInt() }

    var count = 0
    var max = hs[0]
    
    for(i in hs){
        if(i >= max){
            count++
            max = i
        }
    }

    println(count)
}


Measured memory_bytes: 37868
n = gets.to_i

xs = []
ys = []
n.times do
  x, y = gets.split.map(&:to_i)
  xs << x
  ys << y
end

if xs.zip(ys).all? {|x, y| (x + y).abs % 2 == 0}
  is_odd = false
elsif xs.zip(ys).all? {|x, y| (x + y).abs % 2 == 1}
  is_odd = true
else
  puts "-1"
  exit
end

us = xs.zip(ys).map {|x, y| x + y}
vs = xs.zip(ys).map {|x, y| x - y}


ds = 31.downto(0).map {|i| 1 << i}
if !is_odd
  ds << 1
end

p ds.size
puts ds.join(' ')

n.times do |i|
  u = us[i]
  v = vs[i]

  cs = ds.map do |d|
    if u > 0
      u -= d
      up = 0
    else 
      u += d
      up = 1
    end

    if v > 0
      v -= d
      vp = 0
    else
      v += d
      vp = 2
    end

    dirs = "RDUL"
    dirs[up + vp]
  end

  puts cs.join('')
#  p [u, v]
end


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

int main(){
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  
  long long xy1 = max(a*c, a*d);
  long long xy2 = max(b*c, b*d);
  long long xy = max(xy1, xy2);
  
  cout << xy << endl;
}

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

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-1);
		else
			System.out.println(a);
	}
}


Measured memory_bytes: 21332
#include <stdio.h>
#include <math.h>
#include <string>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

// Q1
int main()
{
	int nA, nB;
	int n[3] = { 1,2,3 };
	cin >> nA >> nB;
	n[nA-1] = 0;
	n[nB-1] = 0;
	for (int i = 0; i < 3; i++)
	{
		if (0 != n[i])
			cout << n[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#include <memory>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double l_double;

#define vtr vector
#define PB push_back
#define EB emplace_back
#define gcd __gcd
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define st_ct static_cast // <>
#define TEST uint _ {}; cin >> _; while (_--)
#define PI (3.1415926535897932384626433832795)
#define MOD st_ct<int>(1e9 + 7)
#define EPS 1e-9
#define deb1(x) cerr << #x << " -> " << x << endl;
#define deb2(x,y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ")" << endl;
#define deb3(x,y,z) cerr << "(" << #x << ", " << #y << ", " << #z << ") -> (" << x << ", " << y << ", " << z << ")" << endl;
#define debVV(V) cerr << #V << ":\n" << V << endl; // 2D

// 1D
template<typename T>
istream& operator>>(istream &is, vector<T> &A) {
    for (T &v: A)
        is >> v;
    return is;
}

template <typename T>
ostream& operator<<(ostream &os, const vector<T> &A) {
    for (T const &v: A)
        os << v << " ";
    return os;
}

template<typename T>
void vtrV(const vector<T> &A)
{ for (T const &val: A) cout << val << endl; }

// 2D
template<typename T>
istream& operator>>(istream &is, vector<vector<T>> &A) {
    for (vector<T> &i: A)
        for (T &j: i)
            is >> j;
    return is;
}

template <typename T>
ostream& operator<<(ostream &os, const vector<vector<T>> &A) {
    for (vector<T> const &i: A) {
        for (T const &j: i)
            os << j << " ";
        os << endl;
    }
    return os;
}

template<typename T>
void vvtrNS(const vector<vector<T>> &A) {
    for (vector<T> const &i: A) {
        for (T const &j: i)
            cout << j;
        cout << endl;
    }
}

template<typename T>
T cntDigits(const T &N) { return (floor(log10(N)) + 1); }

template<typename T>
bool isPowOfTwo(const T &N) { return (N && (!(N&(N-1)))); }

template<typename T>
T lcm(T a, T b) { return ((a*b)/gcd(a, b)); }
/* -------------------------------------------------------- */
/* -------------------------------------------------------- */

class Obs {
public:
	int height;
	vtr<int> reach;
};

bool heightThanReach(const vtr<Obs> &arr, const vtr<int> &reach, const int &hgt) {
	for (auto const &h: reach)
		if (hgt <= arr.at(h).height)
			return false;
	return true;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.setf(std::ios::boolalpha);
    cout<<std::fixed;
    cout<<std::setprecision(6); // default
    /* -------------------------------- */

    int n {}, m {};
    cin >> n >> m;

    vtr<Obs> arr (n);
    for (auto &ob: arr) {
    	cin >> ob.height;
    }

    while (m--) {
    	int r1 {}, r2 {};
    	cin >> r1 >> r2;
    	arr.at(r1-1).reach.EB(r2-1);
    	arr.at(r2-1).reach.EB(r1-1);
    }

    int ans {};
    for (auto const &ob: arr)
    	if (ob.reach.empty() || heightThanReach(arr, ob.reach, ob.height))
    		++ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9272
#ifndef ___GEOMETRY_LIBRARY
#define ___GEOMETRY_LIBRARY

#include <vector>
#include <algorithm>

template<class type>
class point2d {
public:
	type x, y;
	point2d() : x(type(0)), y(type(0)) {};
	point2d(type x_, type y_) : x(x_), y(y_) {};
	bool operator==(const point2d& p) { return x == p.x && y == p.y; }
	bool operator!=(const point2d& p) { return x != p.x || y != p.y; }
	point2d& operator+=(const point2d& p) { x += p.x; y += p.y; return *this; }
	point2d& operator-=(const point2d& p) { x -= p.x; y -= p.y; return *this; }
	point2d& operator*=(type val) { x *= val; y *= val; return *this; }
	point2d& operator/=(type val) { x /= val; y /= val; return *this; }
	point2d operator+(const point2d& p) const { return point2d(*this) += p; }
	point2d operator-(const point2d& p) const { return point2d(*this) -= p; }
	point2d operator*(type val) const { return point2d(*this) *= val; }
	point2d operator/(type val) const { return point2d(*this) /= val; }
	type norm() const { return x * x + y * y; }
	type abs() const { return type(std::sqrt(x * x + y * y)); }
	long double fabs() const { return std::sqrt((long double)(x * x + y * y)); }
	type dot(const point2d& p) const { return x * p.x + y * p.y; }
	type cross(const point2d& p) const { return x * p.y - y * p.x; }
	int ccw(const point2d& p1, const point2d& p2) const {
		// Centering at point p, p1 -> p2 is COUNTER-CLOCKWISE : (1)
		// Centering at point p, p1 -> p2 is CLOCKWISE : (-1)
		// Collinear with order p1 -> p -> p2 : (2)
		// Collinear with order p -> p1 -> p2 : (-2)
		// Collinear with order p -> p2 -> p1 : (0)
		point2d pr1 = p1 - point2d(*this);
		point2d pr2 = p2 - point2d(*this);
		if (pr1.cross(pr2) != 0) return pr1.cross(pr2) > 0 ? 1 : -1;
		if (pr1.dot(pr2) < 0) return 2;
		return pr1.norm() < pr2.norm() ? -2 : 0;
	}
};

template<class type>
class segment2d {
public:
	point2d<type> p1, p2;
	segment2d() : p1(point2d<type>()), p2(point2d<type>()) {};
	segment2d(const point2d<type>& p1_, const point2d<type>& p2_) : p1(p1_), p2(p2_) {};
	type norm() const { return (p1 - p2).norm(); }
	type abs() const { return (p1 - p2).abs(); }
	long double fabs() const { return (p1 - p2).fabs(); }
};

#endif // ___GEOMETRY_LIBRARY

#include <iostream>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int q;
	cin >> q;
	cout.precision(15);
	for (int i = 0; i < q; ++i) {
		segment2d<double> s1, s2;
		cin >> s1.p1.x >> s1.p1.y >> s1.p2.x >> s1.p2.y >> s2.p1.x >> s2.p1.y >> s2.p2.x >> s2.p2.y;
		if ((s1.p2 - s1.p1).cross(s2.p2 - s2.p1) == 0) cout << "2\n";
		else if ((s1.p2 - s1.p1).dot(s2.p2 - s2.p1) == 0) cout << "1\n";
		else cout << "0\n";
	}
	return 0;
}


Measured memory_bytes: 3288
//Nihal Mittal - nihal_47
    //Strike First , Strike Hard , No Mercy !!
     
    /**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
    ⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
    ⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
    ⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
    ⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
    ⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
    ⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
    ⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
    ⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
    ⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
    ⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
    ⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
    ⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
    ⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
    **/
    #include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #define ll long long
    #define ld long double
    #define mk make_pair
    #define pb push_back
    #define in insert
    #define se second
    #define fi first
    #define mod 1000000007
    #define watch(x) cout << (#x) << " is " << (x) << "\n"
    #define all(v) (v).begin(),(v).end()
    #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    #define pii pair<ll,ll>
    #define vi(x) vector<x>
    #define maxn 100005
    #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
    using namespace std;
    using namespace __gnu_pbds;
    ll fac[500010]; 
    ll power(ll x,ll y) 
    { 
        ll res = 1;    
        x = x % mod;  
        while (y > 0) 
        { 
            if (y & 1) 
                res = (res*x) % mod; 
            y = y>>1;
            x = (x*x) % mod;   
        } 
        return res; 
    }   
    ll modInverse(ll n, ll p) 
    { 
        return power(n, p-2); 
    }
    void precompute() 
    { 
        fac[0] = 1; 
        for (ll i=1 ; i<=500003; i++) 
            fac[i] = fac[i-1]*i%mod; 
    }
    ll ncr(ll n, ll r) 
    { 
       if (r==0) 
          return 1; 
     
       return (fac[n]* modInverse(fac[r], mod) % mod * 
                modInverse(fac[n-r], mod) % mod) % mod; 
    }
    signed main()
    {
        fast;
       
        ll n,m,j,ans=0,cur=1;
        precompute();
        cin>>n>>m;
        for(j=0;j<=n;j++)
        {
            ll a = ncr(n,j);
            a *= ncr(m-j,n-j);
            a %= mod;
            a *= fac[n-j];
            a %= mod;
            if(j&1) ans = (ans - a + mod)%mod;
            else ans = (ans + a)%mod;
        }
        ans = (ans * ncr(m,n))%mod;
        ans = (ans * fac[n])%mod;
        cout<<ans;
     
    }

Measured memory_bytes: 7500
#include<bits/stdc++.h>
#define num 1e5
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int main()
{
    fastio;
    long long int n,m,c,d,i;
    cin>>n>>m;
    long long v=num;
    while(n--)
    {
        cin>>c>>d;
        if(d<=m)
        {
            v=min(v,c);
        }
    }
    if(v==num) cout<<"TLE"<<endl;
    else cout<<v<<endl;
}


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

int main() {
	ll n,m;
	cin >> n >> m;
	vector<string> a(n), b(n);
	rep(i,n) cin >> a[i];
	rep(i,m) cin >> b[i];
	bool ans = false;
	rep(x,n-m+1) rep(y,n-m+1) {
		bool match = true;
		rep(i,m) rep(j,m) {
			if (a[x+i][y+j] != b[i][j]) match = false;
		}
		if (match) ans = true;
	}
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
struct node
{
	ll x,y;
	bool operator<(const node& aa)const
    {
        return x<aa.x;
    }
    bool operator==(const node& aa)const
    {
        return x==aa.x&&y==aa.y;
    }
}a[maxn];
ll n;
ll h,w;
ll xx[]={-2,-2,-2,-1,-1,-1,0,0,0};
ll yy[]={-2,-1,0,-2,-1,0,-2,-1,0};
ll ans[1000];
ll mod=1e9+7;
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
	gbtb;
	cin>>h>>w>>n;
	repd(i,1,n)
	{
		cin>>a[i].x>>a[i].y;
	}
    vector<ll> v;
    repd(i,1,n)
    {
        repd(j,0,8)
        {
            ll x=a[i].x+xx[j];
            ll y=a[i].y+yy[j];
            if(x>=1&&x+2<=h&&y>=1&&y+2<=w)
            {
//                cout<<x<<" "<<y<<endl;
                ll num=(x)*mod+y;
                v.push_back(num);
            }
        }
    }
    sort(ALL(v));
    v.push_back(-9ll);
    ll ww=1ll;
     ll ans0=(h-2ll)*(w-2ll);
    for(int i=0;i<v.size()-1;i++)
    {
//        db(v[i]);
        if(v[i]==v[i+1])
        {
            ww++;
        }else
        {
            ans[ww]++;
            ww=1ll;
            ans0--;
        }
    }


    cout<<ans0<<endl;
    repd(i,1,9)
    {
        cout<<ans[i]<<endl;
    }



    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 12012
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
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)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

X = I()

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

p = primes(1000000)

for pp in p:
    if pp >= X:
        print(pp)
        break


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N=(int)1e5+7;

int n,m;
int t[N];
ll s[N];
int e[N];

int dad(int a)
{
        if(a==t[a])
        {
                return a;
        }
        else
        {
                t[a]=dad(t[a]);
                return t[a];
        }
}

void uni(int a,int b)
{
        a=dad(a);
        b=dad(b);
        if(a!=b)
        {
                t[b]=a;
                s[a]+=s[b];
                e[a]+=e[b];
        }
}

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        cin>>n>>m;
        for(int i=1;i<=n;i++)
        {
                t[i]=i;
                cin>>s[i];
        }
        vector<pair<int,pair<int,int>>>krr(m);
        for(int i=0;i<m;i++)
        {
                int a,b,x;
                cin>>a>>b>>x;
                krr[i]={x,{a,b}};
        }
        sort(krr.begin(),krr.end());
        int res=0;
        for(auto &it:krr)
        {
                int a=it.second.first;
                int b=it.second.second;
                int x=it.first;
                uni(a,b);
                a=dad(a);
                b=dad(b);
                e[a]++;
                if(s[a]>=x)
                {
                        res+=e[a];
                        e[a]=0;
                }
        }
        res=m-res;
        cout<<res<<"\n";
        return 0;
}
/**

**/


Measured memory_bytes: 2944
/*
AizuOnline A0222
Title Prime Quadruplet
@kankichi573
*/
#include <stdio.h>
char prime_f[10000001];

int prime_table[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,
		   53,59,61,67,71,73,79,83,89,97,
		   101,103,107,109,113,127,131,137,139,149,151,157,163,
		   167,173,179,181,191,193,197,199,211,223};
//


void make_furui()
{
        int i,j,p;

        prime_f[0]=prime_f[1]=0;

        for(i=0;i<=10000000;i++)
                prime_f[i]=1;
  
        for(i=0;prime_table[i]<=61;i++)
        {
                p = prime_table[i];
                prime_f[p]=1;
                for(j=2;p*j<3200;j++)
                        prime_f[p*j]=0;
        }
}
void make_furui2()
{
        int i,j,p;


        for(i=2;i<3200;i++)
        {
                if(!prime_f[i])
                        continue;
                //printf("%d\n",i);
                for(j=2;i*j<10000000;j++)
                        prime_f[i*j]=0;
        }
}
int isprime(int n)
{
        return(prime_f[n]);
}


//
int solve(int n)
{
        int i;

        if(n<19)
                return(13);
        if(n<109)
                return(19);
        for(i=((n-9)/10)*10+9;i>=109;i-=10)
                if(isprime(i) && isprime(i-2) &&
                   isprime(i-6) && isprime(i-8))
                        return(i);
        /*never reach */
        return(-1);

}
main()
{
        int n,ret;

        make_furui();
        make_furui2();

        while(EOF!=scanf("%d",&n) && n)
        {
                ret=solve(n);
                printf("%d\n",ret);
        }
        return(0);
}

Measured memory_bytes: 10364
import java.util.Scanner;

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

        int a= 0,b= 0,c = 0;
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();

        System.out.println(Math.min((int) b/a,c));


    }

}


Measured memory_bytes: 22996
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#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, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef pair<long long, long long>pll;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 200050;
const double pi = acosl(-1); constexpr double EPS = 1e-10;
constexpr ll INF = 1e16;
void yes(bool c) { if (c)print("Yes"); else print("No"); };

int A[1010][1010];
void solve() {
	int H, W; cin >> H >> W;
	REP(i, H) {
		REP(j, W)cin >> A[i][j];
	}
	int x = 0, y = 0;
	using arr4 = array<int, 4>;
	vector<arr4>ans;
	REP(_, H*W-1) {
		int nx = x, ny = y;
		if (x % 2 == 0) {
			ny++;
			if (ny >= W) {
				nx++;
				ny--;
			}
		}
		else {
			ny--;
			if (ny < 0) {
				nx++;
				ny++;
			}
		}
		if (A[x][y] & 1) {
			A[nx][ny]++;
			ans.push_back({ x + 1,y + 1,nx + 1,ny + 1 });
		}
		x = nx, y = ny;
	}
	print(ans.size());
	for (auto a : ans) {
		cout << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << endl;
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 10220
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> hi(n);
  for( int i=0; i<n; i++ ) cin >> hi[i];

  int ans = 0;
  for(int i=0; i<n; i++){
    if( k <= hi[i] ) ans += 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main()
{
	int n,i,j;
	char s[222]={};

	scanf("%s",s);
	
	n=strlen(s);
	for(i=n-3;i>0;i-=2){
		char a[111]={},b[111]={};

		for(j=0;j<(i+1)/2;j++){
			a[j]=s[j];
			b[j]=s[j+(i+1)/2];
		}
		if(strcmp(a,b)==0){
			printf("%d",strlen(a)+strlen(b));
			return 0;
		}
	}
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

int main() {
    cin >> n >> m;
    cout << n + 1 - m << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<string>
#include<map>

using ll = long long;

int main(){
    ll n, k;
    std::cin >> n >> k;
    std::map<ll, ll> mp;
    for(int i = 0; i < n; i++){
        ll a, b;
        std::cin >> a >> b;
        mp[a] += b;
    }

    ll length = 0;
    for(auto m : mp){
        length += m.second;
        // std::cout << m.first << " " << m.second << std::endl;
        if(length >= k){
            std::cout << m.first << std::endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 4224
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

int search(vector<string>& s, int l, int pn) {
	if (s[l][pn-1] >= '0'&&s[l][pn-1] <= '9')return s[l][pn-1] - '0';
	if (s[l][pn-1] == '+') {
		int ret = 0;
		for (int i = l + 1; i < s.size(); i++) {
			if (s[i].size() > pn + 1)continue;
			if (s[i].size() == pn + 1) {
				ret += search(s, i, pn + 1);
				continue;
			}
			break;
		}
		return ret;
	}
	int ret = 1;
	for (int i = l + 1; i < s.size(); i++) {
		if (s[i].size() > pn + 1)continue;
		if (s[i].size() == pn + 1) {
			ret *= search(s, i, pn + 1);
			continue;
		}
		break;
	}
	return ret;
}

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

	cin >> N;
	vector<int>ans;
	while (N) {
		vector<string>v(N);
		for (int i = 0; i < N; i++)cin >> v[i];
		ans.push_back(search(v, 0, 1));
		cin >> N;
	}
	for (auto i : ans) {
		cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<pair<int,int> , null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update> 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fi first
#define se second
#define endl '\n'
#define int int64_t
#define double long double
#define fdt fuck donald trump
// mt19937 rnd(time(0));
// const int SMALL = LLONG_MIN >> 2;
const int BIG = LLONG_MAX >> 2;
const int MAXN = (int)2e5 + 3;
const int MOD = 998244353;

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
	// freopen("FDT.txt","r",stdin);
	int n, x, y;
	cin >> n >> x >> y;
	vector<vector<int>> g(n + 1);
	for(int i = 1; i < n; i ++){
		g[i].push_back(i + 1);
		g[i + 1].push_back(i);
	}
	g[x].push_back(y);
	g[y].push_back(x);
	auto shortest_path = [&](int source){
		queue<pair<int,int>> q;
		q.push({source, 0});
		vector<int> d(n + 1, BIG);
		d[source] = 0;
		while(q.size()){
			auto u = q.front();
			q.pop();
			if(u.se != d[u.fi])
				continue;
			for(int v: g[u.fi])
				if(d[v] == BIG){
					d[v] = d[u.fi] + 1;
					q.push({v, d[v]});
				}
		}
		return d;
	};
	vector<int> ans(n);
	for(int source = 1; source <= n; source ++){
		auto d = shortest_path(source);
		for(int i = 1; i <= n; i ++)
			ans[d[i]] ++;
	}
	for(int i = 1; i < n; i ++)
		cout << ans[i]/2 << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>

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

string solve(int X,int Y,int Z)
{
	//printf("%d %d %d\n",X,Y,Z);
	if(Y==0&&Z==0)
	{
		string ret="";
		for(int i=0;i<X;i++) ret+="A";
		return ret;
	}
	if(X==0)
	{
		string ret=solve(Y,Z,0);
		for(int i=0;i<ret.size();i++)
		{
			if(ret[i]=='A') ret[i]='B';
			else ret[i]='C';
		}
		return ret;
	}
	else if(Y==0)
	{
		string ret=solve(X,Z,0);
		for(int i=0;i<ret.size();i++) if(ret[i]=='B') ret[i]='C';
		return ret;
	}
	if(Z==0)
	{
		if(X%Y==0)
		{
			string ret="";
			for(int i=0;i<Y;i++)
			{
				for(int j=0;j<X/Y;j++) ret+="A";
				ret+="B";
			}
			return ret;
		}
		string ret=solve(X%Y,Y-(X%Y),0);
		string ans="";
		for(int i=0;i<ret.size();i++)
		{
			if(ret[i]=='A')
			{
				for(int j=0;j<=X/Y;j++) ans+="A";
				ans+="B";
			}
			else
			{
				for(int j=0;j<X/Y;j++) ans+="A";
				ans+="B";
			}
		}
		//printf("%d %d %d : %s\n",X,Y,Z,ans.c_str());
		return ans;
	}
	int z=X%(Y+Z),k=(X+Y+Z-1)/(Y+Z);
	if(z==0) z=Y+Z;
	if(z<=Z)
	{
		string ret=solve(z,Y,Z-z);
		string ans="";
		for(int i=0;i<ret.size();i++)
		{
			if(ret[i]=='A')
			{
				for(int j=0;j<k;j++) ans+="A";
				ans+="C";
			}
			else
			{
				for(int j=0;j<k-1;j++) ans+="A";
				ans+=ret[i];
			}
		}
		//printf("%d %d %d : %s\n",X,Y,Z,ans.c_str());
		return ans;
	}
	else
	{
		string ret=solve(z-Z,Z,Y-(z-Z));
		string ans="";
		for(int i=0;i<ret.size();i++)
		{
			if(ret[i]=='C')
			{
				for(int j=0;j<k-1;j++) ans+="A";
				ans+="B";
			}
			else
			{
				for(int j=0;j<k;j++) ans+="A";
				if(ret[i]=='A') ans+="B";
				else ans+="C";
			}
		}
		return ans;
	}
	return "";
}
int main()
{
	int X,Y,Z;
	scanf("%d %d %d",&X,&Y,&Z);
	string ret=solve(X,Y,Z);
	for(int i=0;i<ret.size();i++)
	{
		if(ret[i]=='A') ret[i]='a';
		if(ret[i]=='B') ret[i]='b';
		if(ret[i]=='C') ret[i]='c';
	}
	printf("%s\n",ret.c_str());
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
 
        try {
            String buffer[] = br.readLine().split("\\s+");
 
            int N = Integer.parseInt(buffer[0]);
            int M = Integer.parseInt(buffer[1]);
            int L = Integer.parseInt(buffer[2]);
 
            int A[][] = new int[N][M];
            int B[][] = new int[M][L];
 
            String buf_A[] = new String[M];
            String buf_B[] = new String[L];
 
            for(int row = 0; row < N; row++){
                buf_A = br.readLine().split("\\s+");
                for(int col = 0; col < M; col++){
                    A[row][col] = Integer.parseInt(buf_A[col]);
                }
            }
 
            for(int row = 0; row < M; row++){
                buf_B = br.readLine().split("\\s+");
                for(int col = 0; col < L; col++){
                    B[row][col] = Integer.parseInt(buf_B[col]);
                }
            }
 
            Long ans;
 
            for(int A_row = 0; A_row < N; A_row++){
                for(int B_col = 0; B_col < L; B_col++){
                    ans = 0L;
                    for(int B_row = 0; B_row < M; B_row++){
                        ans += A[A_row][B_row]*B[B_row][B_col];
                    }
                    if(B_col == 0){
                        System.out.printf("%d", ans);
                    }else{
                        System.out.printf(" %d", ans);
                    }
                }
                System.out.printf("\n");
            }
 
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 78412
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();
    int k = sc.nextInt();
    if ((b - a) / 2 >= k) {
      for (int i = 0; i < k && i < (a + b) / 2; i++) {
        System.out.println(a + i);
      }
      for (int i = k - 1; i >= 0; i--) {
        System.out.println(b - i);
      }
    } else {
      for (int i = a; i <= b; i++) {
        System.out.println(i);
      }
    }
  }

}


Measured memory_bytes: 22996
#include<stdio.h>

#include<iostream>
#include<string>

using namespace std ;

#define MAX_N 1000


bool IsSucceed( string *dat ,int *N )
{
	int succeed = true ;
	int begin = 0 ,end = *N - 1 ;
	while( succeed == true && begin < end )
	{
		succeed = (dat[ begin ] == dat[ end ]) ;

		++begin ;
		--end ;
	}
	
	return succeed ;
}

string horizontal[ MAX_N ] ;
string vertical[ MAX_N ] ;
int main( void )
{
	int C ,N ;
	scanf( "%d %d" ,&C ,&N ) ;

	int i ,j ;
	for( i = 0 ; i < N ; ++i )
	{
		cin >> horizontal[ i ] ;
	}

	for( i = 0 ; i < N ; ++i )
	{
		for( j = 0 ; j < N ; ++j )
		{
			vertical[ i ].insert( vertical[ i ].begin() + j ,horizontal[ j ][ i ] ) ;
		}
	}
	
	int ans = (IsSucceed( horizontal ,&N ) & IsSucceed( vertical ,&N )) == true ;
	
	for( i = 1 ; i < C ; ++i )
	{
		int c ;
		scanf( "%d" ,&c ) ;
		for( j = 0 ; j < c ; ++j )
		{
			int y ,x ;
			scanf( "%d %d" ,&y ,&x ) ; --y ; --x ;

			string::iterator p = vertical[ x ].begin() + y ;
			vertical[ x ].replace( p ,p ,vertical[ x ].substr( y ,1 ) == "0" ? "1" : "0" ) ; vertical[ x ].erase( vertical[ x ].begin() + y + 1 ) ;
			string::iterator _p = horizontal[ y ].begin() + x ;
			horizontal[ y ].replace( _p ,_p ,horizontal[ y ].substr( x ,1 ) == "0" ? "1" : "0" ) ; horizontal[ y ].erase( horizontal[ y ].begin() + x + 1 ) ;
		}

		ans += (IsSucceed( horizontal ,&N ) & IsSucceed( vertical ,&N )) == true ;
	}
	
	printf( "%d\n" ,ans ) ;

	return 0 ;
}


Measured memory_bytes: 5304
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, L):
    L.sort()
    ans = 0
    for i, a in enumerate(L):
        for j in range(i+1, N):
            b = L[j]
            l = max(a-b, b-a)
            r = a+b
            x = bisect.bisect_left(L, l, lo=j+1)
            y = bisect.bisect_left(L, r, lo=j+1)
            ans += y - x
            if x <= j <= y:
                ans -= 1
            if x <= i <= y:
                ans -= 1

    return ans


def main():
    N = read_int()
    L = read_int_n()
    print(slv(N, L))

    # N = 2 * (10**3)
    # L = [random.randint(1, 1000) for _ in range(N)]
    # print(slv(N, L))


if __name__ == '__main__':
    main()


Measured memory_bytes: 68216
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
typedef long long ll;

using namespace std;

int main(){
	ll a,b,m;
	cin>>a>>b>>m;
	ll x[a],y[b],mins1=100005,mins2=100005;
	for(int i=0;i<a;i++){
		cin>>x[i];
		mins1=min(mins1,x[i]);
	}
	for(int i=0;i<b;i++){
		cin>>y[i];
		mins2=min(mins2,y[i]);
	}
	ll mins=mins1+mins2;
	for(int i=0;i<m;i++){
		ll d,e,f,now;
		cin>>d>>e>>f;
		now=x[d-1]+y[e-1]-f;
		mins=min(now,mins);
	}
	cout<<mins;
}



Measured memory_bytes: 5128
# Queue

class MyQueue:
    def __init__(self):
        self.queue = [] # list
        self.top = 0
    
    def isEmpty(self):
        if self.top==0:
            return True
        return False
    
    def isFull(self):
        pass

    def enqueue(self, x):
        self.queue.append(x)
        self.top += 1
    
    def dequeue(self):
        if self.top>0:
            self.top -= 1            
            return self.queue.pop(0)
        else:
            print("there aren't enough values in Queue")

def main():
    n, q = map(int, input().split())
    A = [
        list(map(lambda x: int(x) if x.isdigit() else x, input().split()))
        for i in range(n)
    ]
    A = [{'name': name, 'time': time} for name, time in A]
    queue = MyQueue()
    for a in A:
        queue.enqueue(a)
    elapsed = 0
    while not queue.isEmpty():        
        job = queue.dequeue()        
        if job['time']>q:
            elapsed += q
            job['time'] = job['time'] - q
            queue.enqueue(job)
        else:
            elapsed += job['time']
            print(job['name']+ ' ' + str(elapsed))

main()


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

//E题
int main()
{
	int n, m;
	cin >> n >> m;
	int l1, r1,l2,r2;
	cin >> l1 >> r1;
	m--;
	while (m--)
	{
		cin >> l2 >> r2;
		if (l2 > l1) l1 = l2;
		if (r2 < r1) r1 = r2;
	}
	if (r1 < l1) cout << 0<<endl;
	else {
		cout << r1 - l1 + 1 << endl;
	}
}

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

using namespace std;

int main()
{
  int n;
  cin>>n;
  map<string,int>m;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    ++m[s];
  }
  int ans=0;
  for(auto it=m.begin();it!=m.end();it++){
    if(it->second>0){
        ++ans;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 19152
#include<iostream> 
using namespace std; 
int main() 
{ 
    long long a,b,c; 
    cin>>a>>b>>c; 
    if(a<=b&&c<=b)cout<<a+c<<endl;
    else if(b<=a&&a<=c)cout<<b+a<<endl;
    else if(b<=a&&c<=a)cout<<b+c<<endl;
    else if(c<=a&&a<=b)cout<<c+a<<endl;
    else if(a<=b&&b<=c)cout<<a+b<<endl;
    return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n;

int data[100];
int allsum;
long long int dp[100][21];

long long int check(int i,int sum)
{
  //  cerr<<i<<" "<<sum<<endl;

  if(sum>20 || sum<0)
    return 0;
  if(i>=n-1)
    return 0;
  if(dp[i][sum]!=-1)
    return dp[i][sum];
  if(i==n-2)
    {
      if(sum==allsum)
        return 1;
      else
        return 0;
    }

  long long int ans=check(i+1,sum+data[i+1])+check(i+1,sum-data[i+1]);

  dp[i][sum]=ans;
  return dp[i][sum];
}

int main()
{
  cin>>n;
  for(int i=0;i<n-1;i++)
    {
      cin>>data[i];
    }
  cin>>allsum;
  memset(dp,-1,sizeof(dp));

  long long int ans=check(0,data[0]);
  cout<<ans<<endl;

}

Measured memory_bytes: 1180
fun main(args: Array<String>) {
    val (n, blue, red) = getLongs()

    if (n <= blue + red) {
        if (n <= blue) println(n)
        else println(blue)
    } else {
        val k = n / (blue + red)
        val remain = n % (blue + red)
        if (remain <= blue) println(blue * k + remain)
        else println(blue * k + blue)
    }
}


fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }
fun getLong() = readLine()!!.toLong()
fun getLongs() = readLine()!!.split(" ").map { it.toLong() }

Measured memory_bytes: 37744
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        int l = s.length();
        if (l==1){
            System.out.println(Integer.valueOf(s));
        }
        else if (is_9(s)){
            int n = s.charAt(0);
            System.out.println(9*(l-1)+n-48);
        }
        else {
            int n = s.charAt(0);
            System.out.println((l-1)*9+n-49);
        }
    }
    public static boolean is_9(String s){
        for (int i=1;i<s.length();i++){
            if (s.charAt(i)!=57)
                return false;
        }
        return true;
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()


typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

#ifdef TESTING
#define DEBUG fprintf(stderr,"====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG 
#define VALUE(x)
#define debug(...)
#endif
/*
inline string IntToString(ll a) {
	char x[100];
	sprintf_s(x, "%lld", a); string s = x;
	return s;
}

inline ll StringToInt(string a) {
	char x[100]; ll res;
	strcpy_s(x, a.c_str()); sscanf_s(x, "%lld", &res);
	return res;
}
*/

inline string uppercase(string s) {
	int n = SIZE(s);
	rep(i, n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
	return s;
}

inline string lowercase(string s) {
	int n = SIZE(s);
	rep(i, n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
	return s;
}


int main()
{
	int n,ans = 0;
	cin >> n;
	vi v(n),a(8);
	int ex = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		if (v[i] >= 1 && v[i] < 400)
			a[0]++;
		if (v[i] >= 400 && v[i] < 800)
			a[1]++;
		if (v[i] >= 800 && v[i] < 1200)
			a[2]++;
		if (v[i] >= 1200 && v[i] < 1600)
			a[3]++;
		if (v[i] >= 1600 && v[i] < 2000)
			a[4]++;
		if (v[i] >= 2000 && v[i] < 2400)
			a[5]++;
		if (v[i] >= 2400 && v[i] < 2700)
			a[6]++;
		if (v[i] >= 2800 && v[i] < 3200)
			a[7]++;
		if (v[i] >= 3200)
			ex++;
	}
	rep(i, 8) {
		if (a[i] != 0)
			ans++;
		//cout << a[i] << " ";
	}
	//cout << endl;
	//cout << ex << endl;//(to debug)
	if (ans == 0)
		cout << "1 " << ex << endl;
	else
		cout << ans << " " << ans + ex << endl;
 	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int ans[3][3] =
{
    {1, 2, 3},
    {4, 5, 6},
    {7, 8, 0}
};
int dx[] = { 0, 1, 0, -1 };
int dy[] = { -1, 0, 1, 0 };

bool match(int f[3][3]) {
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (f[i][j] != ans[i][j])
                return false;
        }
    }
    return true;
}

int dfs(int f[3][3], int x, int y, int v, int d, int l) {
    if (match(f))
        return d;
    if (d > l)
        return -1;
    for (int i = 0, res; i < 4; ++i) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (nx < 0 || nx > 2 || ny < 0 || ny > 2 || (i + 2) % 4 == v)
            continue;
        f[y][x] = f[ny][nx];
        f[ny][nx] = 0;
        if ((res = dfs(f, nx, ny, i, d + 1, l)) > 0)
            return res;
        f[ny][nx] = f[y][x];
        f[y][x] = 0;
    }
    return -1;
}

int main() {
    int f[3][3], x, y;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> f[i][j];
            if (f[i][j] == 0) {
                y = i;
                x = j;
            }
        }
    }

    int res;
    for (int i = 1; i < 50; ++i) {
        if ((res = dfs(f, x, y, -1, 0, i)) >= 0) {
            break;
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3116
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7, MAX = 1e9, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = 0, max_index = 0;
long long min_value = MAX, min_index = 0;
long long sum = 0;

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

int main() {
    map<string, int> m;
    cin >> N;
    string s;
    cin >> s;
    m[s] = 0;
    char c = s[s.size()-1];
    bool flag = true;
    rep(i, N-1){
        cin >> s;
        if(s[0] != c){
            flag = false;
        }
        if(m.find(s) == m.end()) m[s] = 0;
        else{
            flag = false;
        }
        c = s[s.size()-1];
    }
    if(flag) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)
#define VI vector<int>
#define VD vector<double>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVC vector<VC>
#define VVS vector<VS>
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define me min_element
#define Me max_element
#define mp make_pair
#define fi first
#define se second
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define sortup(vec) sort(all(vec))
#define sortdown(vec) sort(lla(vec))
template<class T>void mini(T &a,T b){a=min(a,b);}
template<class T>void maxi(T &a,T b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__);
#define out(...) _cout(__VA_ARGS__);
void _cin(){}template<class Head,class...Tail>void _cin(Head&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
template<class Head>void _cout(Head head){cout<<head<<endl;}template<class Head,class...Tail>void _cout(Head head,Tail...tail){cout<<head<<" ";_cout(forward<Tail>(tail)...);}
void addin(){}template<class Head,class...Tail>void addin(vector<Head>&vechead,Tail&&...tail){in(Head,head);vechead.emb(head);addin(forward<Tail>(tail)...);}
template<class C>void vecout(vector<C> vec){int vecsize=si(vec);fou(i,0,vecsize-1)cout<<vec[i]<<" ";out(vec[vecsize-1]);}
template<class C> C gcd(C a,C b){if(a&&b)return gcd(min(a,b),max(a,b)%min(a,b));else return a;}template<class C> C lcm(C a,C b){return a/gcd(a,b)*b;}

#define int int64_t
// #define double long double


signed main(){
  IOS;

  in(int,n,i);
  out(n-i+1);
}

Measured memory_bytes: 256