akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8

import sys

N, Y = (int(i) for i in input().split())

for x in range(N + 1):
	for y in range(N - x + 1):
		z = N - x - y
		if 10000 * x + 5000 * y + 1000 * z == Y:
			print(str(x) + " " + str(y) + " " + str(z))
			sys.exit()

print("-1 -1 -1")

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int num[100] = {};
    num[a]++;
    num[b]++;
    num[c]++;
    if(num[5] == 2 && num[7] == 1) {
        printf("YES\n");
        return 0;
    }
    printf("NO\n");

    return 0;
}


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

#define ll long long

using namespace std;

int main()
{
	ll n; cin>>n;
	map<ll, ll> Map;
	vector<ll> a(n), b(n), ua(n,0), ub(n,0);
	for(int i=0; i<n; i++){
		cin>>a[i]>>b[i];
		Map[a[i]] = i;
		ua[a[i]-1]++; ub[b[i]-1]++;
	}
	for(int i=0; i<n; i++){
		if (ua[i]!=1 || ub[i]!=1){
			cout << "-1\n";
			return 0;
		}
	}
	ll ans=0;
	for(int i=0; i<n; i++){
		ll cur = Map[b[i]];
		if (cur==i) continue;
		ans++;
		Map[a[i]] = cur;
		ll temp = a[i];
		a[i] = a[cur];
		a[cur] = temp;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 12324
def main():
    s = input()
    ans = 0
    g_count = 0
    for c in s:
        if c == "g":
            if g_count:
                ans += 1
                g_count -= 1
            else:
                g_count += 1
        else:
            if g_count:
                g_count -= 1
            else:
                ans -= 1
                g_count += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <cstdio>
using namespace std;

int main()
{
	int n;
	
	while (scanf("%d", &n) != EOF){
		n %= 39;
		if (n == 0){
			printf("3C39\n");
		}
		else if (n < 10){
			printf("3C0%d\n", n);
		}
		else {
			printf("3C%d\n", n);
		}
	}
	
	return (0);
}

Measured memory_bytes: 1036
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;

int main() {
	int N;
	int v[20], c[20];
	cin >> N;
	int value = 0;
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < N; i++) {
		if (v[i] > c[i]) {
			value += v[i] - c[i];
		}
	}

	cout << value << endl;
	return 0;
}

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

struct Info{
	int id,cost,ac;
};

bool operator < (const Info &a,const Info &b){
	if(a.ac!=b.ac) return a.ac>b.ac;
	if(a.cost!=b.cost) return a.cost<b.cost;
	return a.id>b.id;
}

int main()
{
	int M,T,P,R;
	while(cin>>M>>T>>P>>R){
		if(M==0) break;
		vector<vector<int> >num_WA(T,vector<int>(P,0));
		vector<int> cost(T,0);
		vector<int> num_AC(T,0);
		for(int i=0;i<R;i++){
			int m,t,p,j;
			cin>>m>>t>>p>>j;
			t--;
			p--;
			if(j==0){
				cost[t] += m+num_WA[t][p]*20;
				num_AC[t]++;
			}
			else{
				num_WA[t][p]++;
			}
		}
		vector<Info> temp;
		for(int i=0;i<T;i++){
			Info hoge;
			hoge.cost=cost[i];
			hoge.id=i+1;
			hoge.ac=num_AC[i];
			temp.push_back(hoge);
		}
		sort(temp.begin(),temp.end());
		int bef_ac=0,bef_cost=0;
		for(int i=0;i<temp.size();i++){
			if(i!=0){
				if(bef_ac==temp[i].ac && bef_cost==temp[i].cost){
					cout<<"=";
				}
				else cout<<",";
			}
			cout<<temp[i].id;
			bef_ac=temp[i].ac;
			bef_cost=temp[i].cost;
		}
		cout<<endl;
	}
	return 0;
}

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

using namespace std;

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

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

int N, S;

int dfs(int num, int n, int s){
  if(n == N){
    if(s == S) return 1;
    return 0;
  }

  if(num == 10) return 0;

  return dfs(num+1, n+1, s+num) + dfs(num+1, n, s);
}

int main(){
  while(scanf("%d%d", &N, &S) && N+S){
    int v[10] = {};
    printf("%d\n", dfs(0, 0, 0));
  }
  return 0;
}

Measured memory_bytes: 1184
n,k=map(int,input().split())
a=[0]+[int(j) for j in input().split()]
l=[-1]*(n+1)
ll=[]
i=1
idx=0
while True:
    if l[i]==-1:
        l[i]=idx
    else:
        ll.append(i)
        break
    ll.append(i)
    i=a[i]
    idx+=1

p=ll[-1]
nl=ll[l[p]:-1]
ml=ll[:l[p]]
n,m=len(nl),len(ml)
if k<m:
    print(ml[k])
elif nl==[]:
    print(p)
    exit()
else:
    print(nl[(k-m)%n])


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

using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < n; ++i)

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
int main() {
	ll a, b;
	cin >> a >> b;
	ll g = gcd(a, b);
	int cnt = 0;
	for (ll i = 2; i * i <= g; ++i) {
		if (g % i == 0) {
			cnt++;
			while (g % i == 0)
				g /= i;
		}
	}
	if (g != 1) cnt++;
	cout<<cnt+1<<endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(dead_code)]
