akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;
using P = pair<int, int>;

const int mod = 1000000007; // 998244353;
struct mint {
  long long x;
  mint(long long x=0) : x((x%mod+mod)%mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint& a) const {
    return mint(*this) += a;
  }
  mint operator-(const mint& a) const {
    return mint(*this) -= a;
  }
  mint operator*(const mint& a) const {
    return mint(*this) *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint& a) { return *this *= a.inv(); }
  mint operator/(const mint& a) const {
    return mint(*this) /= a;
  }
};
istream& operator>>(istream& is, const mint& a) {
  return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
  return os << a.x;
}

using P = pair<int, int>;

int main() {
  int n, k;
  cin >> n >> k;
  vector<P> s;
  for (int i = 1; i * i <= n; i++) {
    s.push_back(P(i, 0));
    s.push_back(P(n/i, 0));
  }
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  int m = s.size();
  rep(i,m) {
    if (i == 0) s[i].se += s[i].fi;
    else s[i].se += s[i].fi - s[i-1].fi;
  }

  vector<vector<mint>> dp(k+1, vector<mint>(m));
  dp[0][m-1] = 1;
  rep(i,k) {
    for (int j = m-2; j>=0; j--) dp[i][j] += dp[i][j+1];
    rep(j,m) {
      int l = m - j - 1;
      dp[i+1][j] += dp[i][l] * s[l].se;
    }
  }
  mint ans = 0;
  rep(j,m) ans += dp[k][j];
  cout << ans << endl;
  return(0);
}

Measured memory_bytes: 54460
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;


int main() {
	long long int S, tmp = 0, min = 9999999999, D, number, result;;

	cin >> S;

	D = S;

	int count = 0;

	while (D != 0) {
		D /= 10;
		count += 1;
	}

	for (int i = count - 1; i > 1; i--) {
		tmp = 0;
		number = S / pow(10, i);
		number %= 10;
		tmp += number * 100;
		number = S / pow(10, i - 1);
		number %= 10;
		tmp += number * 10;
		number = S / pow(10, i - 2);
		number %= 10;
		tmp += number;

		result = abs(753 - tmp);
		if (min > result) min = result;
	}


	cout << min;

	return 0;
}

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

    int main() {
        int num;
        int score_a=0,score_b=0;
        cin >> num;
        vector<int> score(num);
        for(int i=0;i<num;i++){
            cin >> score.at(i);
        }
        sort(score.begin(),score.end());
        reverse(score.begin(),score.end());
        for(int i=0;i<num;i++){
            if(i%2!=0){
                score_b += score.at(i);
            }else{
                score_a += score.at(i);
            }
        }
        cout << score_a - score_b << endl;
        }

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


def main():
    # 整数の入力
    x, y = map(int, input().split())

    for i in range(x + 1):
        for j in range(y + 1):
            if(i + j == x and 2 * i + 4 * j == y):
                print("Yes")
                exit(0)
    
    print("No")



if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    S = "00" + S;
    int ans = 0;
    string T = S;
    RREP(i, S.length() - 1, 0) {
        if (S[i] > '9') {
            S[i] = '0';
            S[i - 1] += 1;
        }
        int num = S[i] - '0';
        int num2 = S[i - 1] - '0';
        if ((S[i] == '5' && S[i - 1]  >= '5') || S[i] >= '6') {
            S[i - 1] += 1;
            S[i] = '0';
            ans += -num + 10;
        } else{
            ans += num;
        }
    }
    //cout << S << endl;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2332
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	ll f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int inf=0x3f3f3f3f;
inline bool chkmax(int &x,int y){return (y>x)?(x=y,1):0;}
inline bool chkmin(int &x,int y){return (y<x)?(x=y,1):0;}
int d[11][11],f[101][101];
int main(){
	int A=read(),B=read();
	REP(i,1,A) REP(j,1,B) d[i][j]=read();
	REP(i,0,100) REP(j,0,100)
		REP(x,1,A) REP(y,1,B)
			chkmax(f[i][j],d[x][y]-x*i-y*j);
	REP(x,1,A) REP(y,1,B){
		int dis=inf;
		REP(i,0,100) REP(j,0,100) chkmin(dis,f[i][j]+i*x+j*y);
		if(dis!=d[x][y]){
			printf("Impossible\n");
			return 0;
		}
	}
	int n=202,m=101*101+200;
	printf("Possible\n");
	printf("%d %d\n",n,m);
	REP(i,1,100) printf("%d %d X\n",i,i+1);
	REP(i,102,201) printf("%d %d Y\n",i,i+1);
	REP(i,0,100)
		REP(j,0,100)
			printf("%d %d %d\n",i+1,202-j,f[i][j]);
	printf("%d %d\n",1,n);
	return 0;
}

