akhauriyash/Code-Regression huggingface dataset:
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    ll a;
    cin>>a;
    double b;
    cin>>b;
    b+=1e-4;
    ll c=b*100;
    ll res=a*c/100;
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3700
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
N, K = 0, 0
X = []


def set_inputs():
    global N, K, X
    N, K = get_li()
    X = get_li()
    return


def twice(x):
    return x[0] * 2, x[1]


def find_index(l, x):
    if x in l:
        return l.index(x)
    return inf


def main():
    setrecursionlimit(100000)
    set_inputs()
    ans = inf
    for i in range(N-K+1):
        l, r = X[i], X[i+K-1]
        tmp = min(abs(l) + abs(l-r), abs(r) + abs(r-l))
        ans = min(ans, tmp)
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


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


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14992
import java.util.Arrays;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int L = scanner.nextInt();
    String[] S = new String[N];
    for (int i = 0; i < N; i++) S[i] = scanner.next();
    Arrays.sort(S);
    for (int i = 0; i < N; i++) {
      System.out.print(S[i]);
    }
    System.out.println();
  }
}


Measured memory_bytes: 22100
class Combination:
    def __init__(self, n, mod):
        self.n = n
        self.mod = mod
        self.fac = [1 for i in range(self.n + 1)]
        self.finv = [1 for i in range(self.n + 1)]
        for i in range(2, self.n+1):
            self.fac[i] = (self.fac[i - 1] * i) % self.mod
            self.finv[i] = (self.finv[i-1] * pow(i, -1, self.mod)) % self.mod

    def comb(self, n, m):
        return self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod) % self.mod
def iparse():
    return list(map(int, input().split()))

if __name__ == "__main__":
    s = input()
    ans = 0
    for i in range(1 << (len(s) - 1)):
        prev = 0
        for j in range(len(s) - 1):
            if (i >> j) & 1 == 1:
                tmp = s[prev:j + 1]
                ans += int(tmp)
                prev = j+1
        ans += int(s[prev:])
    print(ans)
            
        
    


Measured memory_bytes: 9028
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}




fn solve(x: i64) -> i64 {
    let mut i = 1;
    loop {
        if i * (i + 1) >= 2 * x {
            return i
        }
        i += 1
    }
}


fn main() {
    input! {
        x: i64,
    }
    println!("{}", solve(x));
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,a) for(int i=lst[a];i;i=nxt[i])
using namespace std;

typedef long long ll;

const int N=85,M=325;

struct P{int x,y;ll v;}p[N];
struct limit{int a,b,tp;}lim[M];

int n,m;
char opt[5];

namespace flow{

	const int N=505,M=N*500;
	const ll inf=1e18;

	int t[M],f[M],nxt[M],lst[N],l,S,T;
	ll v[M];

	void add(int x,int y,int z,ll c) {
		t[++l]=y;f[l]=z;v[l]=c;nxt[l]=lst[x];lst[x]=l;
		t[++l]=x;f[l]=0;v[l]=-c;nxt[l]=lst[y];lst[y]=l;
	}

	ll dis[N],ans;
	int pre[N];
	bool vis[N];
	int q[M];

	bool spfa() {
		fo(i,S,T) dis[i]=-inf;dis[S]=0;
		int i=0,j=1;q[1]=S;vis[S]=1;
		while (i<j) {
			rep(k,q[++i]) 
				if (f[k]&&dis[t[k]]<dis[q[i]]+v[k]) {
					dis[t[k]]=dis[q[i]]+v[k],pre[t[k]]=k;
					if (!vis[t[k]]) vis[t[k]]=1,q[++j]=t[k];
				}
			vis[q[i]]=0;
		}
		return dis[T]>0;
	}

	void find() {
		for(int x=T;x;x=t[pre[x]^1]) {
			ans+=v[pre[x]];
			f[pre[x]]--;f[pre[x]^1]++;
		}
	}

	int lx[N],ly[N],rx[N],ry[N];