use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, stdin, BufRead};
use std::str::FromStr;

fn read_one<T>() -> T
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let stdin = stdin();
    let mut handle = stdin.lock();
    let mut buf = String::new();
    handle.read_line(&mut buf).unwrap();

    buf.trim().parse::<T>().unwrap()
}

macro_rules! read_tuple {
    ( $( $t:ty ), * ) => {
        {
            let stdin = stdin();
            let mut handle = stdin.lock();
            let mut buf = String::new();
            handle.read_line(&mut buf).unwrap();
            let mut v = buf.trim().split_whitespace()
                .collect::<VecDeque<&str>>();
            (
                $({
                    v.pop_front().unwrap().parse::<$t>().unwrap()
                },)*
            )
        }
    }
}

fn read_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let stdin = stdin();
    let mut handle = stdin.lock();
    let mut buf = String::new();
    handle.read_line(&mut buf).unwrap();

    buf.trim()
        .split_whitespace()
        .map(|s| s.parse::<T>().unwrap())
        .collect::<Vec<T>>()
}

fn main() -> io::Result<()> {
    let mut n = read_one::<i32>();
    let mut sum: i64 = 0;
    for i in (1..n + 1) {
        if i % 3 != 0 && i % 5 != 0 {
            sum += i as i64;
        }
    }
    println!("{}", sum);
    return Ok(());
}


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

using ll = long long;
using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(false)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;

ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return (a == 0 || b == 0) ? 0 : (a / __gcd(a, b) * b); }

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;

	double ret = (n % 2 == 0) ? 0.5 : ( double(n - n / 2) / double(n) );
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 10;
int counts = 1,maxn = -INF;
int head[MAXN];
struct node{
	int to;
	int next;
	int color;
}edge[MAXN];
void addedge(int a,int b){	
	edge[counts].to = b;
	edge[counts].color = 0;
	edge[counts].next = head[a];
	head[a] = counts++;
}
void dfs(int u,int c){
	int tmp = 1;
	for(int i = head[u];i != 0;i = edge[i].next){
		int v = edge[i].to;
		if(tmp == c)
			tmp++;
		edge[i].color = tmp;
		maxn = max(maxn,tmp);
		dfs(v,tmp);
		tmp++;
	}
}
int main(){
	int n;
	cin >> n;
	for(int i = 1;i< n;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		addedge(a,b);
	}
	dfs(1,0);
	printf("%d\n",maxn);
	for(int i = 1;i < counts;i++){
		printf("%d\n",edge[i].color);
	}
	return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long 
ll dp[3001][3001];
ll game(ll i,ll j,ll sum, ll arr[])
{
    if(i+1==j)
    return max(arr[i],arr[j]);
    if(dp[i][j]!=-1)
     return dp[i][j];
    dp[i][j]= max(sum-game(i+1,j,sum-arr[i],arr),sum-game(i,j-1,sum-arr[j],arr));
    return dp[i][j];
}
int main()
{
    ll n,sum=0;
    cin>>n;
    ll arr[n];
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)
      cin>>arr[i];
    for(int i=0;i<n;i++)
      sum+=arr[i];
      if(n==1)
      {
          cout<<sum;
          return 0;
      }
     
      ll x=game(0,n-1,sum,arr);
      ll y=sum-x;
     
    cout<<x-y;
}