Measured memory_bytes: 384
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools, bisect
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007
INF = float("inf")

def main():
    N, K, C = LI()
    S = SL()

    L = []
    rest = C
    for i, ch in enumerate(S):
        if ch == "o" and rest >= C:
            rest = -1
            L.append(i)
        rest += 1

    R = []
    rest = C
    for i, ch in list(enumerate(S))[::-1]:
        if ch == "o" and rest >= C:
            rest = -1
            R.append(i)
        rest += 1
        
    for a, b in zip(L[:K], R[:K][::-1]):
        if a == b:
            print(a + 1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 137768
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}

template<class T>
class SegmentTreeMax{
    int n = 0;
    std::vector<T> dat;
public:
    SegmentTreeMax(){}
    SegmentTreeMax(int m, T fill = -INF){
        int i = 1;
        while(i < m) i *= 2;
        n = i;
        dat.resize(2*i - 1);
        for(int j(0), j_len(2*i-1); j < j_len; ++j)
            dat[j] = fill;
    }

    void update(int k, T a){
        k += n - 1;
        int moto = dat[k];
        dat[k] = a;
        while(k){
            k = (k - 1) / 2;
            dat[k] = std::max(dat[2*k+1], dat[2*k+2]);
        }
    }

    T getMax(int a, int b, int k=0, int l=0, int r=-1){
        //[a, b[であることに注意
        if(r < 0) r = n;
        if(r <= a || b <= l) return -INF;
        if(a <= l && r <= b) return dat[k];

        T vl(getMax(a, b, 2*k+1, l, (l+r)/2));
        T vr(getMax(a, b, 2*k+2, (l+r)/2, r));
        return std::max(vl, vr);
    }

    T getvalue(int k){
        return dat[k+n-1];
    }
};


int main(){
    int N; std::cin >> N;
    SegmentTreeMax<long long> segtm(N+1, 0);
    std::vector<int> h(N);
    for(int i(0); i < N; ++i) std::cin >> h[i];
    {
        int a;
        for(int i(0); i < N; ++i){
            std::cin >> a;
            segtm.update(h[i], segtm.getMax(0, h[i])+a);
        }
    }
    std::cout << segtm.getMax(0, N+1) << std::endl;
    return 0;
}


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

const int N = 100005;

using namespace std;

char s[N];
int n, m, l[N], r[N], x[N / 2], root[N / 2], sz[N / 2];