	ll solve(int k) {
		fo(i,S,T) lst[i]=0;l=1;
		S=0;T=n+(k<<1)+200+1;
		fo(i,1,n) {
			add(k+p[i].x,k+100+i,1,p[i].v);
			add(k+100+i,k+100+n+p[i].y,1,0);
		}
		fo(i,1,k) lx[i]=ly[i]=1,rx[i]=ry[i]=100;
		fo(i,1,m) {
			if (lim[i].tp==0) lx[lim[i].b+1]=max(lx[lim[i].b]+1,lim[i].a+1);
			if (lim[i].tp==1&&k>lim[i].b) rx[k-lim[i].b]=min(rx[k-lim[i].b],lim[i].a-1);
			if (lim[i].tp==2) ly[lim[i].b+1]=max(ly[lim[i].b]+1,lim[i].a+1);
			if (lim[i].tp==3&&k>lim[i].b) ry[k-lim[i].b]=min(ry[k-lim[i].b],lim[i].a-1);
		}
		fo(i,2,k) lx[i]=max(lx[i],lx[i-1]),ly[i]=max(ly[i],ly[i-1]);
		fd(i,k-1,1) rx[i]=min(rx[i],rx[i+1]),ry[i]=min(ry[i],ry[i+1]);
		fo(i,1,k) {
			add(S,i,1,0);add(200+n+k+i,T,1,0);
			fo(j,lx[i],rx[i]) add(i,j+k,1,0);
			fo(j,ly[i],ry[i]) add(k+100+n+j,200+n+k+i,1,0);
		} 
		rep(i,42);
		ans=0;int flow=0;
		while (spfa()) flow++,find();
		return flow==k?ans:0;
	}
}

int main() {
	scanf("%d",&n);
	fo(i,1,n) scanf("%d%d%lld",&p[i].x,&p[i].y,&p[i].v);
	scanf("%d",&m);
	fo(i,1,m) {
		scanf("%s",opt+1);
		scanf("%d%d",&lim[i].a,&lim[i].b);
		if (opt[1]=='L') lim[i].tp=0;
		if (opt[1]=='R') lim[i].tp=1;
		if (opt[1]=='D') lim[i].tp=2;
		if (opt[1]=='U') lim[i].tp=3;
	}
	ll ans=0;
	fo(i,1,n) ans=max(ans,flow::solve(i));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
# ABC089C - March
from itertools import combinations as comb


def main():
    N, *S = open(0).read().split()
    capitals = [s[0] for s in S]
    cnt = [capitals.count(i) for i in "MARCH"]
    ans = sum(x * y * z for x, y, z in comb(cnt, 3))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 10864
import math
import fractions
n = int(input())
a_ls = list(map(int,input().split()))
lcm = 1
ans = 0
mod = 10**9+7
for i in a_ls:
    lcm = lcm * i//fractions.gcd(lcm,i)
for i in a_ls:
    ans += lcm//i
print(ans%mod)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

typedef unsigned int uint;

int main(){
    uint N, K;
    cin >> N >> K;
    vector<uint> A(N);
    vector<uint> B(N);
    REP(i,N){
        uint a, b;
        cin >> a >> b;
        A[i] = a;
        B[i] = b;
    }

    int last = -1;
    vector<uint> answers;
    answers.push_back(K);
    for(int b = 0; b <= 30; b++){
        int bit = (K >> b) & 1;
        if(bit == 1 && last == 0){
            //uint tmp = K;
            //tmp &= ~(1U << b);
            K &= ~(1U << b);
            uint tmp = K;
            for(int x = 0; x < b; x++){
                tmp |= (1U << x);
            }
            answers.push_back(tmp);
            last = 0;
        }
        else
            last = bit;
    }

    ll ans = 0;
    for(auto&& x : answers){
        //for(int b = 30; b >= 0; b--){
        //    cout << ((x >> b) & 1);
        //}
        //cout << endl;

        ll tmp = 0;
        REP(i,N){
            uint a = A[i];
            bool add = true;
            for(int b = 0; b <= 30; b++){
                int bitx = (x >> b) & 1;
                int bita = (a >> b) & 1;
                if(bitx == 0 && bita == 1){
                    add = false;
                    break;
                }
            }
            if(add){
                tmp += B[i];
            }
        }

        chmax(ans, tmp);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int a,b;
    cin >> a;
    cin >> b;
    if(a>=1 && a<=100 && b>=1 && b<=100)
        cout << a*b << " " << 2*(a+b) << endl;
    return 0;
}


Measured memory_bytes: 3052
# coding: utf-8
# Your code here!

M, D = map(int, input().split())
tmp1, tmp2 = 0, 0
ctr = 0

for i in range(4, M + 1):
    for j in range(22, D + 1):
        tmp1 = j % 10
        tmp2 = j // 10
        if tmp1 >= 2 and tmp2 >= 2 and tmp1 * tmp2 == i:
            ctr += 1
print(ctr)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int l[200005],r[200005];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,k,c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> l,r;
    for(int i = 0 ; i < n && l.size() < k ; i++){
        if(s[i] == 'o'){
            l.push_back(i);
            i+=c;
        }
    }
    reverse(ALL(s));
    for(int i = 0 ; i < n && r.size() < k ; i++){
        if(s[i] == 'o'){
            r.push_back(n-1-i);
            i+=c;
        }
    }
    sort(ALL(r));
    vector<int> ans;
    for(int i=0;i<min(r.size(),l.size());i++){
        if(r[i] == l[i])ans.push_back(l[i]);
    }
    for(auto x:ans)cout << x + 1 << endl;
}

Measured memory_bytes: 6556
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	auto isN = [](char c) {return '0' <= c && c <= '9'; };
	in(int, A, B);
	in(string, s);
	bool ans = s.size() == A + B + 1 && s[A] == '-';
	s[A] = '0';
	for (auto c : s)
		ans = ans && isN(c);
	YesNo(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <cmath>
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	vector<ll>a,b;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		a.push_back(x);
	}
	for(ll j=0;j<n;j++){
		ll x;
		cin>>x;
		b.push_back(x);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	ll right = 0; 	
	for(ll j=0;j<n;j++){
		right=max(a[j]*b[j],right);
//		cout << a[j]<<" "<<b[j]<<endl;
	}
//	cout <<right<<endl;
    ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
 // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        ll mid = left + (right - left) / 2;
        ll cnt=0;
        for(ll i=0;i<n;i++){
        	if(a[i]*b[i]>mid){
        		cnt+=a[i]-mid/b[i];
        	}
        }
//        cout <<cnt<<" ";
        if (cnt<=k) right = mid;
        else left = mid;
//    	cout <<mid<<endl;        
    }
    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    cout << max(ll(0),right);	
	// your code goes here
	return 0;
}

