akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <cstdio>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

const int MAX_N=1000, MAX_U=1000;
int u,n,v,w;
int dp[MAX_U+1];
int res_w[50],res_v[50];
int c=1;

int main(){
	while(cin >> u,u){		
		cin >> n;
		memset(dp, 0, sizeof(dp));

		for(int i=0;i<n;i++){
			scanf("%d,%d", &v,&w);
			for(int j=u;j>=0;j--) if(j-w>=0) dp[j] = max(dp[j], dp[j-w]+v);
		}
		
		int tmp = u;
		for(int i=u;i>=0;i--) if(dp[i]>=dp[tmp]) tmp=i;
		
		cout << "Case " << c << ":" << endl;
		cout << dp[tmp] << endl << tmp << endl;
		c++;
	}
	
	return 0;
}

Measured memory_bytes: 3144
package main

import (
	"os"
	"fmt"
	"bufio"
	"strconv"
)

func main() {
	var ans   = 0
	var fares = []int{0, 0, 0, 0}
	var sc    = bufio.NewScanner(os.Stdin)
	
	for i := 0; i < 4; i++ {
		sc.Scan()
		fares[i], _  = strconv.Atoi(sc.Text())
	}
	
	for i := 0; i < len(fares); i += 2 {
		if fares[i] < fares[i + 1] {
			ans += fares[i]
		} else {
			ans += fares[i + 1]
		}
	}

	fmt.Println(ans)
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//templete
int main() {
    int N;
    cin>>N;
    vll A;
    ll sxor=0;
    for(int i=0;i<N;i++){
        ll a;
        cin>>a;
        A.pb(a);
        sxor^=a;
    }
    //総xorが1である桁は全部0にしとく
    for(int i=0;i<N;i++)
        A[i]&=~sxor;
    int r=0;    //現在のrank
    for(int idx=60;idx>=0;idx--){
        //idx桁目が1であるような要素を探す
        bool flag=0;    //そのような要素が見つかったか？
        for(int i=r;i<N;i++){
            if((A[i]>>idx)&1){
                swap(A[i],A[r]);    //見つけたら上に持ってくる
                flag=1;
                break;
            }
        }
        //A[r]以外でidx番目が1であるような要素すべてにA[r]をxorする
        if(flag){
            for(int i=0;i<N;i++){
                if(i!=r && ((A[i]>>idx)&1))
                    A[i]^=A[r];
            }
            r++;
        }
    }

    ll ans=0;
    for(int i=0;i<N;i++)
        ans^=A[i];
    cout<<2LL*ans+sxor<<endl;
    
    return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
 		Scanner scanner = new Scanner(System.in);
 		int K = scanner.nextInt();
 		String S = scanner.next();
 		String[] S1 = S.split("");

 		if (K >= S1.length) {
 			for (int j = 0; j < S1.length; j++) {
 	 			System.out.print(S1[j]);
 	 		}
 		} else {
 			for (int j = 0; j < K; j++) {
 	 			System.out.print(S1[j]);
 	 		}
 			System.out.println("...");
 		}
 	}
 }

Measured memory_bytes: 35788
#include <iostream>

using namespace std;

int main()
{
    int n;
    n=10000;
    for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    if(x>y){
cout<<y<<" "<<x<<endl;}
 else if(x==0&&y==0)
    {return 0;}
 else{
     cout<<x<<" "<<y<<endl;
 }
    }
    return 0;
}



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

using namespace std;

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int n = r * 100 + g * 10 + b;
    if(n%4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner as = new Scanner(System.in);
		
		int dice1[];
		int dice2[];
		String str = "";
		Boolean breakp = null;
		
		dice1 = new int[6];
		dice2 = new int[6];
		
		for(int i=0;i<6;i++){
			
			dice1[i] = as.nextInt();
			
		}
		
		for(int i=0;i<6;i++){
			
			dice2[i] = as.nextInt();
			
		}
		
		for(int i=0;i<3;i++){
		
			for (int j=0;j<4;j++){
				
				for(int k=0; k<j; k++){
					
					dice2 = Spin.diceSpin(dice2, "x");
					
				}
				
				breakp = Spin.Check(dice1, dice2, i);
				
				if(breakp == true){
					
					str = "Yes";
					break;
					
				}
				else{
					
					str = "No";
					
				}
				
			}
			
			if(breakp == true){
				
				break;
				
			}
		
		}
		
		System.out.println(str);

	}

}


class Spin{
	
	public static int[] diceSpin(int[] dice,String spn) {
	
		int tre = 0;	
			
		switch (spn){
		case "x":
			tre = dice[4];
			dice[4] = dice[0];
			dice[0] = dice[1];
			dice[1] = dice[5];
			dice[5] = tre;
			break;
			
		case "y":
			tre = dice[3];
			dice[3] = dice[0];
			dice[0] = dice[2];
			dice[2] = dice[5];
			dice[5] = tre;
			break;
			
		case "z":
			tre = dice[2];
			dice[2] = dice[1];
			dice[1] = dice[3];
			dice[3] = dice[4];
			dice[4] = tre;
			break;
					
		}
			
		return dice;
		
	  }
	