inline int Root(int x)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x]);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    scanf("%s%d", s, &n);
    m = strlen(s);
    for (int i = 0; i < n; i++)
    {
        scanf("%d%d", &l[i], &r[i]);
        l[i]--, r[i]--;
    }
    if (m & 1)
    {
        int pos = m >> 1;
        for (int i = 0; i < n; i++)
        {
            if (l[i] == pos && r[i] == pos)
            {
                n--;
                swap(l[i], l[n]);
                swap(r[i], r[n]);
                i--;
                continue;
            }
            if (l[i] > pos) l[i]--;
            if (r[i] >= pos) r[i]--;
        }
        m--;
        for (int i = pos; i < m; i++) s[i] = s[i + 1];
    }
    int len = m >> 1;
    for (int i = 0; i < n; i++)
    {
        if (l[i] < len && r[i] >= len)
        {
            int p1 = len - l[i], p2 = r[i] - len + 1;
            if (p1 == p2) l[i] = -1, r[i] = -1;
            if (p1 < p2)
            {
                l[i] += 2 * p1;
            }
            if (p1 > p2)
            {
                r[i] -= 2 * p2;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (l[i] >= len)
        {
            int rr = m - 1 - l[i];
            int ll = m - 1 - r[i];
            l[i] = ll, r[i] = rr;
        }
    }
    for (int i = 0; i < len; i++)
    {
        x[i + 1] = s[m - 1 - i] - s[i];
    }
    for (int i = len + 1; i > 0; i--)
    {
        x[i] -= x[i - 1];
    }
    for (int i = 0; i < n; i++)
    {
        l[i]++, r[i]++, r[i]++;
    }
    iota(root, root + len + 2, 0);
    fill(sz, sz + len + 2, 1);
    for (int i = 0; i < n; i++)
    {
        int a = Root(l[i]), b = Root(r[i]);
        if (a == b) continue;
        if (sz[a] < sz[b])
        {
            sz[b] += sz[a];
            x[b] += x[a];
            root[a] = b;
        }
        else
        {
            sz[a] += sz[b];
            x[a] += x[b];
            root[b] = a;
        }
    }
    for (int i = 0; i < len + 2; i++)
    {
        if (x[Root(i)] % 26 != 0)
        {
            puts("NO"), exit(0);
        }
    }
    puts("YES");
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
int x, y, z, r, w, h, a=0, b=0;
string ans;
cin >> w >>h >> x>>y>>r;
w-=r;
h-=r;
a+=r;
b+=r;
if(a<=x && x<=w && b<=y && y<=h) {ans="Yes";}
else {ans="No";};
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    ll N, H; cin >> N >> H;
    vel a(N), b(N); rep(i,N) cin >> a[i] >> b[i];

    sort(rall(a)); sort(rall(b));

    int cnt = 0;
    rep(i,N) {
        if(b[i] > a[0]) { H -= b[i]; cnt++; }
        if(H <= 0) break;
    }
    if(H <= 0) {cout << cnt << endl; return 0;}
    
    while(true) {
        H -= a[0];
        cnt++;
        if(H <= 0) break;
    } 
    cout << cnt << endl;
    return 0;

    
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
int main()
{
        //input->compute->output//
        int X, Y, Z, K;
        cin >> X >> Y >> Z >> K;
        vector<ll> A(X), B(Y), C(Z);
        for (int i = 0; i < X; i++)
        {
                cin >> A[i];
        }
        for (int i = 0; i < Y; i++)
        {
                cin >> B[i];
        }
        for (int i = 0; i < Z; i++)
        {
                cin >> C[i];
        }
        sort(C.begin(), C.end());
        reverse(C.begin(), C.end());

        vector<ll> AB(X * Y);
        for (int i = 0; i < X; i++)
        {
                for (int j = 0; j < Y; j++)
                {
                        AB.push_back(A[i] + B[j]);
                }
        }
        sort(AB.begin(), AB.end());
        reverse(AB.begin(), AB.end());

        vector<ll> ABC;

        for (int i = 0; i < min(K, (int)AB.size()); i++)
        {

                for (int j = 0; j < Z; j++)
                {
                        ABC.push_back(AB[i] + C[j]);
                }
        }

        sort(ABC.begin(), ABC.end());
        reverse(ABC.begin(), ABC.end());

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

        return 0;
}


Measured memory_bytes: 58868
use std::io::stdin;
use std::str::FromStr;

fn main(){
    let xs: Vec<i64> = get_vec();
    let (w, h, x, y) = (xs[0], xs[1], xs[2], xs[3]);
    let m = if x*2==w && y*2==h {1} else {0};
    println!("{} {}", (w as f64*h as f64)/2., m);
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}

#[allow(dead_code)]
fn vec_min(xs: &Vec<i64>) -> i64 {
    xs.iter().map(|&x|x).fold(std::i64::MAX, std::cmp::min)
}

#[allow(dead_code)]
fn vec_max(xs: &Vec<i64>) -> i64 {
    xs.iter().map(|&x|x).fold(std::i64::MIN, std::cmp::max)
}

#[allow(dead_code)]
fn vec_sum(xs: &Vec<i64>) -> i64 {
    xs.iter().fold(0, |acc, &x| acc+x)
}


Measured memory_bytes: 4352
/*
 KUNAL RAUT (ZUKONIT14)  :- "DO WHAT YOU LIKE!"
 -PICT,PUNE! :)
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 1000005
#define N 1000001
#define MAX2N 1*1000 + 10
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define forci(p,n) for(ll i=p;i<(ll)n;i++)
#define forcj(p,n) for(ll j=p;j<(ll)n;j++)
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a) __builtin_popcount(a)
#define test ll t;cin>>t;for(ll testi=1;testi<=t;testi++)
#define djokovic  freopen("input00.txt", "r", stdin);freopen("output00.txt", "w", stdout);
ll gcd(ll a, ll b) {    if (b == 0) return a;    return gcd(b, a % b);}
ll lcm(ll a, ll b) {    return (a / gcd(a, b) * b);}
ll expo(ll x, ll y) {
    ll res = 1; x = x % mod; while (y > 0) {
        if (y & 1)res = (1ll * res * x) % mod;
        y = y >> 1; x = (1ll * x * x) % mod;
    } return res;
}
ll ncr(ll n, ll r) { ll res = 1; if (r > n - r)r = n - r; for (ll i = 0; i < r; i++) {  res *= n - i;  res /= i + 1; } return res;}
ll max(ll a, ll b) {return (a > b) ? a : b;}
bool prime(ll n) {ll i; for (i = 2; i <= sqrt(n); i++) {if (n % i == 0)return false;} return true;}
bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b)
{   if (a.second == b.second)
        return a.first < b.first;
    return (a.second < b.second);
}

//https://www.youtube.com/watch?v=WTJSt4wP2ME

ll rr[] = {0, 1, 1, 1, 0, -1, -1, -1};
ll cc[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll n, m, ans[MAXN], mini[MAXN], a[MAXN];
void solve()
{
    ld n; cin >> n; cout << 2 * pi*n;
}
signed main()
{
    bolt;
//#ifndef ONLINE_JUDGE
  //  djokovic;
//#endif
    solve();
}




Measured memory_bytes: 3796
#include <iostream>

using namespace std;

int main()
{
    int n,k,q,r;
    cin>>n>>k>>q;
    int p=q;
    int a[n];
    for(int i=0; i<n; i++)
    a[i]=k;

        while(p--)
        {
            cin>>r;
            a[r-1]=a[r-1]+1;
        }
    for(int i=0; i<n; i++)
    {
        if(a[i]-q>0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	int a, b; cin >> a >> b;
	cout << min(a, b) << " " << max(0, a + b - n) << endl;
	return 0;
}

Measured memory_bytes: 256
K, A, B = list(map(int, input().split()))

if A + 2 < B:
    if K <= A - 1:
        print(K + 1)
    else:
        K -= A - 1
        num = A + (B - A) * (K // 2) + (K % 2)
        print(num)

else:
    print(K + 1)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll N,M;
    cin >> N >> M;
    ll X[M];
    ll diff[M-1];
    for(int i = 0; i<M;i++)
        cin >> X[i];
    sort(X,X+M);
    ll ans = 0;
    for(int i = 0; i < M-1;i++)
        diff[i] = X[i+1] - X[i];
    int count = N - M;
    int i = 0;
    sort(diff,diff+M-1);
    while(count < 0){
        ans += diff[i];
        i++;
        count++;
    }
    cout << ans << "\n";
    return 0; 
}


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

using namespace std;
map<string,pair<int,int> > used;
string rev(string s,int start,int enddy)
{
    while(start < enddy)
    {
        swap(s[start],s[enddy]);
        start++;
        enddy--;
    }
    return s;
}
vector<int> rep[27];
int main()
{
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    for(int i = 0;i < s.length();i++)
        rep[s[i] - 'a'].push_back(i);

    long long diff2 = 0;
    for(int i = 1;i < s.length();i++)
    {
        vector<int>::iterator it = lower_bound(rep[s[i-1]-'a'].begin(),rep[s[i-1] - 'a'].end(),i);
        diff2 += s.length() - i - 1;
        diff2 -= rep[s[i-1]-'a'].end() - it;
        //cout << (s.length() - i - 1) - (rep[s[i-1]-'a'].end() - it) << endl;
    }
    cout << diff2 + s.length() ;
    /*long long diff = 0;
    for(int i = 0;i < s.length();i++)
    {
        for(int j = i+1;j < s.length();j++)
        {
            if(used.find(rev(s,i,j)) == used.end())
            {
                diff++;
                used[rev(s,i,j)] = {i,j};
            } else {
                //cout << i << " " << j << endl;
            }
        }
    }
    cout << diff;*/
    return 0;
}


Measured memory_bytes: 1908
S = input()
X = "abcdefghijklmnopqrstuvwxyz"
S_index = sorted(set(S), reverse = True)
S_list = list(S_index)
X_list = list(sorted(X, reverse = True))
answer = None
for i in X_list:
  for n in S_list:
    if i == n:
      break
    elif n == S_list[-1]:
      answer = i
print(answer)

Measured memory_bytes: 3188
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 200010;
const int INF = 2147483600;

int N,M; 
int dfn[MAXN+1],low[MAXN+1],tim;
int Node[MAXN<<1],Next[MAXN<<1],Root[MAXN+1],cnt;
int fa[MAXN+1]; bool hv[MAXN+1];

inline void insert(int u,int v){
	Node[++cnt]=v; Next[cnt]=Root[u]; Root[u]=cnt; return ;
} int pt;

inline void Tarjan(int k){
	dfn[k]=low[k]=++tim; int son=0;
	for(int x=Root[k];x;x=Next[x]){
		int v=Node[x]; if(!dfn[v]){
			++son; fa[v]=k; Tarjan(v);
			low[k]=min(low[k],low[v]);
			if((fa[k]==-1&&son>1)||(fa[k]!=-1&&dfn[k]<=low[v]))
				hv[k]=1;
		} else low[k]=min(low[k],dfn[v]);
	} if(hv[k]) ++pt;
}
int deg[MAXN+1],mx=0,tot=0;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(),M=read();
	for(int i=1;i<=M;i++){
		int u=read(),v=read();
		insert(u,v); insert(v,u);
		++deg[u]; ++deg[v];
	} for(int i=1;i<=N;i++)
		if(deg[i]&1){ puts("No"); return 0; }
	fa[1]=-1; Tarjan(1);
	for(int i=1;i<=N;i++){
		if(deg[i]>mx) mx=deg[i],tot=1;
		else if(deg[i]==mx) ++tot;
	} if(mx==4&&pt<2&&tot<=2){
		puts("No"); return 0;
	} if(mx==2){
		puts("No"); return 0;
	} puts("Yes");
	return 0;
}