Measured memory_bytes: 4848
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<vector<int>> LR(N, vector<int>(N));
	for (int i = 0; i < M; i++) {
		int l, r;
		cin >> l >> r;
		LR[l - 1][r - 1]++;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i > 0) LR[i][j] += LR[i - 1][j];
			if (j > 0) LR[i][j] += LR[i][j - 1];
			if (i > 0 && j > 0) LR[i][j] -= LR[i - 1][j - 1];
		}
	}
	vector<int> Ans(Q);
	for (int i = 0; i < Q; i++) {
		int p, q;
		cin >> p >> q;
		Ans[i] = LR[q - 1][q - 1];
		if (p > 1) Ans[i] += -LR[p - 2][q - 1] - LR[q - 1][p - 2] + LR[p - 2][p - 2];
	}
	for (int a : Ans) cout << a << endl;
}

Measured memory_bytes: 2304
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 c = sc.nextInt();
        int res = (int) (Math.ceil(a / (double) b) * c);
        System.out.println(res);
    }
}


Measured memory_bytes: 27084
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
sum = 0
for i in a_list:
    sum+=i
index = 0
while index<m:
    if a_list[index]<(sum/(4*m)):
        print("No")
        exit()
    index+=1
print("Yes")

Measured memory_bytes: 3064
def a():
    N, K = [int(n) for n in input().split()]
    h = [int(n) for n in input().split()]
    # dp[i]はi番目までたどり着くのに必要な最小コスト
    # dp[0] = 0
    # dp[1] = |h[1] - h[0]|
    # dp[i] = min(dp[0]+h[i]-h[0], dp[1]+h[i]-h[1], ...)
    dp = [0] * N
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])
    for i in range(2, N):
        dp[i] = min([dp[k] + abs(h[k] - h[i]) for k in range(max(i - K, 0), i)])
    print(dp[N-1])
 
if __name__ == "__main__":
    a()

Measured memory_bytes: 13980
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k; cin >> n >> k;
    if((n-1)*(n-2)/2 < k) {
        cout << -1 << endl;
        return 0;
    }
    int time = n-1+ (n-1)*(n-2)/2 - k;
    cout << time << endl;

    REP(i,1,n) {
        REP(j,i+1,n+1) {
            if(time>=1) cout << i << " " << j << endl;
            time--;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int main() {

	int N;
	cin >> N;
	std::vector<int> h;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		h.push_back(tmp);
	}
	int count = 1;
	
	for (int i = 1; i < N; i++) {
		int ni = h[i];
		bool canlook = true;
		for (int j = 0; j < i; j++) {
			if (ni >= h[j]) {
				canlook = true;
			}
			else {
				canlook = false;
				break;
			}
		}
		if (canlook == true) {
			count += 1;
		}

	}

    cout << count << endl;

	return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;



int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c>=22)cout<<"bust"<<endl;
  else cout<<"win"<<endl;
  return 0;
}

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

int main() {
  int N, C;
  cin >> N;

  if (N%1000 == 0) {
    C = 0;
  }
  else {
    C = 1000 - N % 1000;
  }
  
  cout << C << endl;
}

Measured memory_bytes: 3620
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N, K = map(int, input().split())
Xs = list(map(int, input().split()))