Measured memory_bytes: 70912
//#include<cstdio>
#include<iostream>
using namespace std;

int main(){
	long long a, b, t, gcd, lcm;
	while( cin >> a >> b ){
		t=a*b;
		while(a!=b){
			while(a>b) a-=b;
			while(a<b) b-=a;
		}
		gcd=a;
		lcm=t/gcd;
		cout << gcd << " " << lcm << endl;
	}
 return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int a, b; cin >> a >> b;
  int cnt=0;
  for(int i = a; i <= b; i++) {
    string num = to_string(i);
    if(num[0] == num[4] && num[1] == num[3]) cnt++;
  }
  cout << cnt << endl;

  return 0;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> v) {os << "(" << v.first << ", " << v.second << ")"; return os;}

void solve() {
  int N;
  cin >> N;
  vector<pii> R(N), B(N);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    R[i] = {a, b};
  }
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    B[i] = {a, b};
  }
  sort(all(B));
  sort(all(R));

  vector<int> flag(N);
  int ans = 0;
  for (int i = 0; i < N; i++) { // B
    int y = -1, j_ = -1;
    for (int j = 0; j < N; j++) { // R
      if (flag[j]) continue;
      if (R[j].first >= B[i].first) continue;
      if (y < R[j].second && R[j].second < B[i].second) {
        y = R[j].second;
        j_ = j;
      }
    }
    if (j_ == -1) continue;
    flag[j_] = 1;
    ans++;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    signed int w, h, r;
    int x, y;

    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

    if(x < 0 || y < 0)
        printf("No\n");
    else if(w - r < x || h - r < y)
        printf("No\n");
    else 
        printf("Yes\n");

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int B[N] = {};
  int A[N];
  for (int i = 1; i < N; i++) {
    cin >> A[i];
    B[A[i]-1]++;
  }
  rep(i, N) cout << B[i] << endl;

  return 0;
}

Measured memory_bytes: 5236
#include <iostream>

using namespace std;

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


    int a;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a % 2 == 0) {
            if (a % 3 == 0 || a % 5 == 0) {
                continue;
            } else {
                cout << "DENIED";
                return 0;
            }
        }
    }

    cout << "APPROVED";

    return 0;
}


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

struct Card {
  char suit;
  int val;
};

int partition(vector<Card>& A, int p, int r) {
  int x = A[r].val;
  int i = p - 1;
  for (int j = p; j < r; ++j) {
    if (A[j].val <= x) {
      ++i;
      swap(A[i], A[j]);
    }
  }
  swap(A[i + 1], A[r]);
  return i + 1;
}