Measured memory_bytes: 13204
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll dp[1000010][2];

signed main(){
    string N;
    cin >> N;
    dp[0][1] = 1;
    REP(i, N.length()){
        dp[i + 1][0] = min(dp[i][0] + N[i] - '0', dp[i][1] + 10 - (N[i] - '0'));
        dp[i + 1][1] = min(dp[i][0] + N[i] - '0' + 1, dp[i][1] + 10 - (N[i] - '0') - 1);
    }
    PRINT(dp[N.length()][0]);
    return 0;
}

Measured memory_bytes: 20016
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
#define REP(i, a, b) for(int i = int(a); i <= int(b); i++)
#define LOOP(i, v) for(int i = 0; i < v.size(); i++)
#define EPS 1e-9
#define INF 1e12
#define debug(x) cerr << "DEBUG : " << (#x) << " => " << (x) << endl

vi ngb[100001];
int where[100001];

vi all;

void dp(int a, int w)
{
  if(where[a] == -1)
  {
    all.push_back(a);
    where[a] = w;
    LOOP(i, ngb[a]) dp(ngb[a][i], w);
  }
}

int main()
{
  int N, M, x, y;
  vi p;
  
  scanf("%d %d", &N, &M);
  
  p.resize(N+1);
  
  REP(i, 1, N) scanf("%d", &p[i]);
  
  REP(i, 0, M-1)
  {
    scanf("%d %d", &x, &y);
    ngb[x].push_back(y);
    ngb[y].push_back(x);
  }
  
  REP(i, 1, N) where[i] = -1;
  
  int enc = 0;
  int ans = 0;
  REP(i, 1, N)
  {
    if(where[i] == -1)
    {
      enc++;
      all.resize(0);
      dp(i, enc);
      LOOP(j, all)
      {
        if(where[p[all[j]]] == enc) ans++;
      }
    }
  }
  
  printf("%d\n", ans);
    
  return 0;
}