minus = []
plus = []
for x in Xs:
    if x < 0:
        minus.append(x)
    elif x == 0:
        K -= 1
    else:
        plus.append(x)

# 左にあるn個を取るまでの移動距離
left_dist = [0] * (len(minus) + 1)
for i, m in enumerate(reversed(minus)):
    left_dist[i+1] = abs(m)
# 右にあるn個を取るまでの移動距離
right_dist = [0] * (len(plus) + 1)
for i, p in enumerate(plus):
    right_dist[i+1] = p
# print(left_dist)
# print(right_dist)

ans = 1e20
for left_num in range(0, K + 1):
    right_num = K - left_num
    if left_num > len(minus) or right_num > len(plus):
        continue
    ans = min(ans, left_dist[left_num] * 2 + right_dist[right_num])
    ans = min(ans, right_dist[right_num] * 2 + left_dist[left_num])
print(ans)


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) {
        string s;
        int k;
        cin >> k >> s;
        if((int) s.size() <= k) cout << s;
        else {
            string ans = "";
            for(int i = 0; i < k; i++) ans += s[i];
            ans += "...";
            cout << ans;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
c1, c2 = map(int, input().split())

prizes = [300000, 200000, 100000]
total_prize = 0
if(c1 <= 3):
  total_prize += prizes[c1-1]
if(c2 <= 3):
  total_prize += prizes[c2-1]
if(c1==1 and c2==1):
  total_prize += 400000
print(total_prize)

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    
    //a<b<c
    if(a <= b && b <= c)
     printf("%d %d %d\n",a,b,c);
    //a<c<b
    else if(a <= c && c <= b )
     printf("%d %d %d\n",a,c,b);
    //c<b<a
    else if(c <= b && b <= a)
     printf("%d %d %d\n",c,b,a);
    //c<a<b
    else if(c <= a && a <= b)
     printf("%d %d %d\n",c,a,b);
    //b<a<c
    else if(b <= a && a <= c)
     printf("%d %d %d\n",b,a,c);
    //b<c<a
    else if(b <= c && c <= a)
     printf("%d %d %d\n",b,c,a);
    return 0;
}


Measured memory_bytes: 2064
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from collections import Counter

cnt = Counter()
for line in stdin:
    start, end = (int(s) for s in line.split())
    if start or end:
        cnt[start] += 1
        cnt[end] += 1
    else:
        semi_eulerian = sum(i % 2 for i in cnt.values()) == 2
        if semi_eulerian and cnt[1] % 2 and cnt[2] % 2:
            print('OK')
        else:
            print('NG')
        cnt.clear()

Measured memory_bytes: 4648
#include <cstdio>
#include <algorithm>

const int MN = 100005;

int N, C, K, T[MN];

int main() {
	scanf("%d%d%d", &N, &C, &K);
	for (int i = 1; i <= N; ++i) scanf("%d", &T[i]);
	std::sort(T + 1, T + N + 1);
	int Ans = 0, lst = 0, cap = 0;
	for (int i = 1; i <= N; ++i) {
		if (cap == C || lst < T[i]) ++Ans, lst = T[i] + K, cap = 1;
		else ++cap;
	}
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 2120
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		String T = sc.next();
		int ss = S.length();
		int tt = T.length();
		char[] chS = new char[ss];
		char[] chT = new char[tt];
		for( int i=0; i<ss; i++ ){
			chS[i] = S.charAt(i);        
		}
		for( int i=0; i<tt; i++ ){
			chT[i] = T.charAt(i);       
		}
		int x = 0,y = 0,b = 0;
		loop:for( int i=0; i<=ss-tt; i++ ){
			int a = i;
			int count = 0;          
			for( int j=0; j<tt; j++ ){
				if( chS[a]=='?' || chS[a]==chT[j] ){
					count++;
				}
				if( count==tt ){
					x = i;
					y = i+tt-1;	
					b = 1;                  
				}  
				a++;              
			}            
		}
		if( ss==1 ){
			b = 0;          
        }          
		if( b==1 ){   //if start   
		for( int i=0; i<x; i++ ){
			if( chS[i]=='?' ){
				System.out.print("a");
			}else{
				System.out.print(chS[i]);
			}
		}
		for( int i=0; i<tt; i++ ){
			System.out.print(chT[i]);
		}
		for( int i=y+1; i<ss; i++ ){
			if( chS[i]=='?' ){
				System.out.print("a");
			}else{
				System.out.print(chS[i]);
			}
		}
        }      //if end
		if( ss==1 ){
			if( S.equals(T) || S.equals("?") ){
				System.out.println(T);              
            }else{
				System.out.println("UNRESTORABLE");              
            }              
        }else{
			if( x==0 && y==0 ){
				System.out.println("UNRESTORABLE");              
            }              
        }          
	}
}