void quickSort(vector<Card>& A, int p, int r) {
  if (p < r) {
    int q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

void merge(vector<Card>& A, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  vector<Card> L(n1 + 1);
  vector<Card> R(n2 + 1);
  for (int i = 0; i < n1; ++i) L[i] = A[left + i];
  for (int i = 0; i < n2; ++i) R[i] = A[mid + i];
  L[n1].val = R[n2].val = INT_MAX;
  int i = 0, j = 0;
  for (int k = left; k < right; ++k) {
    if (L[i].val <= R[j].val) {
      A[k] = L[i];
      ++i;
    } else {
      A[k] = R[j];
      ++j;
    }
  }
}

void mergeSort(vector<Card>& A, int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

bool is_stable(const vector<Card>& c1, const vector<Card>& c2) {
  for (size_t i = 0; i < c1.size(); ++i) {
    if (c1[i].suit != c2[i].suit) return false;
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  vector<Card> c(n);
  for (int i = 0; i < n; ++i) cin >> c[i].suit >> c[i].val;
  vector<Card> c1, c2;
  c1 = c2 = c;
  quickSort(c1, 0, n - 1);
  mergeSort(c2, 0, n);
  if (is_stable(c1, c2)) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  for (int i = 0; i < n; ++i) {
    cout << c1[i].suit << " " << c1[i].val << endl;
  }
}



Measured memory_bytes: 5824
s=input()
if s=="SUN":
    print(7)
elif s=="MON":
    print(6)
elif s=="TUE":
    print(5)
elif s=="WED":
    print(4)
elif s=="THU":
    print(3)
elif s=="FRI":
    print(2)
else:
    print(1)

Measured memory_bytes: 2940
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, k; cin >> n >> k;
	vector<ll> a(n + 1); rep(i, n)cin >> a[i + 1];
	rep(i, n)a[i + 1] += a[i];
	vector<ll> v;
	rep(i, n)for (int j = i + 1; j <= n; ++j)v.push_back(a[j] - a[i]);
	sort(all(v), greater<ll>());
	ll d = 1;
	while (d << 1 < v[0])d = d << 1;
	ll mask = d - 1;
	ll res = 0;
	while (d > 0)
	{
		res = res << 1;
		vector<ll> ok, ng;
		for (ll x : v)
		{
			ng.push_back(x&mask);
			if (x&d)ok.push_back(x&mask);
		}
		if (ok.size() >= k)
		{
			v = ok;
			res += 1;
		}
		else v = ng;
		d = d >> 1;
		mask = mask >> 1;
	}
	cout << res << endl;
}

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

const int MAX_N = 200110;

long long int prime[MAX_N]; // i番目の素数
int num_prime[MAX_N + 1];   // 何番目の素数か

// n以下の素数の数を返す
long long int sieve(long long int n) {
    long long int p = 0;
    for (long long int i = 0; i <= n; i++)
        num_prime[i] = i;
    num_prime[0] = -1;
    num_prime[1] = -1;
    for (long long int i = 2; i <= n; i++) {
        if (num_prime[i] >= 0) {
            num_prime[i] = p;
            prime[p++] = i;
            for (long long int j = 2 * i; j <= n; j += i)
                num_prime[j] = -1;
        }
    }
    return p;
}

int main(){
    int n, p;
    sieve(MAX_N);
    while(cin >> n >> p, n != -1){
        vector<long long int> v;
        int idx = n + 1;
        while(num_prime[idx] < 0)idx++;
        for(int i=num_prime[idx];i<=num_prime[idx]+p;++i){
            if(prime[i] == 0)break;
            v.push_back(prime[i]);
        }
        vector<long long int> sum;
        for(int i=0;i<v.size();++i){
            for(int j=i;j<v.size();++j){
                sum.push_back(v[i]+v[j]);
            }
        }
        sort(sum.begin(), sum.end());
        cout << sum[p-1] << endl;
    }

    return 0;
}



Measured memory_bytes: 4116
//AWTF2019-D
#include<stdio.h>
#include<stdbool.h>
#define prime 10000000019

void llswap(long long *a,long long *b){long long c;c=(*a);(*a)=(*b);(*b)=c;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

long long calcul(long long p,long long q,long long z,long long *r,long long *b){
  long long f=0,cnt=0,w,i;
  (*r)=0;(*b)=0;
  if(p<q){f=1;llswap(&p,&q);}
  i=0;
  while(z>=0){
    w=z/q;
    cnt+=(w+1);
    (*r)+=i*(w+1);
    (*b)+=llsankaku(w);
    z-=p;
    i++;
  }
  if(f){llswap(r,b);}
  return cnt;
}

void calc(long long p,long long q,long long k,long long *r,long long *b){
  long long st,fi,te,c;
  st=0;fi=prime*2000;
  while(st<=fi){
    te=(st+fi)/2;
    c=calcul(p,q,te,r,b);
    if(c==k){break;}
    if(c<k){st=te+1;}
    if(c>k){fi=te-1;}
  }
}

typedef struct{
  long long xz;
  long long yz;
}point;

point vector_minus(point a,point b){
  point r;
  r.xz=a.xz-b.xz;
  r.yz=a.yz-b.yz;
  return r;
}

//gaiseki
long long crossproduct(point a,point b){
  return a.xz*b.yz-a.yz*b.xz;
}

bool ispossible(long long r,long long b,long long k){
  long long st,fi,te,zr,zb;
  long long fr,fb,sr,sb;
  st=1;fi=prime-1;
  while(st<=fi){
    te=(st+fi)/2;
    calc(te,prime-te,k,&zr,&zb);
    if(zr<=r && zb<=b){return true;}
    if(zr>r && zb>b){return false;}
    if(zr>r){st=te+1;sr=zr;sb=zb;}
    else{fi=te-1;fr=zr;fb=zb;}
  }
  //Is (r,b) on above the line{(fr,fb),(sr,sb)}(fr<sr)?
  point tg,l1,l2;
  tg.xz=r;tg.yz=b;
  l1.xz=fr;l1.yz=fb;
  l2.xz=sr;l2.yz=sb;
  if(crossproduct(vector_minus(l2,l1),vector_minus(tg,l1))>=0){return true;}
  return false;
}

long long solve(long long r,long long b){
  long long st=0,fi=2222222,te;
  while(st<=fi){
    te=(st+fi)/2;
    if(ispossible(r,b,te)){st=te+1;}
    else{fi=te-1;}
  }
  return fi;
}

int main(){
  long long r,b;
  scanf("%lld%lld",&r,&b);
  printf("%lld\n",solve(r,b)-1);//-1 : empty box
  return 0;
}


Measured memory_bytes: 128
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

signed main() {
 
	crap;

	int n, k;
	cin >> n >> k;

	vector<int> arr(k);
	for(int i=0; i<k; i++){
		cin >> arr[i];
	}

	int ans = INT_MIN;
	for(int i = 1; i <k; i++)
		ans = max(ans, arr[i] - arr[i-1]);

	ans = max(ans, n - arr[k-1] + arr[0]);

	// cout << ans << endl;
	cout << n - ans << endl;

	return 0;
}






Measured memory_bytes: 1792
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}


int main(){
	int a[2];
	a[0]=ci(), a[1]=ci();
	sort(a,a+2);
	if( a[0]==1 && a[1]==2 ) puts("3");
	if( a[0]==1 && a[1]==3 ) puts("2");
	if( a[0]==2 && a[1]==3 ) puts("1");
	return 0;
}


Measured memory_bytes: 128
n, m = map(int,input().split())
q = [0 for i in range(n)]
alist = []
ac = 0
pe = [0 for i in range(n)]
be = 0
for i in range(m):
    a,b=input().split()
    alist.append((int(a), b))
for i in range(m):
    if q[alist[i][0]-1] == 0:
        if alist[i][1] == 'AC':
            ac += 1
            be = be + pe[alist[i][0]-1]
            q[alist[i][0]-1] = 1
        else:
            pe[alist[i][0]-1] +=  1
    else:
        continue
print(ac,be)

Measured memory_bytes: 20576
#include <iostream>
#include <math.h>
#include <string>    // useful for reading and writing
#include <fstream>   // ifstream, ofstream
#include <sstream>   // istringstream

int main()
{
    int n;
    std::cin >> n;
    for(int i = 1; i <= n; i++)
    {
        int x = i;
        while(x)
        {
            if( i%3 == 0 || x%10==3)
            {
            std::cout << " " << i;
            break;
            }else
            {
                x /= 10;
            }

        }
    }
    std::cout<<std::endl;
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <math.h>
#include <stdio.h>

#define MAX_N 100'001

using namespace std;

int T[MAX_N];
int X[MAX_N];
int Y[MAX_N];

int main() {
  int N;
  cin >> N;
  T[0] = 0;
  X[0] = 0;
  Y[0] = 0;
  for (int i = 1; i <= N; ++i) {
    cin >> T[i] >> X[i] >> Y[i];
  }
  for (int i = 0; i < N; ++i) {
    int t = T[i + 1] - T[i];
    int d = abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i]);
    if (!(d <= t && t % 2 == d % 2)) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
}

Measured memory_bytes: 4216
#include <iostream>

using namespace std;

int main(){
  int a,b,c,d;
  cin>>a>>b;
  if(a<=b){
  for(int i=0;i<b;i++)
    cout<<a;
  }else{
  for(int i=0;i<a;i++)
    cout<<b;
  }
  cout<<endl;
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int S[n];
    for (int i = 0; i < n; i++) {
        cin >> S[i];
    }
    int q;
    cin >> q;
    int C = 0;
    for (int i = 0; i < q; i++) {
        int T;
        cin >> T;
        int min = 0;
        int max = n - 1;
        while (min <= max) {
            int target  = (min + max) / 2;
            if (T == S[target]) {
                C++;
                break;
            }
            if (T > S[target]) {
                min = target + 1;
            } else {
                max = target - 1;
            }
        }
    }
   cout << C << endl;
    return 0;
}

Measured memory_bytes: 3420
N = int(input())
D, X = input().split()
A = []
C = 0

for i in range(N):
    A.append(input())

for i in range(N):
    for j in range(100):    
        if int(A[i])*j + 1 > int(D):
            break
        else:
            C += 1

print("%d" % (C+int(X)))

Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x: usize = read();
    println!(
        "{}",
        match x {
            5 | 3 | 7 => "YES",
            _ => "NO",
        }
    )
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

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

int gcd2(int a, int b) {
    while (a > 0 && b > 0) {
        if (a > b) a %= b;
        else b %= a;
    }
    return (a == 0 ? b : a);
}

int main() {
    int N;
    cin >> N;
    
    int A[100010];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int g = A[0];
    for (int i = 1; i < N; i++) {
        g = gcd2(g, A[i]);
    }
    cout << g << endl;
}

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

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

using namespace std;

signed main(){
	while(true){
		int n; cin >> n;
		if(n == 0)break;
		vector<int> k(n);
		for(auto &&e : k)cin >> e;
		string str; cin >> str;
		vector<int> s(str.size());
		for(size_t i = 0; i < str.size(); i++){
			if(islower(str[i])){
				s[i] = (int)(str[i] - 'a');
			}
			else{
				s[i] = (int)(str[i] - 'A'+26);
			}
		}
		for(size_t i = 0; i < s.size(); i++){
			int st = (s[i] + 52 - k[i%k.size()]) % 52;
			if(st >= 26){
				cout << (char)(st - 26 + 'A');
			}
			else{
				cout << (char)(st + 'a');
			}
		}
		cout << endl;
	}


	return 0;
}




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

int debug = 0;
#define PI 3.14159265359

int main()
{
    int r;
    cin >> r;
    printf("%.20f\n",2*r*PI);
    //     cout << 2 * r * PI << endl;
    return 0;
}

Measured memory_bytes: 3764
n=int(input())
a=list(map(int,input().split()))
import collections
coll=collections.Counter(a)
q=int(input())
suma=sum(a)
lis=[0]*(10**5+1)
for i in a:
    lis[i-1]=coll[i] #lisの「番め」の数字が、aに何個あるか

for i in range(q):
    ans=0
    b,c=map(int,input().split())
    sa=c-b
    lis[c-1]+=lis[b-1]
    ans+=sa*lis[b-1]
    lis[b-1]=0
    suma+=ans
    print(suma)

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

int main()
{
    ll X; cin >> X;
    if (X >= 30) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }




    




}


Measured memory_bytes: 3632
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)];rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo

show_flg=False
show_flg=True

ans=0

n=I()
a=LI()
b=[0]*(n+1)
for i in a:
    b[i]+=1
for i in range(1,n+1):
    print(b[i])

#print(ans%mo)






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

using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
int n,s;
 cin>>n;
vector<int> v(n,0),p(n,0);
for(int i=0;i<n;i++)
cin>>v[i];

for (auto i = 0; i < n; i++)
{
  p[v[i]-1]=i+1;
}
for (int i = 0; i < n; i++)
  cout<<p[i]<<' ';

return 0;
}

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

using namespace std;

int main(){
 int a,b,c,d;
  cin >> a >> b >>c >>d;
  
  if((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d) cout << "Yes" << endl;
  else cout << "No" << endl;



}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    s = input()
    print("yes" if len(set(s)) == len(s) else "no")


if __name__ == "__main__":
    main()




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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int sum = accumulate(a.begin(), a.end(), 0);
    int cnt = 0;
    int th;
    if(sum % 4*m == 0) th = sum / (4*m);
    else th = (sum / (4*m)) + 1;
    for(int i=0;i<n;i++){
        if(a[i] >= th) cnt++;
    }
    if(cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main ( int argc, char** argv )
{
  std::string input;
  std::cin >> input;

  if ( input.at( 2 ) == input.at( 3 ) && input.at( 4 ) == input.at( 5 ) )
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
  return 0;
}

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

AA = A + A

AA_re = list(reversed(AA))
A_re = list(reversed(A))

ans0 = 0
for i in range(N):
    a = A_re[i]
    for j in range(i + 1, N):
        b = A_re[j]
        if a < b:
            ans0 += 1


ans1 = 0
for i in range(N):
    a = AA_re[i]
    for j in range(i + 1, 2 * N):
        b = AA_re[j]
        if a < b:
            ans1 += 1


sa = ans1 - ans0
m = 10 ** 9 + 7
matu = ans0 + sa * (K - 1)
ans = (ans0 + matu) * K // 2

if K == 0:
    print(int(ans0))
    exit()

ans = ans % m


print(int(ans))


Measured memory_bytes: 41692
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Scanner scanner;
    static PrintWriter out;
    public static void main(String[] args) {
        scanner = new Scanner(System.in);
        out = new PrintWriter(System.out);
        long a = nextLong();
        long b = nextLong();
        long c = nextLong();
        long d = nextLong();
        long e = a * c;
        long f = a * d;
        long g = b * c;
        long h = b * d;
        long max = e;
        if (max < f) {
            max = f;
        }
        if (max < g) {
            max = g;
        }
        if (max < h) {
            max = h;
        }
        println(max);
        out.flush();
    }

    public static void println(Object o) {
        out.println(o);
    }

    public static void print(Object o) {
        out.print(o);
    }

    public static void printf(String format, Object... o) {
        out.printf(format, o);
    }

    public static String next() {
        return scanner.next();
    }

    public static int nextInt() {
        return Integer.parseInt(scanner.next());
    }

    public static long nextLong() {
        return Long.parseLong(scanner.next());
    }

    public static double nextDouble() {
        return Double.parseDouble(scanner.next());
    }

    public static short nextShort() {
        return Short.parseShort(scanner.next());
    }

    public static float nextFloat() {
        return Float.parseFloat(scanner.next());
    }

    public static void printYes() {
        System.out.println("Yes");
    }

    public static void printYES() {
        System.out.println("YES");
    }

    public static void printNo() {
        System.out.println("No");
    }

    public static void printNO() {
        System.out.println("NO");
    }

    public static String nextLine() {
        return scanner.nextLine();
    }

    public static double distance(double x, double y, double x2, double y2) {
        return Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));
    }

    public static int MOD = 1_000_000_007;
    public static int MAX = 100000;
    public static long[] fac = new long[MAX];
    public static long[] finv = new long[MAX];
    public static long[] inv = new long[MAX];

    public static void combinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    public static long combination(int n, int k) {
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    public static long factorial(long n) {
        return n <= 0 ? 1 : n * factorial(n - 1);
    }
}

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