Measured memory_bytes: 10108
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<pair<pair<string, int>, int>> sp(n);
    for (int i = 0; i < n; i++)
    {
        string s;
        int p;
        cin >> s >> p;
        sp[i] = make_pair(make_pair(s, -p), i);
    }
    sort(sp.begin(), sp.end());
    for (int i = 0; i < n; i++)
    {
        cout << sp[i].second+1 << endl;
    }
    
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.equals("SUN")) System.out.println(7);
		else if(s.equals("MON")) System.out.println(6);
		else if(s.equals("TUE")) System.out.println(5);
		else if(s.equals("WED")) System.out.println(4);
		else if(s.equals("THU")) System.out.println(3);
		else if(s.equals("FRI")) System.out.println(2);
		else if(s.equals("SAT")) System.out.println(1);
	}
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> x(n), y(n), z(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> z[i];
  }
  ll r = 0;
  for (auto sx : {-1, 1}) {
    for (auto sy : {-1, 1}) {
      for (auto sz : {-1, 1}) {
        vector<vector<ll>> dp(n + 1, vector<ll>(m + 1, (ll)-1e13));
        dp[0][0] = 0;
        for (int i = 1; i <= n; i++) {
          dp[i][0] = 0;
          for (int j = 1; j <= m; j++) {
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - 1] + sx * x[i - 1] + sy * y[i - 1] + sz * z[i - 1]);
          }
        }
        r = max(r, dp[n][m]);
      }
    }
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 8192
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll n, k;
    cin >> n >> k;

    vector<pair<ll,ll>> vec(n);
    rep(i, n){
        ll t, d;
        cin >> t >> d;
        vec[i] = {d, t};
    }

    sort(all(vec), greater<pair<ll,ll>>());

    ll now = 0;
    map<ll,ll> mp;
    set<ll> uni;
    priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> other;
    for(int i = 0; i < k; i++){
        if(uni.find(vec[i].second) != uni.end()){
            other.push(vec[i]);
            mp[vec[i].second]++;
        } else {
            uni.insert(vec[i].second);
            mp[vec[i].second]++;
        }
        now += vec[i].first;
    }
    ll ans = now + (ll)uni.size() * (ll)uni.size();
    for(int i = k; i < n; i++){
        if(uni.find(vec[i].second) == uni.end()){
            if(other.empty()) continue;
            uni.insert(vec[i].second);
            now += vec[i].first;
            mp[vec[i].second]++;
            
            pair<ll,ll> rem = other.top();
            now -= rem.first;
            mp[rem.second]--;
            other.pop();

            ans = max(now + (ll)uni.size() * (ll)uni.size(), ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9464
#include<algorithm>  
#include<iostream>  
#include<stdio.h>  
#include<cmath>  
using namespace std;
int n, a[100005], b[5];
int main() 
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
	{
		if (a[i] & 1)
		{ 
			b[1]++; 
			continue;
		}
		if (a[i] % 4 == 0) 
			b[4]++;
		else if 
			(a[i] % 2 == 0) b[2]++;
	}
	if (!b[2] && b[1] > b[4] + 1)
	{
		printf("No");
		return 0;
	}
	if (b[2] && b[1] > b[4])
	{
		printf("No");
		return 0;
	}
	printf("Yes");
	return 0;
}

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

int h[7][100010],ans[100010];
int p[100010],q[100010],p1[100010],q1[100010],a[100010],b[100010],c[100010],d[100010],n,k;
bool vis[100010];

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void print(int x)
{
	static char s[233];
	if (!x) { putchar('0');putchar(' ');return; }
	int tot=0;
	for (;x;x/=10) s[++tot]=x%10+'0';
	for (;tot;tot--) putchar(s[tot]);
	putchar(' ');
}

int main()
{
	n=rd();k=rd();
	for (int i=1;i<=n;i++) p[i]=rd();
	for (int i=1;i<=n;i++) q[i]=rd();
	for (int i=1;i<=n;i++) p1[p[i]]=i,q1[q[i]]=i;
	for (int i=1;i<=n;i++) a[i]=p[i];
	for (int i=1;i<=n;i++) b[i]=q1[a[i]];
	for (int i=1;i<=n;i++) a[i]=b[i];
	for (int i=1;i<=n;i++) b[i]=p1[a[i]];
	for (int i=1;i<=n;i++) a[i]=b[i];
	for (int i=1;i<=n;i++) b[i]=q[a[i]];
	for (int i=1;i<=n;i++) a[i]=b[i];
	int hh=(k-1)/6;
	for (int i=1;i<=n;i++) if (!vis[i])
	{
		int tt=0;
		for (int j=i;!vis[j];j=a[j]) d[tt++]=j,vis[j]=true;
		for (int j=0;j<tt;j++) b[d[j]]=d[(j+hh)%tt];
	}
	for (int i=1;i<=n;i++) c[b[i]]=i;
	for (int i=1;i<=n;i++) h[1][i]=p[i],h[2][i]=q[i];
	for (int i=1;i<=4;i++)
	{
		for (int j=1;j<=n;j++) a[h[i][j]]=j;
		for (int j=1;j<=n;j++) h[i+2][j]=h[i+1][a[j]];
	}
	int now=k-hh*6;
	for (int i=1;i<=n;i++) ans[i]=c[i];
	for (int i=1;i<=n;i++) a[i]=h[now][ans[i]];
	for (int i=1;i<=n;i++) ans[i]=a[i];
	for (int i=1;i<=n;i++) a[i]=b[ans[i]];
	for (int i=1;i<=n;i++) ans[i]=a[i];
	for (int i=1;i<=n;i++) print(ans[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 7168
using System;
class AOJ
{
    public static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        int[,] ca = new int[4,13];
        for (int i = 0; i < a; i++)
        {
            string[] st = Console.ReadLine().Split(' ');
            int sy=0;
            if (st[0] == "S")
                 sy = 0;
            else if (st[0] == "H")
                sy = 1;
            else if (st[0] == "C")
                sy = 2;
            else if (st[0] == "D")
                sy = 3;
            int nu = int.Parse(st[1]);
            ca[sy,nu - 1] = 1;
        }
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 13; j++)
            {
                if (ca[i,j] == 0)
                {
                    if (i == 0)
                        Console.Write("S ");
                    else if (i == 1)
                        Console.Write("H ");
                    else if (i == 2)
                        Console.Write("C ");
                    else if (i == 3)
                        Console.Write("D ");
                    Console.WriteLine(j + 1);
                }
            }
        }
    }
}

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

int maxi;
vector<vector<int>> graph(100000);
vector<int> col(100000, -1);

map<pair<int, int>, int> m;

void dfs(int v, int color) {
    maxi = max(maxi, color);

    int c (color == 1 ? 2 : 1); 

    col.at(v) = color;

    for (int i = 0; i < (int)graph.at(v).size(); i++) {
        if (col.at(graph.at(v).at(i)) != -1) continue;

        dfs(graph.at(v).at(i), c);
        m[make_pair(v, graph.at(v).at(i))] = c;

        c++;
        if (c == color) c++;
    }
}

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> edges(n - 1);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph.at(a).push_back(b);
        graph.at(b).push_back(a);

        edges.at(i) = make_pair(a, b);
    }

    dfs(0, 0);

    cout << maxi << endl;
    for (int i = 0; i < n - 1; i++) {
        int a = edges.at(i).first, b = edges.at(i).second;
        cout << m[make_pair(a, b)] << endl;
    }
}