Measured memory_bytes: 21844
S = input()
ret = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        f = True
        for k in S[i:j + 1]:
            if k not in ("ACGT"):
                f = False
                break
        if f:
            ret = max(ret, (j + 1) - i)
print(ret)

Measured memory_bytes: 9020
#include<stdio.h>
void binary(int *,int,int);

int k=0;
int num2;
int main(){
    int i,j,num1,first[100000],second[500000],same=0,left,right,mid;
    //一つ目の数列
    scanf("%d",&num1);
        for(int i=0;i<num1;i++){
            scanf("%d",&first[i]);
        }
    //二つ目の要素
    scanf("%d",&num2);
    for(i=0;i<num2;i++){
        scanf("%d",&second[i]);
    }
    for(i=0;i<num2;i++){
    k++;
    binary(first,num1,second[i]);
    }
    //printf("%d",k);
    return 0;
}

void binary(int *f,int num,int key){
  int left,right,mid;
  static int same=0;
     left=0;
     right=num;
        while(left<right){
            mid = (left + right)/2;
            if(f[mid]==key){
	      //printf("%d%d\n",f[mid],key);
                same++;
                break;
            }else if(key<f[mid]){
                right=mid;
            }else {
                left=mid+1;
            }
        }
	//printf("%d%d\n",k,num2);
	if(k==num2){
	  printf("%d\n",same);
	  }

}



Measured memory_bytes: 2288
n = int(input())
A = list(map(int, input().split(' ')))

mi = [A[0]]
for i in range(1, n):
    if mi[i-1] > A[i]:
        mi.append(A[i])
    else:
        mi.append(mi[i-1])

#print(mi)

c = 1
for i in range(1, n):
    if A[i] <= mi[i]: c+=1

print(c)

Measured memory_bytes: 26012
n = int(input())
a = list(map(int, input().split()))

m = 0
for i in range(n):
    if i%2:
        m -= a[i]
    else:
        m += a[i]

ans = [m]
for i in range(n-1):
    m = 2*a[i] - m
    ans.append(m)

print(*ans)

Measured memory_bytes: 69732
N= int(input())
A = list(map(int, input().split()))
from collections import Counter

if N%3:
  if all([a==0 for a in A]):
    print('Yes')
  else:
    print('No')


else:
  c = Counter(A)
  temp = 0
  for k,v in c.items():
    if v % (N//3):
      print('No')
      exit()
    else:
      for i in range(v//(N//3)):
        temp = temp^k
  if temp==0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 14116
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<b)
		{printf("a < b\n");
	}
	else if(a>b)
		{printf("a > b\n");
		}
	else {printf("a == b\n");
	}
	
	return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
#define lim 1000000000000000007
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(),v.end()
#define mod ((int)1e9+7)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int>> pii;
const int N = (int)1e3+5;

vector<vector<int>> distance_from_source;
vector<string> grid;
int r, c;
void dijksta(int source_x, int source_y) {
  distance_from_source[source_x][source_y] = 0;
  priority_queue<pii,vector<pii>,greater<pii>> pq;
  pq.push({0,{source_x,source_y}});
  while(!pq.empty()) {
    pii curr_node = pq.top();
    pq.pop();
    int x = curr_node.second.first, y = curr_node.second.second;
    if(distance_from_source[x][y] == curr_node.first) {
      REP(k,-2,2) {
        REP(l,-2,2) {
          if(x+k>=0 && x+k<r && y+l>=0 && y+l<c && grid[x+k][y+l]=='.') {
            int _x = x+k, _y = y+l, d = (abs(k)+abs(l))!=1;
            if(distance_from_source[_x][_y] > distance_from_source[x][y] + d) {
              distance_from_source[_x][_y] = distance_from_source[x][y] + d;
              pq.push({distance_from_source[_x][_y], {_x, _y}});
            }
          }
        }
      }
    }
  }
}

void solve() {
  cin >> r >> c;
  distance_from_source = vector<vector<int>>(r,vector<int>(c,1e9));

  int source_x, source_y;
  int destination_x, destination_y;
  cin >> source_x >> source_y;
  cin >> destination_x >> destination_y;
  source_x--, source_y--;
  destination_x--, destination_y--;

  grid = vector<string>(r);
  REP(i,0,r-1) {
    cin>>grid[i];
  }
  dijksta(source_x, source_y);
  if(distance_from_source[destination_x][destination_y] == 1e9) {
    distance_from_source[destination_x][destination_y] = -1;
  }
  cout << distance_from_source[destination_x][destination_y];
}

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

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


Measured memory_bytes: 8652
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int N;
 cin >> N;
 
  vector<int>a(N);
  for(int i = 0; i < N; i++){
   cin >> a.at(i); 
  }
int s = 0, b = 0, c;
  while(s != 1){
     if(a.at(s) == -1){
       b = -1;
       break;
     }
   c = s;
   s = a.at(s) - 1;
   a.at(c) = -1;
   b++;
  }
cout << b << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
int N;
ll A[Nmax];

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

	ll ans = 1e10;
	for(int i=0; i<N; i++) ans = min(ans, A[i]);
	bool change = true;
	while(change){
		change = false;
		for(int i=0; i<N; i++){
			if(A[i] > ans) A[i] = A[i] % ans;
		}
		for(int i=0; i<N; i++){
			if(A[i]>0 && A[i]<ans){
				ans = A[i];
				change = true;
			}
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

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

    for (int i = 0; i < line.length(); i++) {
      char c = line.charAt(i);
      if (Character.isUpperCase(c))
        newLine[i] = (Character.toLowerCase(c));
      else if (Character.isLowerCase(c))
        newLine[i] = (Character.toUpperCase(c));
      else
        newLine[i] = c;
    }
    System.out.println(new String(newLine));
  }
}



Measured memory_bytes: 26196
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
#define int long long
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
using namespace std;
#define hash hush
typedef long long ll;
typedef long double ld;
int n, a[100000];
int b[100000];
signed  main() {
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ans += a[i];
	}
	sort(a, a + n);
	int u = 0;
	for (int i = 0; i < n;) {
		int j = i;
		while (j < n&&a[i] == a[j]) 
			j++;
		b[u] = j - i;
		u++;
		i = j;
	}
	if (u % 2 == 0)
		cout << u-1 << endl;
	else
		cout << u << endl;
	getchar(); getchar();
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i,a,n) for(int i = a; n > i; i++)
#define REP(i,n) rep(i,0,n)

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


