akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int b=1,p=2,i,x,t=1,n;
scanf("%d",&x);
int s[88888]={0};
s[0]=1;
b++;
for(i=p;;i++)
{
    n=(int)(pow(b,i)+0.5);
    if(n>1000)
    {
        i=p-1;
        b++;
    }
    else s[t++]=n;
    if(b>31)break;
}
sort(s,s+t);
n=upper_bound(s,s+t,x)-s-1;
printf("%d\n",s[n]);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,a[5555],f[5555],ans[5555];
int main(){
	cin>>n;
	FOR(i,1,n) getint(a[i]);
	f[1]=1;
	FOR(i,2,n){
	//	i-a[i]
		if (i<a[i]) return puts("-1"),0;
	//	i-a[i] ge bi i chi
	//	a[i]~i-1
		FOR(j,1,i-1) if (f[j]>=a[i]) ++f[j];
		f[i]=i-1-(i-a[i])+1;
	}
	FOR(i,1,n) if (a[i]>f[i]) return puts("-1"),0;
	FOR(i,1,n) ans[f[i]]=a[i];
	FOR(i,1,n) printf("%d\n",ans[i]);
	return 0;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int x,y;
    cin >> x >> y;
    cout <<x+y/2 << endl;
}


Measured memory_bytes: 256
/*
    Print a Frame: ITP1_5_B
*/

#include <stdio.h>

int main(void)
{
    int H, W, i, j;
    while (1) {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0)
            break;

        /* the first line */
        for (i = 0; i < W; i++)
            putchar('#');
        putchar('\n');

        /* totyuu */
        for (i = 2; i < H; i++) {
            putchar('#');
            for (j = 2; j < W; j++)
                putchar('.');
            printf("#\n");
        }
        /* the last line */
        for (i = 0; i < W; i++)
            putchar('#');
        printf("\n\n");
   }
    return (0);
}