int main() {
  vector<string> s(3);
  cin >> s[0] >> s[1] >> s[2];
  int ans, tmp, turn = 0;
  while (1){
    tmp = turn;
    if (s[tmp].size() == 0) {
      ans = tmp;
      break;
    }
    else {
      if (s[tmp].front() == 'a'){
        turn = 0;
        s[tmp].erase(0, 1);
      }
      else if (s[tmp].front() == 'b'){
        turn = 1;
        s[tmp].erase(0, 1);
      }
      else {
        turn = 2;
        s[tmp].erase(0, 1);
      }
    }
  }
  
  if (ans == 0) cout << "A" << endl;
  else if (ans == 1) cout << "B" << endl;
  else cout << "C" << endl;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define N 200005
using namespace std;
int main(){
    int n,x,m,s=1;
    cin>>n>>m;
    --n;
    while(n--){
        cin>>x;
        if(x>=m) m=x, ++s;
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long a=Long.parseLong(sc.next());
long b=Long.parseLong(sc.next());
long x=Long.parseLong(sc.next());
if(a==0){System.out.println(b/x+1);}else{
System.out.println(b/x-(a-1)/x);
}
}}

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

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

    ll N, M;
    cin >> N >> M;

    vector<pair<ll, ll>> AB(N);
    rep(i,N) cin >> AB[i].first >> AB[i].second;

    sort(AB.begin(), AB.end());

    ll sum = 0;
    ll num = 0;
    rep(i,N) {
        if (num + AB[i].second <= M) {
            sum += AB[i].first * AB[i].second;
            num += AB[i].second;
        } else if (num + AB[i].second > M) {
            sum += AB[i].first * (M - num);
            num += M - num;
        }
        if (num == M) break;
    }

    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
signed main(){
    int n, m;
    cin >> n >> m;
    int s =0;
    for(int i=0; m>i; i++){
        int temp ;
        cin >> temp;
        s+=temp;
    }
    if(s > n){
        cout << -1 << endl;
    }else{
        cout << n-s<<endl;
    }
}






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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var h = new HashSet<string>();
            int a = int.Parse(Console.ReadLine());
            for(int i=0; i<a; i++){
                h.Add(Console.ReadLine());
            }
            Console.WriteLine(h.Count);
        }
    }
}