int rui[3][1002][1002] = {};

int main(){
	int n,m,k;
	scanf("%d %d %d", &n, &m, &k);


	REP(i,n){
		scanf("%*c");
		REP(j,m){
			char buf;
			scanf("%c", &buf);
			switch(buf){
			case 'J':
				rui[0][i+1][j+1]++;
				break;

			case 'O':
				rui[1][i+1][j+1]++;
				break;

			case 'I':
				rui[2][i+1][j+1]++;
				break;
			}
		}
	}
	REP(i,n){
		REP(j,m){
			rui[0][i+2][j+1] += rui[0][i+1][j+1];
			rui[1][i+2][j+1] += rui[1][i+1][j+1];
			rui[2][i+2][j+1] += rui[2][i+1][j+1];
		}
	}
	REP(i,n){
		REP(j,m){
			rui[0][i+1][j+2] += rui[0][i+1][j+1];
			rui[1][i+1][j+2] += rui[1][i+1][j+1];
			rui[2][i+1][j+2] += rui[2][i+1][j+1];
		}
	}

	REP(i,k){
		int a,b,c,d;
		scanf("%d %d %d %d", &a, &b, &c, &d);
		//a--;b--;c--;d--;
		REP(j,3){
			int res = rui[j][c][d] - rui[j][a-1][d] - rui[j][c][b-1] + rui[j][a-1][b-1];
			printf("%d",res);
			if(j < 2)
				printf(" ");
		}
		printf("\n");
	}


	return 0;
}