Measured memory_bytes: 1964
#!/usr/bin/env python3
from collections import defaultdict,deque
import sys
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
def LI(): return map(int, input().split())
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    mxy = [(0, 1), (1, 0), (-1, 0), (0, -1)]
    h, w, K = LI()
    y1, x1, y2, x2 = LI()
    q = deque()
    field = [[False] * (w + 2)] + [None] * h + [[False] * (w + 2)]
    for i in range(1, h + 1):
        field[i] = [False] + [True] * w + [False]
    for i in range(1, h + 1):
        s = input().rstrip()
        for j in range(1, w + 1):
            if s[j-1] == "@":
                field[i][j] = False
    q.append((x1, y1))
    ans = 0
    c = [[0] * (w + 2) for i in range(h + 2)]
    while q:
        next_q = deque()
        while q:
            x, y = q.pop()
            if (x, y) == (x2, y2):
                print(ans)
                return
            if field[y][x]:
                for i in range(1, K + 1):
                    if field[y + i][x]:
                        if not c[y + i][x]:
                            next_q.append((x, y + i))
                            c[y + i][x] = 1
                    else:
                        break
                for i in range(1, K + 1):
                    if field[y][x + i]:
                        if not c[y][x + i]:
                            next_q.append((x + i, y))
                            c[y][x + i] = 1
                    else:
                        break
                for i in range(1, K + 1):
                    if field[y - i][x]:
                        if not c[y - i][x]:
                            next_q.append((x, y - i))
                            c[y - i][x] = 1
                    else:
                        break
                for i in range(1, K + 1):
                    if field[y][x - i]:
                        if not c[y][x - i]:
                            next_q.append((x - i, y))
                            c[y][x - i] = 1
                    else:
                        break
                field[y][x] = False
        ans += 1
        q = next_q
    print(-1)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 143600
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    string s1,s2;
    cin >> s1 >> s2;
    cout << (s1.at(0)==s2.at(2)&&s1.at(1)==s2.at(1)&&s1.at(2)==s2.at(0) ? "YES" : "NO") << endl; 
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int N; cin >> N;
  vector<int> dp(N + 10);
  dp[0] = 0;
  for (int i = 1; i <= N; i++) {
    dp[i] = 100000000;
    int pow6 = 1;
    while (pow6 <= N) {
      if (i - pow6 < 0) break;
      dp[i] = min(dp[i], dp[i - pow6] + 1);
      pow6 *= 6;
    }
    int pow9 = 1;
    while (pow9 <= N) {
      if (i - pow9 < 0) break;
      dp[i] = min(dp[i], dp[i - pow9] + 1);
      pow9 *= 9;
    }
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 640
'use strict'

function Main(input) {
  const inputList = input.split(' ');
  const numOfBills = Number(inputList[0])
  const moneyTotal = Number(inputList[1])

  const result = [-1, -1, -1]

  for (let i=0; i<=numOfBills; i++) {
    for (let j=0; j<=numOfBills-i; j++) {
      const k = numOfBills - j - i
      const tmpTotal = 10000 * i + 5000 * j + 1000 * k;
        if (tmpTotal === moneyTotal) {
          result[0] = i
          result[1] = j 
          result[2] = k
          break
        }
      
    }
  }

  console.log(result[0])
  console.log(result[1])
  console.log(result[2])
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7876
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main (string[] args) {
        var inp = Console.ReadLine().Split(' ');

        long n = long.Parse(inp[0]);
        long k = long.Parse(inp[1]);

        long nk = n / k;

        long n1 = n - k * nk;
        long prev = n1;

        n1 = Math.Abs(n1 - k);
        if(prev > n1) {
            Console.WriteLine(n1);
        } else {
            Console.WriteLine(prev);
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		a,b,c,d,i,j,k,n,m,x,y,ans = 0;
	char	str[256];
	
	scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);

	if (n%a==0) x = n/a *b;
	else x = (n/a+1)*b;

	if (n%c==0) y = n/c *d;
	else y = (n/c+1)*d;

	printf("%d\n",min(x,y) );


	return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool used[210];
bool graph[100][100] = { false };
bool visited[8];
int n, m, a[50], b[50];

int dfs(int v,int n,bool visited[8]) {
	flag = true;
	for (int i = 0;i < n;i++) {
		if (visited[i] == false) {
			flag = false;
		}
	}
		if (flag) {
			return 1;
		}
		int ans = 0;
		for (int i = 0;i < n;i++) {
			if (graph[v][i] == false)continue;
			if (visited[i])continue;
			visited[i] = true;
			ans += dfs(i, n, visited);
			visited[i] = false;
		}
		return ans;
}

int main() {
	std::cin >> n >> m;
	for (int i = 0;i < m;i++) {
		std::cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	for (int i = 0;i < n;i++) {
		visited[i] = false;
	}
	visited[0] = true;
	std::cout << dfs(0, n, visited) << std::endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    string n;
    cin >> n;
    cout << ((n[0] == n[2]) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#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

int N;
vector<int> D;

signed main()
{
    cin >> N;
    D.resize(N);
    REP(i, N) { cin >> D[i]; }
    SORT(D);

    int rb = N / 2;
    int lb = rb - 1;
    if(rb == lb) {
        printf("0\n");
        return 0;
    }
    int ans = D[rb] - D[lb];
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n, k; cin >> n >> k;
    vector<ll> h(n);
    REP(i, n) cin >> h[i];

    // dp[i][j][k] := i個見て、j個取った。最後取ったのがH_k (kだけ1-indexed)
    vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(n-k+1, vector<ll>(n+1, 1e15)));
    dp[0][0][0] = 0;
    REP(i, n) REP(j, n-k+1) {
        // h_(i+1)を取る
        if (j < n-k) {
            RANGE(l, 0, i) {
                ll hk = l == 0 ? 0 : h[l-1];
                chmin(dp[i+1][j+1][i+1], dp[i][j][l] + max(0LL, h[i] - hk));
            }
        }
        // h_(i+1)を取らない
        RANGE(l, 0, i) {
            chmin(dp[i+1][j][l], dp[i][j][l]);
        }
    }

    cout << *min_element(ALL_OF(dp[n][n-k])) << endl;
    
}

Measured memory_bytes: 216832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[4],o;
double dp[309][309][309],n;
double best(ll x,ll y,ll z)
{
    if(x==0&&y==0&&z==0) return 0;
    double &r=dp[x][y][z],k=x+y+z;
    if(r!=-1)return r;r=0;
    if(x)
    r+=best(x-1,y,z)*x/k;
    if(y)
    r+=best(x+1,y-1,z)*y/k;
    if(z)
    r+=best(x,y+1,z-1)*z/k;
    r+=n/k;
    return r;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
for(ll i=0;i<n;i++){
    cin>>o;
    a[o]++;
}
for(ll i=0;i<305;i++)
for(ll j=0;j<305;j++)
for(ll k=0;k<305;k++)
    dp[i][j][k]=-1;
printf("%0.10f",best(a[1],a[2],a[3]));
return 0;
}


Measured memory_bytes: 229564
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int N;
    cin >> N;
    int c1 = 105, c2 = 165, c3 = 195;
    if(N >= c3) cout << 5;
    else if( N >= 189) cout << 4;
    else if( N >= c2) cout << 3;
    else if( N >= 135) cout << 2;
    else if( N >= c1) cout << 1;
    else cout << 0;

    return 0;
}


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

int N, M, A, B, C, D,s,g,V,P;
int K[32][32];
const int inf = 1001001001;


int main() {
	rep(i, 32) {
		rep(j, 32) K[i][j] = inf;
	}
	cin >> N;
	cin.ignore();
	cin >> M;
	rep (i,M) {
		cin >> A;
		cin.ignore();
		cin >> B;
		cin.ignore();
		cin >> C;
		cin.ignore();
		cin >> D;
		K[A][B] = C;
		K[B][A] = D;
	}
	cin >> s;
	cin.ignore();
	cin >> g;
	cin.ignore(); 
	cin >> V;
	cin.ignore();
	cin>> P;
	
	for (int k = 1; k <= N; k++) {
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) {
				if (K[i][j] > K[i][k] + K[k][j]) K[i][j] = K[i][k] + K[k][j];
			}
		}
	}
	int ans = V - P - K[s][g] - K[g][s];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;

int main()
{
    int w,h,x,y;
    while (~scanf("%d %d %d %d", &w,&h,&x,&y)) {
        long long a = (long long)w * h;
        printf("%lld", a/2);
        if (a%2) printf(".5");
        putchar(' ');

        if (x*2==w && y*2==h) puts("1");
        else puts("0");

    }
    return 0;
}


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

using namespace std;

typedef long long ll;

vector<ll> memo(100010, -1); // k-2の場合

ll MOD = 1e9+7;
int cnt = 0;
ll dfs(int k, const vector<vector<int> > &g, int now, int from=-1){
	int color;
	if(from==-1) color=k-1;
	else color=k-2;

	if(k < g[now].size()) return 0; // 色が足りない

	int c = g[now].size();
	// color P c = color*(color-1)*...*(color-c+1);
	
	ll p = memo[c-1];
	if(from == -1 || p == -1) {
		p = 1;
		for(int i = 0; i < c; ++i){
			if(g[now][i] == from) continue;

			p *= color--;
			p %= MOD;
		}
	}
	/*
	if (memo[c-1] == -1 || from == -1){
		for(int i = 0; i < c; ++i){
			if(g[now][i] == from) continue;

			p *= color--;
			p %= MOD;
		}
		//cout << "c:" << c << " , p:" << p << ", memo:" << memo[c-1] << endl;
		//if(from != -1) memo[c] = p;
	}else{
		p = memo[c-1];
	}
	*/
	
	for(int i = 0; i < c; ++i){
		if(g[now][i] == from) continue;
			
		p *= dfs(k, g, g[now][i], now);
		p %= MOD;
	}

	return p;
}

int main(){
	int N, K; cin >> N >> K;
	vector<vector<int> > G(100010);
	for(int i = 0; i < N-1; ++i){
		int from, to; cin >> from >> to;
		from--; to--;
		G[from].push_back(to);
		G[to].push_back(from);
	}

	// memo計算
	memo[0] = 1;
	memo[1] = (K-2) % MOD;
	int tmp = (K-2)-1;
	for(int i = 2; i <= K-2; ++i){
		memo[i] = memo[i-1] * tmp--;
		memo[i] %= MOD;
	}

	ll ans = K*dfs(K, G, 0);
	ans %= MOD;

	cout << ans << endl;

	return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  ll v[30] ={};
  rep(i,28){
    cin >> n;
    --n;
    v[n] = 1;
  }
  rep(i,30){
    if(v[i] == 0){
      cout << i+1<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3192
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    yukari<int> g(n);
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    akari<int> dp(n), dp2(n);
    int s = -1, maxi = 0;
    auto dfs = [&](auto &&dfs, akari<int> &d, int v, int p) -> void {
        for (int nv : g[v])
        {
            if (nv == p)
            {
                continue;
            }
            d[nv] = d[v] + 1;
            if (maxi < d[nv])
            {
                maxi = d[nv];
                s = nv;
            }
            dfs(dfs, d, nv, v);
        }
    };
    dp[0] = 0;
    dfs(dfs, dp, 0, -1);
    dp2[s] = 0;
    dfs(dfs, dp2, s, -1);
    int x = *max_element(dp2.begin(), dp2.end());
    cout << (x % 3 != 1 ? "First" : "Second") << endl;
}

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

Measured memory_bytes: 19328
n = int(input())
a = list(map(int,input().split()))
key = [0]*n
ans = []
for i in range(n-1,-1,-1):
  if sum(key[i::i+1]) % 2 != a[i]:
    ans.append(i+1)
    key[i] = 1
ans.reverse()
print(len(ans))
print(" ".join(list(map(str,ans))))

Measured memory_bytes: 78556
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

typedef pair<int, int> P;
P f(int x){
    int a = x % 10;
    int b = 0;
    while(x != 0){
        b = x;
        x /= 10;
    }
    return P(a, b);
}

int main(){
    int n;
    cin >> n;
    map<P, int> freq;
    repr(i, 1, n+1){
        P p = f(i);
        freq[p]++;
    }

    ll ans = 0;
    repr(i, 1, n+1){
        P p = f(i);
        P q(p.second, p.first);
        ans += freq[q];
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 256
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-9-8 21:05:03
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
ll X;
ll x[100010];

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

int main()
{
  cin >> N >> X;
  for (auto i = 0; i < N; i++)
  {
    cin >> x[i];
    x[i] -= X;
    x[i] = abs(x[i]);
  }
  if (N == 1)
  {
    cout << x[0] << endl;
  }
  else
  {
    ll ans = gcd(x[0], x[1]);
    for (auto i = 1; i < N; i++)
    {
      ans = gcd(ans, x[i]);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
  int N, K;
  cin >> N >> K;
  ll ans = 0;
  for (int b = K + 1; b <= N; b++) {
    int t = 0;
    t = (b - K) * (N / b);
    t += max((N % b) - K + 1, 0);
    debug("%d - %d\n", b, t);
    ans += t;
  }
  if (K == 0)
    ans -= N;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    string s[n];
    unordered_map<string, long> cnt;
    for (auto &si:s) {
        cin >> si;
        sort(si.begin(), si.end());
        cnt[si]++;
    }
    long sum = 0;
    for (auto ci:cnt) {
        sum += ci.second * (ci.second - 1) / 2;
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 17572
var
	n,i:Longint;
	a,b,p,q,ans:int64;
begin
	read(n,a,b,p);
	for i:=2 to n do begin
		read(q);
		if b>a*(q-p)then ans:=ans+a*(q-p)else ans:=ans+b;
		p:=q;
	end;
	writeln(ans);
end.


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

using namespace std;

void countSort(const vector<int> &init_array,vector<int> &sorted_array,const int max_val){
    vector<int> count_array(max_val+1,0);
    for(int i = 0;i < init_array.size();i++) count_array[init_array[i]]++;
    for(int i = 1;i < max_val+1;i++) count_array[i] = count_array[i] + count_array[i-1];
    for(int j = init_array.size()-1;j >= 0;j--){
        sorted_array[count_array[init_array[j]]-1] = init_array[j];
        count_array[init_array[j]]--;
    }
}

int main(){
    int len_array;
    int temp,max_val = 0;
    scanf("%d",&len_array);
    
    vector<int> int_array(len_array,0);
    vector<int> sorted_array(len_array,0);

    for(int i = 0;i < len_array;i++){
        scanf("%d",&temp);
        int_array[i] = temp;
        max_val = max(temp,max_val);
    } 
    
    countSort(int_array,sorted_array,max_val);
    
    for(int i = 0;i < len_array;i++){
        printf("%d",sorted_array[i]);
        if(i < len_array-1) printf(" ");
        else printf("\n");
    }
    return 0;   
}



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

using namespace std;

int main () {
    long long n; cin >> n;
    bool flag = false;

    long long largestN = 1;

    for (long i = 1; i * i <= n; i++) {
        if (n % i == 0) largestN = i;
    }

    long long pair = n / largestN;

    cout << largestN + pair - 2 << endl;
}

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

int main(){
    int n;
    int ans=0;
    cin>>n;
    for (int i = 1; i <= n; ++i) {
        int t=0;
        for (int j = 1; j <= i; ++j) {
            if(i%2==0)break;
            if(i%j==0)++t;
        }
        if(t>=8)++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import math

a, b = map(int, input().split())

h = 100
w = 100

char_white = '.'
char_black = '#'

fields_w = [[char_white for _ in range(int(w/2))] for _ in range(h)]
fields_b = [[char_black for _ in range(int(w/2))] for _ in range(h)]

spaces_per_row = math.ceil((int(w/2) - 2) / 2.0)

for i in range(a - 1):
    col = i % spaces_per_row
    row = i // spaces_per_row
    fields_b[row * 2 + 1][col * 2 + 1] = char_white

for i in range(b - 1):
    col = i % spaces_per_row
    row = i // spaces_per_row
    fields_w[row * 2 + 1][col * 2 + 1] = char_black

res = np.concatenate((fields_w, fields_b), 1)

print(str(h) + ' ' + str(w))
for row in res:
    print(''.join(row))


Measured memory_bytes: 12724
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        int k = 26;
        StringBuilder ans = new StringBuilder();
        while(n != 0) {
            char a = (char)(n % k + 96);
            if(n % k == 0) {
                a = 'z';
                ans.insert(0, a); 
                n /= k;
                n--;
            }else {
                ans.insert(0, a);  
                n /= k;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35764
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}

template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

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

  ll n;
  std::cin>>n;

  std::string s;
  std::cin>>s;

  ll ans=0;
  char prv=s[0];

  rep(i,0,n){
    if(s[i]!=prv){
      ans++;
      prv=s[i];
    }
  }

  std::cout<<ans+1;
 
  return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
using namespace std;

#define ll long long
#define MP make_pair

int main(void) {
  int n,num=0;
  cin>>n;
  for (int i = 0; i < n; i++) {
    num+=i+1;
  }
  cout<<num<<"\n";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1e9+7;
using namespace std;

int main(){
    int n; cin >> n;
    int num[5] = {0};
    ll ans = 0;
    REP(i, n){
        string s; cin >> s;
        if(s[0] == 'M') num[0]++;
        if(s[0] == 'A') num[1]++;
        if(s[0] == 'R') num[2]++;
        if(s[0] == 'C') num[3]++;
        if(s[0] == 'H') num[4]++;
    }
    REP(i, 5){
        for(int j = i+1; j < 5; j++){
            for(int k = j+1; k < 5; k++){
                ans += (ll)num[i]*num[j]*num[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  int i, ans = 0;
  for(i = 0; i < s.size() - 1; i++){
    if(s.at(i) != s.at(i + 1)){
      ans++;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int w,a,b;
	cin>>w>>a>>b;
	if(abs(b-a)<=w)
		cout<<0<<endl;
	else
		cout<<min(abs(b-a-w),abs(a-b-w))<<endl;
	return 0;
}

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

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  if (c >= a && c <= b) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}



Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<time.h>
#include<cstdlib>
typedef long long ll;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mm(a) memset(a,0,sizeof(a))
#define lr rt<<1
#define rr rt<<1|1
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0);
#define inf 0x3f3f3f3f
#define eqs 1e-8
#define lb(x) (x&(-x))
#define ch(a) (int(a-'0'))
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef pair<int,int> pii;
const double pi=acos(-1);
const int maxn=1010;
//const ll Mod=1000000007;
const ll Mod=998244353;
using namespace std;



char s[200];
int main()
{
    cin>>s;
    int n=strlen(s);
    int f=0;
    for(int i=0,p=n-1;i<n;i++,p--)
    {
        if(s[i]!=s[p])
        {
//            cout<<i<<' '<<p<<' '<<s[i]<<' '<<s[p]<<endl;
            f=1;
        }
    }
    int l=(n-1)/2;
    for(int i=0,p=l-1;i<l;i++,p--)
    {
        if(s[i]!=s[p])
        {
//            cout<<i<<' '<<p<<' '<<s[i]<<' '<<s[p]<<endl;
            f=1;
        }
    }
    
    
    l=(n+3)/2-1;
    for(int i=l,p=n-1;i<n;i++,p--)
    {
        if(s[i]!=s[p])
        {
//            cout<<i<<' '<<p<<' '<<s[i]<<' '<<s[p]<<endl;
            f=1;
        }
    }
    
    
    if(f==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    double x=1.00000000/a;
    double y=1.00000000/b;
    double z=x+y;
    double ans=1/z;
    printf("%.8lf",ans);
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
/* {{{ Definitions */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <ios>
#include <utility>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
/* }}}------------------------------------------- */
string S;
void solve(){
	int n = S[6] - '0';
	if(S[5] == '1'){
		cout << "TBD" << endl;
		return;
	}
	if(n <= 4){
		cout << "Heisei" << endl;
	}
	else
		cout << "TBD" << endl;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> S;
	solve();
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		long[] l = new long[n+1];
		l[0] = 2;
		l[1] = 1;
		
		for(int i = 2; i <= n; i++) {
			l[i] = l[i-2]+l[i-1];
		}
		System.out.println(l[l.length-1]);
		
		
	}

}


Measured memory_bytes: 21844
package main

import "fmt"

func main() {
	var S string
	var ans, cnt int
	fmt.Scan(&S)
	for _, Si := range S {
		if Si == 'A' || Si == 'C' || Si == 'G' || Si == 'T' {
			cnt++
			if cnt > ans {
				ans = cnt
			}

		} else {
			cnt = 0
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
main()
{
    int l[31];
    int w, n;
    int f, t, s;
    int i;

    scanf("%d%d",&w,&n);
    for(i=1;i<=w;i++) l[i]=i;
    for(i=0;i<n;i++){
        scanf("%d,%d",&f,&t);
        s=l[f];
        l[f]=l[t];
        l[t]=s;
    }
    for(i=1;i<=w;i++){
        printf("%d\n",l[i]);
    }
    return 0;
}

Measured memory_bytes: 596
#define S(i) scanf("%d",&i);
int i,n,D,d[500001],Q,m[500001],N=1,a[500001];main(){S(n)S(D)Q=D;for(i=0;i<n;++i){S(d[i])if(Q*2>d[i])Q=abs(Q-d[i]);m[i]=Q;}for(i=n;i>0;--i){if(m[i-1]>=N)a[i]=1;if(2*N>d[i])N+=d[i];}if(D>=N)a[0]=1;S(Q)for(i=0;i<Q;++i){S(D)if(a[D-1])puts("YES");else puts("NO");}}

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

long long lucas[87]={0};

long long test(int x){
	lucas[0]=2;
	lucas[1]=1;

	if(lucas[x])return lucas[x];
	else{
		lucas[x]=test(x-1)+test(x-2);
		return lucas[x];
	}
}

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

	cout<<test(n)<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,k;
    cin >> n >> k;
    if (k == 1) cout << 0 << endl;
    else cout << (n - k) << endl;
}

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

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

ll a,b,c,n,m;
ll ans=100000000000;

string s;

int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin>>n>>m;
  vector<int> v(m);
  rep(i,m)cin>>v[i];
  //sort(v.begin(), v.end(), greater<int>);
  ll sum=0;
  rep(i,m){
    sum+=v[i];
  }
  if(n-sum<0){
    cout<<"-1";
  }
  else{
    cout<<n-sum;
  }
  

  return 0;
}



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

int main(){
  int x, a, b, s;
  s = 1;
  cin >> x;
  a = x / 100;
  b = x % 100;
  if(b > 5 * a)
    s = 0;
  if(x > 99 && x < 106)
    s = 1;
  cout << s << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;


void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}

//出力形式を返す関数
string out(vector<int> v){
    string ans="[";
    for(int i=0;i<v.size();i++){
        if(i!=0) ans+=", ";
        ans+=to_string(v[i]);
    }
    ans+="]";
    return ans;
}

struct Node{
    //自分の親、左右の子、深さ、高さ、次数を保持
    int parent=-1,sibling=-1, left, right, depth=0 , height=0 ,degree;
    string status="internal node";
};


struct bstNode{
    int key;
    bstNode *parent, *left, *right;
};

bstNode *root, *NIL;

void insert(int k){
    bstNode *y=NIL;
    bstNode *x=root;
    bstNode *z;

    z = (bstNode*)malloc(sizeof(bstNode));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    //親を探す
    while(x != NIL){
        y = x;
        if( z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }

    //親を設定。NILのときはｚは根
    z->parent = y;

    if(y==NIL){
        root=z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

void inorder(bstNode *u){
    if(u==NIL) return;
    inorder(u->left);
    cout<<" "<<u->key;
    inorder(u->right);
}

void preorder(bstNode *u){
    if(u==NIL) return;
    cout<<" "<<u->key;
    preorder(u->left);
    preorder(u->right);
}


signed main(){
    int m,x; cin>>m;
    string s;

    for(int i=0;i<m;i++){
        cin>>s;
        if(s=="insert"){
            cin>>x;
            insert(x);
        }else{
            inorder(root); cout<<endl;
            preorder(root); cout<<endl;
        }
    } 

    //setDepthAll(tree,root_index);

    //setHeightAll(tree,root_index);

    //output_tree(tree);
}


Measured memory_bytes: 26472
// Copyright 2019 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N;
	cin >> N;
	array<string, 2> str;
	cin >> str[0] >> str[1];
	for(size_t index = 0; index < N * 2; ++index)
		cout << str[index % 2][index / 2];
	cout << endl;
}


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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    char ta;
    cin >> ta;
    if ('A' <= ta && ta <= 'Z')
        cout << "A\n";
    else
        cout << "a\n";
    return 0;
}

Measured memory_bytes: 3644
import * as fs from 'fs';

namespace AtCoder.abc159 {

    class ProgramC {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        /**
         * in
         * 999
         * out
         *
         */
        main(): void {
            const l: number = parseInt(this.args[0]);

            let a: number = 0;
            let b: number = 0;
            let c: number = 0;

            a = l / 3;
            b = l / 3;
            // a = Math.ceil(l / 3);
            // b = Math.ceil(l / 3);
            c = l - (a + b);

            console.log(a*b*c);
        }
    }

    const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
    const prg = new ProgramC(args);
    prg.main();
}


Measured memory_bytes: 7500
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

				Scanner scan = new Scanner(System.in);

				long A = scan.nextLong();
				long B = scan.nextLong();
				long N = scan.nextLong();

				System.out.println( A * Math.min(B-1, N)/B);

	}

}

Measured memory_bytes: 26816
#include<bits/stdc++.h>
using namespace std;
string s2="keyence",s3="";
int ans=0,ans2=0;
int main()
{
	string s;
	cin>>s;
	int cha=s.size()-7;
	if(s==s2)
	{
		cout<<"YES"<<endl;
		return 0;
	}
	for(int i=0;i<7;i++)
	{
		s3="";
		for(int c=0;c<i;c++)
			s3+=s[c];
		for(int c=i+cha;c<s.size();c++)
			s3+=s[c];
		if(s3==s2)
		{
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int N;
signed main(){
    scanf("%lld",&N);
    int cnt=0;
    rep(i,N){
        int d1,d2;
        scanf("%lld %lld",&d1,&d2);
        if(d1==d2){
            cnt+=1;
        }else cnt=0;
        if(cnt==3){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
}

Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

signed main() {
  int H, W; 
  cin >> H >> W;

  vector<string> s(H);
  REP(i, H) cin >> s[i];

  int ans = 0;
  vector<vector<bool>> visited(H, vector<bool>(W, false));
  REP(i, H) REP(j, W){
    if(visited[i][j]) continue;
    visited[i][j] = true;
    queue<pair<int, int>> q;
    q.push({i, j});
    int brack = 0;
    int white = 0;
    while(!q.empty()){
      auto p = q.front(); q.pop();
      if(s[p.first][p.second] == '#') brack++;
      else white++;
      REP(i, 4){
        int x = p.first+dx[i];
        int y = p.second+dy[i];
        if(OUT(0, x, H)) continue;
        if(OUT(0, y, W)) continue;
        if(visited[x][y]) continue;
        if(s[x][y] == s[p.first][p.second]) continue;
        visited[x][y] = true;
        q.push({x, y});
      }
    }
    ans += brack*white;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512