	public static Boolean Samecheck(int[] dice1,int[] dice2){
		
		Boolean flag = null;
		
		for(int i=0;i<6;i++){
			
			if(dice1[i] != dice2[i]){
				
				flag = false;
				break;
			}
			else{
				
				flag = true;
				
			}
			
		}
		
		return flag;
		
	}
	
	public static Boolean Check(int[] dice1,int[] dice2,int sp){
		
		Boolean flag = null;
		String spn = null;
		
		switch (sp){
		case 0:
			spn = "x";
			break;
			
		case 1:
			spn = "y";
			break;
			
		case 2:
			spn = "z";
			break;
			
		}
		
		for(int j=0;j<4;j++){		
			
			dice2 = Spin.diceSpin(dice2, spn);
			if(Spin.Samecheck(dice1, dice2)){
				
				flag = true;
				break;
			
			}
			
			flag = false;
			
		}
		
		return flag;
		
	}
	
}

Measured memory_bytes: 26320
#include<stdio.h>
#include<string.h>
int main()
{
	int n,i;
	int t[100005],x[100005],y[100005];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	 	scanf("%d%d%d",&t[i],&x[i],&y[i]);
	for(i=0;i<n;i++)
	{
		if(x[i]<0)
			x[i]=-x[i];
		if(y[i]<0)
			y[i]=-y[i];
	}
	for(i=0;i<n;i++)
	{
		if(t[i]<(x[i]+y[i])||(t[i]-(x[i]+y[i]))%2!=0)
		{
			printf("No\n");
			break;
		}
	}
	if(i>=n)
	printf("Yes\n");		 
	return 0;
}

Measured memory_bytes: 1280
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const int N = 2e5 + 5;

int n;
int go[N];

void solve() {
  cin >> n;
  ll k; cin >> k;
  for(int i = 1; i <= n; i++) {
    int x; cin >> x;
    go[i] = x;
  }
  int p = 1;
  int who = -1;
  set <int> s;
  while(true) {
    p = go[p];
    if(s.count(p)) {
      who = p;
      break;
    }
    s.insert(p);
  }
  int old = who;
  vector <int> cyc;
  cyc.push_back(who);
  while(true) {
    who = go[who];
    if(who == old) break;
    cyc.push_back(who);
  }
  int cur = 1;
  while(true) {
    cur = go[cur];
    k--;
    if(cur == old) {
      break;
    }
    if(k == 0) {
      print(cur);
      return;
    }
  }
  int m = cyc.size();
  cout << cyc[k % m] << '\n';
}

int main() {
  int t; t = 1;
  while(t--) solve();
}