Measured memory_bytes: 16256
#include <stdio.h>
#define MAX 100
int main(){
  int i,n,p,a[MAX],mod,frag=0;
  long long int sum=1;
  scanf("%d %d",&n ,&p);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
    for(i=0;i<n;i++){
      mod=a[i]%2;
      //printf("%d",mod);
      sum*=2;
    if(mod!=0){
      frag=1;
    }
  }
  //printf("%d\n",frag);
  if(frag==0 & p==1){
    printf("0\n");
  }
  if(frag==0 & p==0){
    printf("%lld\n",sum);
  }
  if(frag==1){
    //printf("%ld\n",sum);
    printf("%lld\n",sum/2);
  }
  return 0;
}


Measured memory_bytes: 128
fn main() {
    let scan = std::io::stdin();
    
    let mut line = String::new();
    let _ = scan.read_line(&mut line);

    let mut line2 = String::new();
    let _ = scan.read_line(&mut line2);

    let s = [line.trim(), line.trim()].concat();

    if s.contains(line2.trim()) == false {
        println!("No");
    } else {
        println!("Yes");
    }
}



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

int N;
int a[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }  
  int neg = 0, pos = 0;
  int an = 0, ap = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] > 0) {
      pos = pos + a[i];
      ap++;
    }
  }
  for (int i = N-1; i >= 0; i--) {
    if (a[i] < 0) {
      neg = neg + a[i];
      an++;
    }
  }
  if (abs(pos) > abs(neg)) {
    cout << max(ap-1, 0) + an + N-1 << endl;
    int last = 0;
    while (last < N && a[last] <= 0) last++;
    for (int i = last + 1; i < N; i++) {
      if (a[i] > 0) {
        cout << last + 1 << " " << i + 1 << endl;
        last = i;
      }
    }
    for (int i = 0; i < N; i++) {
      if (a[i] < 0) {
        cout << last + 1 << " " << i + 1 << endl;
      }
    }
    for (int i = 0; i+1 < N; i++) {
      cout << i + 1 << " " << i + 2 << endl;
    }
  } else {
    cout << max(an-1, 0) + ap + N-1 << endl;
    int last = 0;
    while (last < N && a[last] >= 0) last++;
    for (int i = last + 1; i < N; i++) {
      if (a[i] < 0) {
        cout << last + 1 << " " << i + 1 << endl;
        last = i;
      }
    }
    for (int i = 0; i < N; i++) {
      if (a[i] > 0) {
        cout << last + 1 << " " << i + 1 << endl;
      }
    }
    for (int i = N-1; i-1 >= 0; i--) {
      cout << i + 1 << " " << i << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
typedef pair<int,int> P;
typedef long long ll;
int a[1005];

int main(void){
    int n,m,ans=0;
    while(true){
        cin>>n>>m;
        if((n==0)&&(m==0))break;
        ans=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i==j)continue;
                if(a[i]+a[j]<=m){
                    ans=max(ans,a[i]+a[j]);
                }
            }
        }
        if(ans==0)cout<<"NONE"<<endl;
        else cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 3104
#include <stdio.h>
using namespace std;

int main()
{
    int n, count = 0, ans = 0;
    char str[105];
    bool left, right;
    scanf("%d %s", &n, str);

    for(int i = 1; i < n; i++){
        left = right = false;
        for(char c = 'a'; c <= 'z'; c++){
            for(int j = 0; j < i; j++) if(left = (str[j] == c)) break;
            for(int k = i; k < n; k++) if(right = (str[k] == c)) break;
            if(left && right) count++;
        }

        if(ans < count) ans = count;
        count = 0;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll k;
ll a[200100];

bool check(ll v) {
    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        cnt += (a[i] + v-1) / v - 1;
    }
    return cnt <= k;
}

ll solve() {
    ll lb = 0, ub = inf;
    while (ub - lb > 1) {
        ll mid = (lb + ub) / 2;
        if (check(mid)) {
            ub = mid;
        } else {
            lb = mid;
        }
    }
    return ub;
}

void input() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 4692
N = int(input())
A = list(map(int,input().split()))
MOD = 10**9+7

arr = [0] * 60
for a in A:
    for i in range(60):
        if a&(1<<i):
            arr[i] += 1

ans = 0
for i,a in enumerate(arr):
    b = N-a
    ans += a*b * 2**i
    ans %= MOD
print(ans)

Measured memory_bytes: 122936
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include <bitset>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	string s;
	lli ans = 0, c = 1;
	cin >> s;
	
	int n = s.size()-1;
	c <<= n;
	c--;
	
	int a[n+2];
	rep(i, n+1) a[i] = s[i]-'0';
	a[n+1] = 0;
	
	for(; c >= 0 ; c--){
		lli t = a[0];
		rep(i, n+1){
			if((1&(c>>i)) != 1){
				ans += t;
				t = a[i+1];
			}else{
				t = t*10 + a[i+1];
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

int main() {
  int a[3];
  int noOfFives = 0;
  int noOfSevens = 0;
  cin >> a[0] >> a[1] >> a[2];
  for(int i=0;i<3;i++)
    if(a[i] == 5)
      noOfFives++;
  	else if(a[i] == 7 )
      		noOfSevens++;
  if( noOfFives == 2 && noOfSevens == 1 )
    cout << "YES";
   else
     cout << "NO";
  return 0;
}

Measured memory_bytes: 256
// 22
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
void _main(int tc) {
  int n;
  cin >> n;
  assert(n >= 2);
  vector<li> h(n);
  rep(i, n) cin >> h[i];
  vector<li> mem(n, -1);
  mem[n - 1] = 0;
  mem[n - 2] = abs(h[n - 2] - h[n - 1]);
  function<li(li)> fcost = [&](int pos) -> li {
    if (mem[pos] != -1) return mem[pos];
    return mem[pos] = min(abs(h[pos] - h[pos + 1]) + fcost(pos + 1), abs(h[pos] - h[pos + 2]) + fcost(pos + 2));
  };
  cout << fcost(0) << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0); return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

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

int main(){
    string s; cin >> s;
    int cnt = 0, ans = 0;
    for (auto si: s){
        if (si == 'A' || si == 'C' || si == 'G' || si == 'T'){
            cnt ++;
        }
        else{
            ans = max(cnt, ans);
            cnt = 0;
        }
    }
    cout << max(ans, cnt) << endl;
}

Measured memory_bytes: 3556
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    if(a.equals(b)){
      System.out.println("H");
    }
    else
      System.out.println("D");
  }
}


Measured memory_bytes: 21844
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect();
        v2.push(v);
    }
    v2
}

fn main() {
    let n: usize = read();
    let a: Vec<usize> = read_vec();
    let mut counter = 0;

    for i in 1..9 {
        let rate_low = if i == 1 { 1 } else { 400 * (i - 1) };
        let rate_high = i * 400 - 1;

        for v in a.iter() {
            if rate_low <= *v && *v <= rate_high {
                counter += 1;
                break;
            }
        }
    }
    
    let mut c = 0;
    for v in a.iter() {
        if *v >= 3200 {
            c += 1;
        }
    }

    if c == n {
        println!("{} {}", 1, c)
    } else {
        println!("{} {}", counter, counter+c)
    }
}

Measured memory_bytes: 4352
# Original Submission At: https://atcoder.jp/contests/abc149/submissions/16823042
x= int(input())

def prime_check(num,count):
    while True:
        while num % count == 0:
            num = num + 1
            count = 2
        if num <= count**2:
            print(num)
            break
        else:
            count = count + 1

if x==2 :
    print (2)
else:
    prime_check(x,2)


Measured memory_bytes: 9044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M =1000000007;
//MOD??
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}
ll mpow(ll x, ll n){ //x^n(mod M) ????pow(x,n)?????????????mod??
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
int main (){
  int j,i,n,m,x,k,mn=1000000000;
  cin>>n>>m>>x;
  int c[12][13];
  
  for(i=0;i<n;i++){
    for(j=0;j<m+1;j++){
      cin>>c[i][j];
    }
  }
  vector<string> y(4096);
  for(i=0;i<pow(2,n);i++){
    y[i] = (bitset<12>(i)).to_string();
    //cout<<y[i]<<endl;
  }
  int tof =0;
  vector<int>check(m+1);
  for(i=0;i<pow(2,n);i++){
    for(j=0;j<n;j++){
      //cout<<y[i][j]-'0'<<endl;
      if(y[i][j+12-n]-'0'==1){
        for(k=0;k<m+1;k++){
          //cout<<c[j][k]<<endl;
          check[k]+=c[j][k];
        }
      }
    }
    //cout<<check[0]<<endl;
    for(j=1;j<m+1;j++){
      if(j > 0 && check[j]>=x){
        tof++;
      }
      check[j]=0;
    }
    if(tof==m){
      mn = min(mn,check[0]);
    }
    tof=0;
    check[0]=0;

  }
  if(mn==1000000000)
  cout<<-1<<endl;
  else
  cout<<mn<<endl;
  return 0;
}


Measured memory_bytes: 4048