Measured memory_bytes: 14820
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

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

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int A, B;
  cin >> A >> B;
  if(A%2==0 || B%2==0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int hp0, hpMax;
	int w, h;
	char[][] map;
	int nDamages;
	HashMap<Character, Integer> damages;
	int nDirections;
	LinkedList<P> directions;
	int nPostions;
	int[] potions;

	class P{
		int x, y;

		P(int x, int y){
			this.x=x;
			this.y=y;
		}
	}

	void run(){
		for(;;){
			hp0=sc.nextInt();
			hpMax=sc.nextInt();
			if((hp0|hpMax)==0){
				break;
			}
			h=sc.nextInt();
			w=sc.nextInt();
			map=new char[h][w];
			for(int j=0; j<h; j++){
				String s=sc.next();
				for(int i=0; i<w; i++){
					map[j][i]=s.charAt(i);
				}
			}
			nDamages=sc.nextInt();
			damages=new HashMap<Character, Integer>();
			for(int i=0; i<nDamages; i++){
				char c=sc.next().charAt(0);
				int d=sc.nextInt();
				damages.put(c, d);
			}
			nDirections=sc.nextInt();
			directions=new LinkedList<P>();
			for(int i=0; i<nDirections; i++){
				char c=sc.next().charAt(0);
				int dx=0, dy=0;
				switch(c){
				case 'U':
					dy=-1;
					break;
				case 'D':
					dy=1;
					break;
				case 'L':
					dx=-1;
					break;
				case 'R':
					dx=1;
					break;
				}
				for(int k=sc.nextInt(); k>0; k--){
					directions.addLast(new P(dx, dy));
				}
			}
			nDirections=directions.size();
			nPostions=sc.nextInt();
			potions=new int[nPostions];
			for(int i=0; i<nPostions; i++){
				potions[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		int x=0, y=0;
		// 0:unused
		// 1:used
		int[][] dp;
		dp=new int[nDirections+1][1<<nPostions];
		dp[0][0]=hp0;

		for(int i=0; i<=nDirections; i++){
			int damage=damages.get(map[y][x]);
			for(int s=0; s<1<<nPostions; s++){
				if(dp[i][s]<=0){
					continue;
				}
				for(int t=0; t<nPostions; t++){
					if((s>>t&1)==0){
						int hp=Math.min(hpMax, dp[i][s]+potions[t]);
						int u=1<<t;
						dp[i][s|u]=Math.max(dp[i][s|u], hp);
					}
				}
			}
			for(int s=0; s<1<<nPostions; s++){
				dp[i][s]-=damage;
			}
			if(i==nDirections){
				break;
			}
			System.arraycopy(dp[i], 0, dp[i+1], 0, 1<<nPostions);
			P p=directions.get(i);
			x+=p.x;
			y+=p.y;
		}
		boolean f=false;
		for(int i=0; i<1<<nPostions; i++){
			if(dp[nDirections][i]>0){
				f=true;
			}
		}
		println(f?"YES":"NO");
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 37000
X,N=map(int,input().split())
p=input()
def ans170(X:int, N:int, p:str):
    p_list=list(map(int,p.split()))
    count=1
    if len(p)==0:
        return X
    elif X not in p_list:
        return X
    else:
        while True:
            if X-count not in p_list:
                return X-count
                break
            elif X+count not in p_list:
                return X+count
                break
            else:
                count+=1
print(ans170(X,N,p))


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

int N;
long long int a[500];

long long int dp[500][500];

long long int INF = 999999999999999;
long long int S[500];

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) { cin >> a[i]; }

	for (int i = 1; i <= N; i++) {
		S[i] = S[i - 1] + a[i];
	}

	for (int i = 1; i <= N; i++) {
		for(int j = 1; j <= N; j++) {
			dp[i][j] = INF;
		}
	}

	for (int i = 1; i <= N; i++) { dp[i][i] = 0; }

	for (int k = 2; k <= N; k++) {
		for (int i = 1; i <= N - k + 1; i++) {
			int j = i + k - 1;
			for (int m = i; m < j; m++) {
				dp[i][j] = min(dp[i][j], dp[i][m] + dp[m+1][j]+S[j]-S[i-1]);
			}
		}
	}

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

	//system("pause");
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail
{
  template <typename T, std::size_t NDIMS>
  struct vector_builder
  {
    using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
      if (!dims.empty())
        dims.pop_back();
      return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
    }
  };

  template <typename T>
  struct vector_builder<T, 1>
  {
    using type = std::vector<T>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      return type(dims.empty() ? 0 : dims.back(), v);
    }
  };
} // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T &v, SIZE_T... dims)
{
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, long long K)
{
  if (N % K == 0)
  {
    cout << 0 << endl;
    return;
  }

  cout << min(N % K, K - N % K) << endl;
}

int main()
{
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  solve(N, K);
  return 0;
}


Measured memory_bytes: 3608
import java.util.*;

class Main
{
    public static void main(String args[])
    {
	int n, q, C=0;
	long[] S = new long[10000];
	long k;
	Scanner read = new Scanner(System.in);

	//Read S
	n=read.nextInt();
	for(int i=0; i<n; i++)S[i]=read.nextInt();

	//search
	q=read.nextInt();
	for(int i=0; i<q; i++)
	    {
		k=read.nextInt();
		for(int j=0; j<n; j++)
		    {
			if(k==S[j])
			    {
				C++;
				break;
			    }
		    }
	    }

	//print
	System.out.println(C);
    }
}

Measured memory_bytes: 13000
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int n;
int m;
char str[1000000+1];
void exec()
{
	cin >> n;
	if(n==0)exit(0);
	cin >> m >> str;
	int st=0;
	int ret=0;
	for(int i=0;i<m;i++){
		if(st%2==0){
			if(str[i]=='I'){
				st++;
			}
			else {
				st=0;
			}
		}
		else
		{
			if(str[i]=='O'){
				st++;
			}
			else
			{
				st=1;
			}
		}
		if(st%2==1&&st>=2*n+1)
		{
			ret++;
		}
	}
	cout << ret << endl;
}
int main() {
	while(1)exec();
}

Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
constexpr auto PI = 3.14159265358979323846264338327950L;
int needleX[4] = { -1,0,1,0 };
int needleY[4] = { 0,1,0,-1 };


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N>>M;
    vector<pii> X;
    for (int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        X.push_back(make_pair(y, x));
    }
    SORT(X);
    int max = 0;
    int res = 0;
    for (int i = 0; i < M; ++i) {
        if (max <= X[i].second) {
            res++;
            max = X[i].first;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1400
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
struct node
{
    ll a;
};
ll n = N;
vector<node> t(2 * N);
node combine(node l, node r)
{
    node res;
    res.a = max(l.a, r.a);
    return res;
}
void update(int p, node value)
{
    for (t[p += n] = value; p >>= 1;)
        t[p] = combine(t[p << 1], t[p << 1 | 1]);
}
void build()
{
    for (ll i = n - 1; i > 0; --i)
        t[i] = combine(t[i << 1], t[i << 1 | 1]);
}
node query(ll l, ll r)
{
    node resl = {0}, resr = {0};
    for (l += n, r += n; l < r; l >>= 1, r >>= 1)
    {
        if (l & 1)
            resl = combine(resl, t[l++]);
        if (r & 1)
            resr = combine(t[--r], resr);
    }
    return combine(resl, resr);
}
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll &e : a)
        cin >> e;
    for (ll i = 0; i < n; i++)
    {
        ll l = max(0L, a[i] - k);
        ll r = a[i] + k;
        ll x = query(l, r + 1).a + 1;
        update(a[i], {x});
    }
    cout << query(0, N).a;
}

Measured memory_bytes: 21152
#include <stdio.h>
#define MAX 10000

int parent(int i){
  return (i/2);
  
}
int left(int i){
  return 2*i;
}
int right(int i){
  return (2*i+1);
}

int main(){
  int n,i,A[MAX+1];
  int r,l,p;
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1){
      p=parent(i);
      printf("parent key = %d, ",A[p]);
    }
    if(left(i)<=n){
      l=left(i);
      printf("left key = %d, ",A[l]);
    }
    if(right(i)<=n){
      r=right(i);
      printf("right key = %d, ",A[r]);
    }
      printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}



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

    ll n;
    cin>>n;
    ll a[n];
    ll ans = -1e18;
    for(int i=0;i<n;i++) cin>>a[i];
    if(n%2==0){
        ll dp[n]={};
        for(int i=0;i<n;i++) dp[i] = -1e18;
        dp[0]=a[0], dp[1]=a[1];
        for(int i=2;i<n;i++){
            if(i%2){
                dp[i] = max(dp[i-2],dp[i-3])+a[i];
            }
            else{
                dp[i] = dp[i-2] + a[i];
            }
        }
        chmax(ans,max(dp[n-1],dp[n-2]));
    }
    else{
        if(n==3){
            ans = max({a[0],a[1],a[2]});
            cout << ans << endl;
            return 0;
        }
        ll sum = 0;
        for(int i=0;i<n;i++) sum += a[i];
        ll dp[n][3];
        for(int i=0;i<n;i++){
            dp[i][0]=1e18;
            dp[i][1]=1e18;
            dp[i][2]=1e18;
        }
        dp[0][0] = a[0];
        dp[1][0] = a[1];
        dp[1][1] = a[1];
        dp[1][2] = a[0]+a[1];
        for(int i=2;i<n;i++){
            dp[i][0] = dp[i-2][0] + a[i];
            if(i%2==0){
                dp[i][1] = min(dp[i-2][1],dp[i-1][0]) + a[i];
            }
            else{
                dp[i][2] = min(dp[i-2][2],dp[i-1][1]) + a[i];
            }
        }
        ans = sum - min(dp[n-1][1],dp[n-2][2]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9848
using System;
using System.Numerics;
namespace MSOLUTIONS.Problems
{
    class C
    {
        static void Main()
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var inputs1 = Console.ReadLine().Split(" ");
            var inputs2 = Console.ReadLine().Split(" ");
            var n = int.Parse(inputs1[0]);
            var k = int.Parse(inputs1[1]);
            var a = new int[n+1];
            for (var i = 1; i <= n; i++)
            {
                a[i] = int.Parse(inputs2[i-1]);
            }
            for (var i = k + 1; i <= n; i++)
            {
                if (a[i] > a[i-k])
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 46096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int sum = a * b;
		int len = 2 * a + 2 * b;
		System.out.println(sum + " " + len);
	}
}

Measured memory_bytes: 26212