Measured memory_bytes: 13668
import java.util.*;
class Main{
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		String table[]=new String[100000];
		int now=0;
		HashMap<String ,ArrayList<Integer > > map=new HashMap<String, ArrayList<Integer> >();
		while(s.hasNext()){
			String str=s.next();
			int a=s.nextInt();
			if(map.containsKey(str)){
				map.get(str).add(a);
			}
			else{
				table[now++]=str;
				ArrayList<Integer> p=new ArrayList<Integer>(0);
				p.add(a);
				map.put(str,p);
			}
		}
		Arrays.sort(table,0,now);
		for(int i=0;i<now;i++){
			Integer dat[]=map.get(table[i]).toArray(new Integer[100]);
			Arrays.sort(dat,0,map.get(table[i]).size());
			System.out.println(table[i]);
			System.out.print(dat[0]);
			for(int j=1;j<map.get(table[i]).size();j++)
				System.out.print(" "+dat[j]);
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C

#D
def root(x):
    if x == par[x]:
        return x
    par[x] = root(par[x])
    return par[x]

def same(x,y):
    return root(x) == root(y)

def unite(x,y):
    x = root(x)
    y = root(y)
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1
n = I()
v = LIR(n)
l = [None for i in range(2*n-2)]
for i in range(n):
    v[i].append(i)
par = [i for i in range(n)]
rank = [0 for i in range(n)]
v.sort(key = lambda x:x[0])
for i in range(n-1):
    l[i] = [v[i][2],v[i+1][2],v[i+1][0]-v[i][0]]
v.sort(key = lambda x:x[1])
for i in range(n-1):
    l[i+n-1] = [v[i][2],v[i+1][2],v[i+1][1]-v[i][1]]
l.sort(key = lambda x:x[2])
k = 0
ans = 0
for i in range(2*n-2):
    x,y,c = l[i]
    if not same(x,y):
        k += 1
        ans += c
        unite(x,y)
    if k == n-1:break
print(ans)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 127180
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

int main(){

	std::string str;
	std::getline(std::cin, str);

	std::vector<std::string> moji;
	std::vector<int> cost;

	std::string maxsize = "A";

	for (int i = 0, j = 0; i <= str.size(); i++){
		if (i == str.size() - 1 || str[i] == ' '){
			std::string s = str.substr(j, i - j);
			j = i + 1;

			std::vector<std::string>::iterator it = std::find(moji.begin(), moji.end(), s);
			if (it == moji.end()){
				moji.push_back(s);
				cost.push_back(1);
			}
			else {
				cost[it - moji.begin()]++;
			}

			if (s.size() > maxsize.size())maxsize = s;
		}
	}

	
	int maxhind = 0;
	std::string res;
	for (int i = 0; i < moji.size(); i++){
		if (cost[i]>maxhind){
			res = moji[i];
			maxhind = cost[i];
		}
	}

	std::cout << res << " " << maxsize << std::endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i) {
        sum *= i;
    }
    return sum;
}


// max = 8
vector<bool> used(10, false);
vector<int> x(10);
vector<int> y(10);
int n;
long double sum = 0.0;

vector<vector<double long>> length(10, vector<double long>(10));


void re(int prev_point){
    rep(i, n) {
        if(used[i] == false) {
            // 計算処理
            used[i] = true;
            sum += length[prev_point][i];
            re(i);
            used[i] = false;
        }
    }
    //return sum;
}


int main() {
    cin >> n;
    rep(i, n) cin >> x[i] >> y[i];

    rep(i, n) rep(j, n) {
        length[i][j] = sqrt((x[j]-x[i])*(x[j]-x[i]) + (y[j]-y[i])*(y[j]-y[i]));
    }

    int tmp = n*n - n;
    int cnt = facctorialMethod(n)*(n-1)/tmp;
    long double ans = 0.0;
    rep(i, n) rep(j, n) {
        ans += length[i][j]*cnt;
    }

    cout << std::setprecision(10) << ans / facctorialMethod(n) << endl;

    return 0;


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

int n, m, q;
vector<vector<unordered_map<int, int>>> v;

void dfs(vector<int>& cur, int score, int& res) {
	if ((int)cur.size() == n) {
		res = max(res, score);
		return;
	}
	int i = cur.empty() ? 1 : cur.back();
	for (; i <= m; i++) {
		cur.push_back(i);
		int ns = score;
		for (int j = 0; j < (int)cur.size() - 1; j++) {
			ns += v[cur.size()][j + 1][i - cur[j]];
		}
		dfs(cur, ns, res);
		cur.pop_back();
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> q;
	v = vector<vector<unordered_map<int, int>>>(n + 1, vector<unordered_map<int, int>>(n + 1, unordered_map<int, int>()));
	for (int i = 0; i < q; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		v[b][a][c] = d;
	}

	int res = 0;
	vector<int> cur;
	dfs(cur, 0, res);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n;
	cin >> n;
	vii p; vi ans(n);
	int x;
	Foz(i, n) { cin >> x; p.pb({x, i}); }
	sort(all(p));
	Foz(i, n) {
		if (i < n / 2) ans[p[i].second] = p[n / 2].first;
		else ans[p[i].second] = p[n / 2 - 1].first;
	}
	Foz(i, n) cout << ans[i] << '\n';
}



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

const ll MOD = 1000000007LL;

int main(){
    string s;
    cin >> s;
    vector<char> c;
    int f = 0;
    ll ans = 0;

    rep(i, s.size()){
        
        if(i == 0) {
            c.push_back(s[i]);
            continue;
        }
        if(f < 0) {
            c.push_back(s[i]);
            f++;
            continue;
        }
        if(s[i] != c[f]){
            ans += 2;
            c.pop_back();
            f--;
        }else{
            c.push_back(s[i]);
            f++;
        }
    }
    cout << ans << endl;

    return 0;
}

/*
22222

 1011
11011010001011
*/


Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define fi first
#define se second
#define bug cout<<"--------------"<<endl
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=1e9;
const ll llf=1e18;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
typedef pair<int,int> pii;
pii a[110],b[110];
vector<int>f[110];
int col[maxn],vis[maxn];
bool dfs(int u){
	for(int x:f[u]){
		if(vis[x]) continue;
		vis[x]=1;
		if(!col[x]||dfs(col[x])){
			col[x]=u;
			return 1;
		}
	}
	return 0;
} 
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].fi>>a[i].se;
	}
	for(int i=1;i<=n;i++){
		cin>>b[i].fi>>b[i].se;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(a[i].fi<b[j].fi&&a[i].se<b[j].se){
				f[i].push_back(j+n);
			//	f[j+n].push_back(i); 
			}
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		memset(vis,0,sizeof(vis));
		if(dfs(i)) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
//Leonidas
#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container'.',hpp>
//#include <ext/pb_ds/tree_policy'.',hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1e9+7;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int32_t main()
{
    speed
    int n;
    cin>>n;
    cout<<(1000-(n%1000))%1000;
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <math.h>

int main()
{
	unsigned int n,m,a,sum,cnt;
	int ret;

	scanf("%d", &n);
	scanf("%d", &m);

	if (n < 1 || n > 1000000 ||
	    m < 1 || m > 10000) {
			return 1;
	}

	cnt = m;
	sum = 0;
	do {
		a = 0;
		scanf("%d", &a);
		if (a < 1 || a > 10000) {
			continue;
		}
		sum+=a;
		cnt--;
		// printf("a = %d\n", a);
	} while (cnt);

	ret = n - sum;

	if (ret < 0) {
		printf("-1");
	} else {
		printf("%d", ret);
	}
	
	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    priority_queue<pair<int,int>> even,odd;
    map<int,int> o,e;
    for(int i = 0; i < n; i += 2){
        o[v[i]]++;
        e[v[i+1]]++;
    }
    for(int i = 0; i < n; i += 2){
        even.push({o[v[i]],v[i]});
        odd.push({e[v[i+1]],v[i+1]});
    }
    even.push({-1,-1});
    odd.push({-1,-1});
    while(!odd.empty() || !even.empty()){
        pair<int,int> od,ev;
        od = odd.top();
        ev = even.top();
        if(od.second == -1 || ev.second == -1){
            cout << n/2 << endl;
            return 0;
        }
        else if(od.second != ev.second){
            cout << n-od.first-ev.first << endl;
            //cout << od.second << " " << ev.second << endl;
            return 0;
        }
        else if(od.first > ev.first) even.pop();
        else if(od.first < ev.first) odd.pop();
        else{
            pair<int,int> a,b;
            odd.pop(); even.pop();
            a = odd.top(); b = even.top();
            even.push(ev);odd.push(od);
            if(a.first > b.first) odd.pop();
            else even.pop();
        }
    }

}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int ans = 0;
  int curMin = 1e9;
  rep(i,n) {
    curMin = min(curMin, p[i]);
    if (curMin == p[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;
#define M(x,y) ((x)>(y)?(x):(y))
#define m(x,y) ((x)<(y)?(x):(y))

int main() {
	ll a,b,n,ans=0;
	scanf("%lld %lld %lld", &a,&b,&n);
	
	Rep(i,1,a+1) {
		ll x=floorl(i*b/a);
		if (x > n) break;
		ans = M(ans,floorl(a*(x%b)/b));
		ll X=floorl(-1+i * b / a);
		if (X > n) break;
		ans = M(ans, floorl(a * (X % b) / b));
	}
	ans = M(ans, floorl(a*(n % b)/b));
	ll Ans = ans;
	printf("%lld", Ans);
}

Measured memory_bytes: 1692
N, P = [int(_) for _ in input().split()]
A = [int(_) % 2 for _ in input().split()]
dp_e = 1
dp_o = 0
for a in A:
    if a:
        dp_e += dp_o
        dp_o = dp_e
    else:
        dp_e *= 2
        dp_o *= 2
if P:
    print(dp_o)
else:
    print(dp_e)


Measured memory_bytes: 2940
N = int(input())
D, X = map(int, input().split())

A = [int(input()) for i in range(N)]

eated = 0

for i in range(len(A)):
    if A[i] == 1:
        eated += D
    elif D % A[i] == 0:
        eated += D // A[i]
    else:
        eated += D // A[i] + 1

print(X + eated)

Measured memory_bytes: 3064
def judge(n, s):
    for x in range(n, -1, -1):
        for y in range(n - x, -1, -1):
            if 10000 * x + 5000 * y + 1000 * (n - x - y) == s:
                return str(x) + " " + str(y) + " " + str(n - x - y)
    return "-1 -1 -1"

n, s = map(int, input().split())

print(judge(n, s))


Measured memory_bytes: 3060
k,q = input().split()
k = int(k)
q = int(q)

d = input().split()
for i in range(k):
    d[i] = int(d[i]) - 1

import numpy as np
d = np.array(d)

for r in range(q):
    n,x,m = input().split()
    n = int(n)
    x = int(x)
    m = int(m)

    dd = d % m + np.ones(k,dtype="int")
    DD = np.concatenate((np.zeros(1, dtype="int"),np.cumsum(dd) ))
    
    alast = x + DD[k]*((n-1)//k) + DD[(n-1)%k]
    kuriagari = alast // m - x//m

#    print([x%m, alast, alast%m, n - kuriagari - 1])
    print (n - 1 - kuriagari)

Measured memory_bytes: 13428
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

ll n,a,b,d;
vector<ll> h;

bool check(ll m){
    ll cnt=0;
    REP(i,n){
        ll H = h[i] - m*b;
        if(H<=0)continue;
        cnt += (H+d-1)/d;
    }
    return cnt<=m;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>a>>b;
    d = a-b;
    ll ma = 0;
    REP(i,n){
        ll x;
        cin>>x;
        h.push_back(x);
        ma = max(ma,x);
    }
    ll l=0,r=ma/b+1000;
    while(r-l>1){
        ll m = (l+r)/2;
        if(check(m)) r=m;
        else l = m;
    }
    if(!check(l)) l=r;
    cout<<l<<endl;
}

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

#ifdef __WIN32
#define LLFORMAT "I64"
#else
#define LLFORMAT "ll"
#endif

using namespace std;

const int maxn = 3e5 + 10, N = maxn - 10;

int cnt[maxn];

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n), b;
	bool flag = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if(i && a[i] <= a[i - 1]) {
			if(a[i] <= N) b.push_back(a[i]);
			flag = 1;
		}
	}
	if(!flag) { cout << "1\n"; return 0; }
	if(!b.size()) { cout << "2\n"; return 0; }
	int lb = 1, rb = n;
	while(lb <= rb) {
		auto check = [&](int lim) {
			set<int> pos;
			memset(cnt, 0, sizeof cnt);
#ifdef DEBUG
			cout << "check(" << lim << ")\n";
#endif
			for (int x: b) {
				int y = x;
				while(cnt[y] == lim) {
					--y;
					if(y == 0) return false;
				}
				++cnt[y];
				pos.insert(y);
				for(;;) {
					auto it = pos.end();
					--it;
					if(*it == y) break;
					cnt[*it] = 0;
					pos.erase(it);
				}
#ifdef DEBUG
				cout << "x = " << x << endl;
				for (int i: pos) cout << "cnt[" << i << "] = " << cnt[i] << endl;
#endif
			}
			return true;
		};
		int mid = lb + rb >> 1;
		if(check(mid)) rb = mid - 1;
		else lb = mid + 1;
	}
	cout << lb + 1 << endl;
	return 0;
}


Measured memory_bytes: 3316
import std.stdio, std.typecons;

alias Tuple!(int, "year", int, "month", int, "day") Date;

int[] days = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];

bool is_leap_year(Date d) {
  return d.year % 4 == 0 && (d.year % 400 == 0 || d.year % 100 != 0);
}

int count_leap_year(Date d) {
  int count;
  if (is_leap_year(d) && d.month > 2) count++;
  d.year -= 1;
  return count += (d.year / 4 - d.year / 100 + d.year / 400);
}

int sub(Date d1, Date d2) {
  int count = (d2.year - d1.year) * 365 +
    (days[d2.month - 1] - days[d1.month - 1]) +
    (d2.day - d1.day) +
    (count_leap_year(d2) - count_leap_year(d1));
  return count;
}

void main() {
  for(int y1, m1, d1, y2, m2, d2;
      readf("%d %d %d %d %d %d\n", &y1, &m1, &d1, &y2, &m2, &d2), y1 != -1;) {
    sub(Date(y1, m1, d1), Date(y2, m2, d2)).writeln;
  }
}

Measured memory_bytes: 1064
n,m,k = map(int, input().split())

#############

mod = 10**9 + 7
max = n*m + 10
fac, finv, inv = [0]*max, [0]*max, [0]*max

def comInit(max):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( n<0 | k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

#############

ans = n*n*(m-1)*m*(m+1)//6 + m*m*(n-1)*n*(n+1)//6
ans = ans % mod
ans = (com(n*m -2, k-2) * ans) % mod

print(ans)

Measured memory_bytes: 43376
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=2e4+40,P=1e9+7;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }

int n,a[N],b[N],p[N]; 

int main(int argc,char *argv[]){
#ifdef GCURIOUSCAT
	//freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	read(n); 
	rep(i,1,n)read(p[i]); 
	rep(i,1,n)a[i]=b[i]=1;
	rep(i,1,n){
		a[p[i]+1]+=n-i;
		b[p[i]-1]+=n-i;
	}
	rep(i,2,n)a[i]+=a[i-1];
	dec(i,n-1,1)b[i]+=b[i+1]; 
	rep(i,1,n)printf("%d%c",a[i]," \n"[i==n]); 
	rep(i,1,n)printf("%d%c",b[i]," \n"[i==n]); 
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
    cout << fixed << setprecision(10);
    int a,b;
    cin >> a >> b;
    int d = a/b;
    int r = a%b;
    double f = (double)a / (double)b;
    cout << d <<" "<< r <<" "<< f << endl;
}


Measured memory_bytes: 3236
n = gets.to_i
A = gets.split.map(&:to_i)
C = Array.new(A.max + 1, 0)

A.each do |a|
  C[a] += 1
end


count = 0
C.each_with_index do |c, i|
  C[i] += count
  count += c
end

ans = []
for i in 1..n
  ans[C[A[n - i]] - 1] = A[n - i]
  C[A[n - i]] -= 1
end

puts ans.join(' ')



Measured memory_bytes: 153792
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <utility>
using namespace std;

// Union-Find 木 (Verified: AtCoder Typical Contest 001 B)
struct UnionFind {
private:
    const int n;
    int __size, base_size;
    vector<int> uf, has_base;
public:
    // 初期化 UnionFind uni(n) のように宣言すれば良い
    UnionFind(int _n, vector<int> has_base_) : n(_n), __size(_n), uf(_n, -1), has_base(has_base_) {
        base_size = 0;
        for(auto e : has_base_) base_size += (e > 0);
    }
    // find (木の根を求める)
    int find(int x) {return (uf[x] < 0) ? x : uf[x] = find(uf[x]);}
    // x と y が同じ集合に属するかどうか
    bool same(int x, int y) {return find(x) == find(y);}
    // x が属する集合の要素数
    int size(int x) {return -uf[find(x)];}
    int base(int x) {return has_base[find(x)];}
    // 集合はいくつあるか
    int size()      {return __size;}
    int size_base() {return base_size;}
    // x と y の属する集合を併合
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return;
        __size--;
        if(uf[y] < uf[x]) swap(x, y);
        if(has_base[x] and has_base[y]) base_size--;
        has_base[x] += has_base[y];
        uf[x] += uf[y]; uf[y] = x;
    }
};

int solve_testcase(int case_num) {
    int N, T, K; cin >> N >> T >> K;
    if(N == 0 and T == 0 and K == 0) return 1;

    vector<int> is_base(N);
    vector< tuple<int, int, int> > edges;

    int sum = 0;
    for(int i=0; i<N-1; i++) {
        int u, v, w; cin >> u >> v >> w;
        u--; v--; sum += w;
        edges.emplace_back(w, u, v);
    }
    sort(edges.rbegin(), edges.rend());

    for(int i=0; i<T; i++) {
        int v; cin >> v; v--;
        is_base[v] = true;
    }

    int ans = sum, rem = N - 1 - K;
    UnionFind uf(N, is_base);
    for(auto e : edges) {
        if(rem == 0) break;
        int w, u, v; tie(w, u, v) = e;
        // fprintf(stderr, "edge (%d, %d), cost = %d, base = (%d, %d), size_base = %d\n", u, v, w, uf.base(u), uf.base(v), uf.size_base());
        if(uf.same(u, v)) ans -= w, rem--;
        else if(uf.base(u) and uf.base(v) and uf.size_base() == K+1) continue;
        else {
            uf.unite(u, v);
            ans -= w, rem--;
        }
    }

    printf("Case %d: %d\n", case_num, ans);
    return 0;
}

int main() {
    int t = 0;
    while(!solve_testcase(++t));
    return 0;
}



Measured memory_bytes: 3244
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <cctype>

#define int long long 

using namespace std;

struct node{
	int key;
	node *prev;
	node *next;
};

class doubly_linked{
private:
	
public:
	node *head;
	doubly_linked(){
		head = new node();
		head->next = head;
		head->prev = head;
	}
	void insert(int x){
		node *now = new node();
		now->next = head->next;
		head->next->prev = now;
		head->next = now;
		now->prev = head;
		now->key = x;
	};
	void delete2(int x){
		node *now = head->next;
		while ((now->key != x) && (now != head)) now = now->next;
		if (now != head){
			now->prev->next = now->next;
			now->next->prev = now->prev;
		}
	}
	void deleteFirst(){
		head->next = head->next->next;
		head->next->prev = head;
	}
	void deleteLast(){
		head->prev = head->prev->prev;
		head->prev->next = head;
	}
	void print(){
		node *now = head->next;
		bool fst = false;
		while (now != head) {
			if (fst) cout << " ";
			else  fst = true;
			cout << now->key;
			now = now->next;
		}
		cout << endl;
	}
};

signed main(){
	doubly_linked d;
	int n, v;
	string s;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		if (s == "insert") {
			cin >> v;
			d.insert(v);
		}
		if (s == "delete"){
			cin >> v;
			d.delete2(v);
		}
		if (s == "deleteFirst") d.deleteFirst();
		if (s == "deleteLast") d.deleteLast();
	}
	d.print();
}

Measured memory_bytes: 37536
H, W, K = map(int, input().split())

C = [input() for i in range(H)]

import itertools

ans = 0
for i in itertools.product([0, 1], repeat=H):
    for j in itertools.product([0, 1], repeat=W):
        count = 0
        for h in range(H):
            for w in range(W):
                if i[h] != 1 and j[w] != 1 and C[h][w] == "#":
                    count += 1
        if count == K:
            ans += 1
print(ans)

Measured memory_bytes: 68292
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder116_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] t_input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

            int AB = t_input[0];
            int BC = t_input[1];
            int CA = t_input[2];

            int result = AB * BC / 2;

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11476
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

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

	ll n, k, q;
	cin >> n >> k >> q;

	vector<ll> a(q);
	vector<ll> ans(n, 0);
	rep(i, q)
	{
		cin >> a[i];
		ans[a[i] - 1]++;
	}

	rep(i, n)
	{
		if (k - (q - ans[i]) > 0)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}


}