Measured memory_bytes: 43172
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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


ll nC2(ll n){
    if(n<2) return 0;
    return n*(n-1)/2;
}


void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,k; cin >> n >> k;
    vector<double> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    
    
    double ans_tmp = 0;
    for (int i = 0; i < k; i++) ans_tmp += (p[i]+1)/2;
    
    double ans = ans_tmp;
    for (int i = k; i < n; i++) {
        ans_tmp = ans_tmp + (p[i]+1)/2 - (p[i-k]+1)/2;
        ans = max(ans,ans_tmp);
    }
    
    cout << setprecision(10) << ans << endl;
    
    
    
    
    
    
}



signed main() {
    solve();
    return 0;
}



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

public class Main {

	static boolean[] primes;

	static void primeSet(final int MAX){
		primes = new boolean[MAX+1];

		primes[2] = true;
		for(int i=3;i<=MAX;i+=2){
			primes[i] = true;
		}
		int rt = (int) Math.sqrt(MAX);
		for(int i=3;i<=rt;i+=2){
			if(primes[i]){
				for(int j=i*i;j<=MAX;j+=i){
					primes[j] = false;
				}
			}
		}
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(true){
			int n = stdIn.nextInt();
			int p = stdIn.nextInt();
			if(n==-1&&p==-1){
				return;
			}
			primeSet(n+1000);
			int[] u = new int[50];
			int idx = n+1;
			int z = 0;
			for(int i=idx;z<u.length;i++){
				if(primes[i]){
					u[z++] = i;
				}
			}
			z = 0;
			int[] v = new int[1000];
			A:{
				for(int i=0;i<u.length;i++){
					for(int j=i;j<u.length;j++){
						v[z++] = u[i] + u[j];
						if(z==1000){
							break A;
						}
					}
				}
			}
			Arrays.sort(v);
			System.out.println(v[p-1]);
		}
	}
}

Measured memory_bytes: 15000
#include <algorithm>
#include <iostream>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

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

int main() {
    int n;
    cin >> n;
    int val = -1;
    rep(i, 0, n) {
        int _val = -1;
        cin >> _val;
        if (i > 0) {
            val = gcd(val, _val);
        } else {
            val = _val;
        }
    }
    cout << val << endl;
    return 0;
}


Measured memory_bytes: 256