Measured memory_bytes: 2176
#include<stdio.h>
int main()
{
  int A[100],N,i,j,k,count=0;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      scanf("%d",&A[i]);
      for(j=i;j>0;j--)
	{
	  if(A[j]<A[j-1])
	    {
	      k=A[j-1];
	      A[j-1]=A[j];
	      A[j]=k;
	      count++;
	    }
	  else break;
	}
    }
  for(i=0;i<N-1;i++) printf("%d ",A[i]);
  printf("%d\n%d\n",A[N-1],count);
  return 0;
}

Measured memory_bytes: 600
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
#include<unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define MAX ((ll)1<<(ll)31)-1

int main(void) {
	ll n, a, b; cin >> n >> a >> b;
	ll x, y;
	x = max(a, b);
	y = min(a, b);
	if ((x - y) % 2 == 0) {
		cout << (x - y) / 2 << endl;
	}
	else {
		int ans = 0;
		if (n - x < y - 1) {
			ll k = n - x;
			x = n;
			y += k+1;
			cout << k + 1 + (x - y) / 2 << endl;
		}
		else {
			ll k = y - 1;
			y = 1;
			x -= k + 1;
			cout << k + 1 + (x - y) / 2 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n, x = map(int,input().split())
candies = list(map(int,input().split()))
ans = 0

for i in range(n):
    if candies[i] > x:
        margin = candies[i] - x
        candies[i] -= margin
        ans += margin

for i in range(1, n):
    if candies[i] + candies[i-1] > x:
        margin = (candies[i] + candies[i-1]) - x
        candies[i] -= margin
        ans += margin

print(ans)


Measured memory_bytes: 14152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long int ll;
 
 
 ll N = 1000005;
const ll mod = 998244353;
const long long int inf = 1e10+5;
#define pp pair<ll,ll>
 
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
void fastIO(void);
 
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);

 




int main(){
   
  ll n;
  cin>>n;
  ll a[n];
  rep(i,n) cin>>a[i];
  ll cnt=0,temp=1;
  rep(i,n){
      if(a[i]==temp){
          temp++;
          cnt++;
      }
  }
  if(cnt==0) cout<<-1<<endl;
  else
    cout<<n-cnt<<endl;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}
 

Measured memory_bytes: 1792
import math

s,need = list(map(int, input().split())) 

pos=0.0

if(s>=need):
    pos+=(0.0+s-need)/s

now=min(s,need)
while(True):
    p=math.ceil(math.log2(float(need)/now))
    pos += 1.0/s * 0.5**p
    if(now==1):
        break
    now-=1
        
print(pos)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mod 998244353
using namespace std;
int n, k, res, fac[500007], inv[500007];
int main()
{
	cin >> n >> k;
	fac[0] = fac[1] = inv[0] = inv[1] = 1;
	for (int i = 2; i <= k; i++)
		fac[i] = 1LL * fac[i - 1] * i % mod;
	for (int i = 2; i <= k; i++)
		inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
	for (int i = 2; i <= k; i++)
		inv[i] = 1LL * inv[i - 1] * inv[i] % mod;
	for (int i = n; i <= k; i++)
		res = (res + 1LL * fac[k - 1] * inv[i - 1] % mod * inv[k - i] % mod) % mod;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

int main()
{
	UINT n, k;

	cin >> n >> k;


	cout << ((2 * k <= n + 1) ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
//ぶっちゃけ問題文理解してないけど、正しい出力でるのでおｋ
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
  int d,n;
  cin >> d >> n;
  
  if(d==0){
    cout << n + (n/100) << endl;
    return 0;
  }
  if(d==1){
    cout << 100 * n + 100 * (n/100) << endl;
    return 0;
  }
  if(d==2){
    cout << setprecision(15) <<  pow(100,d) * n + pow(100,d) * (n/100) << endl;
    return 0;
  }
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int r, D, x;

signed main() {
	cin >> r >> D >> x;
	rep (i, 10) {
		int t = r * x - D;
		cout << t << endl;
		x = t;
	}

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	abc := make([]string,3)
	all := 0
	for i := 0; i < 3; i++ {
		abc[i] = scanString()
		all += len(abc[i])
	}

	check := func(s1,s2 string) []bool {
		res := make([]bool, all)
		for i := 0; i < all; i++ {
			res[i] = true
		}

		for i := 0; i < len(s1); i++ {
			n := min(len(s1[i:]),len(s2))
			for j := 0; j < n; j++ {
				if s1[i:][j] != s2[j] && s1[i:][j] != '?' && s2[j] != '?' {
					res[i] = false
					break
				}
			}
		}

		return res
	}

	ans := all

	permutationSearch(3, func(a []int) {
		s1,s2,s3 := abc[a[0]],abc[a[1]],abc[a[2]]

		s1s2 := check(s1,s2)
		s2s3 := check(s2,s3)
		s1s3 := check(s1,s3)

		for i := 0; i < len(s1)+1; i++ {
			ma := max(len(s2)+1,len(s1[i:])+1)
			for j := 0; j < ma; j++ {
				if s1s2[i] && s2s3[j] && s1s3[i+j] {
					l := max(max(len(s1), i+len(s2)), i+j+len(s3))
					ans = min(ans, l)
				}
			}
		}
	})

	fmt.Fprintln(wr, ans)

}

func permutationSearch(n int, fn func(a []int)) {
	a := make([]int, n)
	for i := 0; i < n; i++ { a[i] = i }
	swap := func(i,j int) { a[i],a[j] = a[j],a[i] }

	fn(a)
	for i := n-2; i >= 0; i-- {
		if a[i] > a[i+1] { continue }
		for j := n-1; j >= 0; j-- {
			if a[i] > a[j] { continue }
			swap(i,j)
			for k := i+1; k < (n+i+1)/2; k++ { swap(k,n-(k-i)) }
			fn(a)
			i = n-1
			break
		}
	}
}



Measured memory_bytes: 768
# vim: set fileencoding=utf-8:


def main():
    N = int(input())
    divisors = make_divisors(N)
    ans = 10000000000000000000000000

    if pow(divisors[-1], 2) == N:
        ans = kansuu(divisors[-1], divisors[-1])
    else:

        for idx in range(0, len(divisors)-1, 2):
            ans = min(ans, kansuu(divisors[idx], divisors[idx+1]))

    print(ans)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def kansuu(A, B):
    return max(len(str(A)), len(str(B)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N, M; 
	cin >> N >> M; 
	vector<int> E[100010] = {}; 
	for(int i = 0; i < M; i++){
		int a, b; 
		cin >> a >> b; 
		a--; b--; 
		E[a].push_back(b);
		E[b].push_back(a);  
	}
	int F[100010] = {}; 
	int S = -1; int G = -1; 	
	for(int i = 0; i < N; i++){
		F[i] = E[i].size(); 
		if(S == -1 && F[i] == 4) {S = i; continue;}
		if(S >= 0 && G == -1 && F[i] == 4) G = i; 
	}
	sort(F, F+N, greater<int>()); 
	bool possible = true; 
	for(int i = 0; i < N; i++){
		if(F[i] % 2) possible = false; 
	}
	if(F[0] == 2) possible = false; 
	if(N >= 2 && F[0] == 4 && F[1] == 2) possible = false; 
	if(N >= 3 && F[0] == 4 && F[1] == 4 && F[2] == 2){
		int a = E[S].at(0); int b = E[S].at(1); 
		int c = E[S].at(2); int d = E[S].at(3); 
		vector<int> A; vector<int> B; 
		vector<int> C; vector<int> D; 
		A.push_back(S); B.push_back(S); 
		C.push_back(S); D.push_back(S); 
		A.push_back(a); B.push_back(b); 
		C.push_back(c); D.push_back(d); 
		int score = 0; 
		for(int i = 0; i < 114514; i++){
			if(A.at(A.size() - 1) == S) break; 
			if(A.at(A.size() - 1) == G){
				score ++; break; 
			}
			int p = E[A.at(A.size()-1)].at(0); 
			int q = E[A.at(A.size()-1)].at(1); 
			if(p != A.at(A.size()-2)) A.push_back(p); 
			else A.push_back(q);  
		}
		for(int i = 0; i < 114514; i++){
			if(B.at(B.size() - 1) == S) break; 
			if(B.at(B.size() - 1) == G){
				score ++; break; 
			}
			int p = E[B.at(B.size()-1)].at(0); 
			int q = E[B.at(B.size()-1)].at(1); 
			if(p != B.at(B.size()-2)) B.push_back(p); 
			else B.push_back(q);  
		}
		for(int i = 0; i < 114514; i++){
			if(C.at(C.size() - 1) == S) break; 
			if(C.at(C.size() - 1) == G){
				score ++; break; 
			}
			int p = E[C.at(C.size()-1)].at(0); 
			int q = E[C.at(C.size()-1)].at(1); 
			if(p != C.at(C.size()-2)) C.push_back(p); 
			else C.push_back(q);  
		}
		for(int i = 0; i < 114514; i++){
			if(D.at(D.size() - 1) == S) break; 
			if(D.at(D.size() - 1) == G){
				score ++; break; 
			}
			int p = E[D.at(D.size()-1)].at(0); 
			int q = E[D.at(D.size()-1)].at(1); 
			if(p != D.at(D.size()-2)) D.push_back(p); 
			else D.push_back(q);  
		}
		if(score == 4) possible = false; 
	}	 
	if(possible) cout << "Yes" << endl; 
	else cout << "No" << endl; 
}

Measured memory_bytes: 6656