akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int MOD = 1000000007;
const int N = 50;

int tab[N][N], bat[N][N], i, j, res, n;
LL k;

//mnozenie macierzy A*B=C(%mod), wymiary nxn
void wymnozMacierze (int A[N][N], int B[N][N], int C[N][N], int n, int mod) {
 	int i,j,k;
 	for (i=0;i<n;i++) for (j=0;j<n;j++) C[i][j]=0;
 	for (i=0;i<n;i++) for (j=0;j<n;j++) for (k=0;k<n;k++) C[i][j]=(C[i][j]*1LL+A[i][k]*1LL*B[k][j]) % mod;
}

//potegowanie macierzy (A(nxn) ^ b) % c, wynik w R
void potegujMacierz (int A[N][N], int R[N][N], int n, long long b, int c) {
 	int T[N][N],M[N][N],i,j;
 	for (i=0;i<n;i++) for (j=0;j<n;j++) {
     	R[i][j]=(i==j);
     	M[i][j]=A[i][j];
 	}
 	while (b) {
       	if (b%2) {
          	wymnozMacierze(R,M,T,n,c);
          	for (i=0;i<n;i++) for (j=0;j<n;j++) R[i][j]=T[i][j];
       	}
       	wymnozMacierze(M,M,T,n,c);
       	for (i=0;i<n;i++) for (j=0;j<n;j++) M[i][j]=T[i][j];
       	b/=2;	 
 	}
}


int main() {
scanf("%d %lld", &n, &k);
for (i=0;i<n;i++) for (j=0;j<n;j++) scanf("%d", &tab[i][j]);
potegujMacierz(tab, bat, n, k, MOD);
res = 0;
for (i=0;i<n;i++) for (j=0;j<n;j++) res = (res + bat[i][j]) % MOD;
printf("%d\n", res);
return 0;
}

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

const int mod = 1e9+7;

ll powmod(ll x, ll y) {
    ll res = 1;
    for (int i=1; i<=y; i++) {
        res = res*x%mod;
    }
    return res;
}

int main() {
    ll N;
    cin >> N;
    ll ans = powmod(10, N) - powmod(9, N) - powmod(9, N) + powmod(8, N);
    ans %= mod;
    ans = (ans + mod)%mod;
    cout << ans << endl;
    return 0;
}   

Measured memory_bytes: 3620
// abc112_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, T;
    cin >> N >> T;

    int ans = INF;
    REP(i, N){
        int c, t;
        cin >> c >> t;

        if (t <= T){
            ans = min(ans, c);
        }
    }

    if (ans == INF) {
        print("TLE");
    } else {
        print(ans);
    }


    return 0;
}


Measured memory_bytes: 256
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

S = input().rstrip()

G = []

state = 0
tmp = []
for s in S:
	if state == 0 and s == 'R':
		tmp.append(s)
		continue
	if state == 0 and s == 'L':
		state = 1
		tmp.append(s)
		continue
	if state == 1 and s == 'L':
		tmp.append(s)
		continue
	if state == 1 and s == 'R':
		state = 0
		G.append(tmp)
		tmp = []
		tmp.append(s)
G.append(tmp)

A = []

for g in G:
	r = g.count('R')
	l = len(g)-r

	h = len(g)//2
	if not len(g)%2:
		a = h
		b = h
	elif r>l:
		if r%2:
			a = h+1
			b = h
		else:
			a = h
			b = h+1
	else:
		if l%2:
			a = h
			b = h+1
		else:
			a = h+1
			b = h
	
	L = [0] * len(g)
	L[r-1] = a
	L[r] = b
	A.extend(L)

#print(A)
print(' '.join(map(str, A)))

Measured memory_bytes: 16368
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);

    auto dp = new long[][](n + 1, 2);
    fillAll(dp, -inf6);
    dp[0][0] = 0;

    foreach (i ; 0 .. n) {
        foreach (j ; 0 .. 2) {
            if (dp[i][j] == -inf6) continue;
            dp[i + 1][0] = max(dp[i + 1][0], dp[i][j] + (-1)^^j * a[i]);
            dp[i + 1][1] = max(dp[i + 1][1], dp[i][j] + (-1)^^(j ^ 1) * a[i]);
        }
    }

    debug {
        writefln("%(%s\n%)", dp);
    }

    auto ans = dp[n][0];

    writeln(ans);
}

























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

#define MAX_N 100000

// string input = "1222";

string input;
vector<int> s;
string ans = "";

void dfs(int i, int sum, string exp) {
    // 停止条件
    if (i == s.size() - 1) {
        // cout << exp << endl;
        // cout << sum << endl;
        if (sum == 7) {
            ans = exp;
        }
        return;
    }

    // + 使う
    // cout <<  s[i + 1] << endl;
    dfs(i + 1, sum + (s[i + 1]), exp + "+" + to_string(s[i + 1]));

    // - 使う
    dfs(i + 1, sum - (s[i + 1]), exp + "-" + to_string(s[i + 1]));
}

int main() {
    cin >> input;
    for (int i = 0; i < input.length(); i++) {
        // cout << input[i] << endl;
        // cout << typeid(input[i]).name() << endl;
        // printf("%d\n", input[i] - '0');
        s.push_back(input[i] - '0');
    }
    // cout << s[0] << endl;
    // string init = { s[0] };
    dfs(0, s[0], to_string(s[0]));

    cout << ans + "=7" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
	public static void main(String[] args) {
		print();
	}

	public static void print() {
		try {
			List<Integer> numList = new ArrayList<>();
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder sb = new StringBuilder();

			String str = br.readLine();
			String[] nums = str.split(" ", 0);

			for (int i = 0; i < nums.length; i++) {
				numList.add(Integer.parseInt(nums[i]));
			}
			Collections.sort(numList);
			Collections.reverse(numList);

			for (int i = 0; i < numList.size(); i++) {
				sb.append(numList.get(i));
				if (i != numList.size() -1) {
					sb.append(" ");
				}
			}

			System.out.println(sb);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24272
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        boolean found = false;
        for (int i = 1; i <= B; i++) {
            if ((i * A) % B == C) {
                found = true;
            }
        }
        System.out.println(found? "YES" : "NO");
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {

string a; cin>>a;
  int keta=a.size();
  
  int o=0,z=0;
  rep(i,keta){if(a.at(i)=='0'){z++;}else{o++;}}
  int mi=min(o,z);  
  cout<<mi*2<<endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload(_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(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){in(r...);return true;}
    else return false;
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
const int INF = 1e18, MOD = 1e9 + 7;
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

main(){
    INCANT;
    int n, lcnt = 0, rcnt = 0, res = 0;
    string s;
    in(n, s);
    each(c, s){
        if(c == ')'){
            if(rcnt){
                rcnt--;
            }else{
                lcnt++;
            }
        }else{
            rcnt++;
        }
    }
    while(lcnt--){
        out('(');
    }
    out(s);
    while(rcnt--){
        out(')');
    }
}


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

int main(){
  int N,M;
  cin >> M >> M;
  vector<int> L(M),R(M);
  for(int i=0;i<M;i++){
    cin >> L[i] >> R[i];
  }
  sort(L.begin(),L.end());
  sort(R.begin(),R.end());
  if(R[0]-L[M-1]+1>=0){
    cout << R[0]-L[M-1]+1 << endl;
    return 0;
  }
  else{
    cout << 0 << endl;
    return 0;
  }
}

Measured memory_bytes: 4028
#include <iostream>
using namespace std;
typedef long long ll;
ll n,a[100000],ans,rans;
int main(void){
    while(1){
        rans=0;
        ans=0;
        cin>>n;
        if(n==0)return 0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            ans+=a[i];
        }
        for(int i=0;i<n;i++){
            if(a[i]*n<=ans)rans++;
        }
        cout<<rans<<endl;
    }
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+100;
struct node
{
    ll x,y,u,v;
};
node a[maxn];
int main()
{
    ll n,mn1=1e18,mn2=1e18,mx1=-1e18,mx2=-1e18;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].x>>a[i].y;
        a[i].u=a[i].x+a[i].y;
        a[i].v=a[i].x-a[i].y;
        mn1=min(mn1,a[i].u);
        mn2=min(mn2,a[i].v);
        mx1=max(mx1,a[i].u);
        mx2=max(mx2,a[i].v);
    }
    cout<<max({mx1-mn1,mx2-mn2});
    return 0;
}


Measured memory_bytes: 9740
#include <cstdio>
#include <iostream>
using namespace std;
const int Q=1<<9;
int f[Q][Q],sm[Q][Q];
int MOD;
inline int add(int a,int b)
{a+=b;return a>=MOD?a-MOD:a;}
inline int sub(int a,int b)
{a-=b;return a<0?a+MOD:a;}
inline int mul(int a,int b)
{return 1LL*a*b%MOD;}
int c[Q][Q];
int main()
{
	int n,k;
	scanf("%d%d%d",&n,&k,&MOD);
	for(int i=0;i<=n;i++){
		c[i][0]=1;
		for(int j=1;j<=i;j++)
			c[i][j]=add(c[i-1][j],c[i-1][j-1]);
	}
	for(int i=0;i<=k;i++)f[1][i]=1,sm[1][i]=k-i+1;
	for(int i=2;i<=n+1;i++){
		for(int j=0;j<=k;j++){
			for(int l=1;l<=i;l++)
				f[i][j]=add(f[i][j],mul(c[i-2][l-1],mul(f[i-l][j],sm[l][j+1])));
		}
		for(int j=k;j>=0;--j)
			sm[i][j]=add(sm[i][j+1],f[i][j]);
	}
	printf("%d",f[n+1][0]);
	return 0;
}

Measured memory_bytes: 2048
import bisect
import sys
n = int(input())
up = sorted(list(map(int, input().split())))
mid = sorted(list(map(int, input().split())))
low = sorted(list(map(int, input().split())))
ans = 0
for i in range(len(mid)):
    pre = bisect.bisect_left(up, mid[i])
    over = len(low) - bisect.bisect(low, mid[i])
    ans += pre * over

print(ans)


Measured memory_bytes: 106436
#include <iostream>

using namespace std;
 
int main() {
    int n = 0, max = -1000001, min = 1000001, a;
    long long sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        sum += a;
        if (a < min) {
            min = a;
        }
        if (a > max) {
            max = a;
        }
    }
    cout << min << " " << max << " " << sum << endl;
}


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;


std::vector<std::int64_t> divisor_list(std::int64_t n){
  std::vector<std::int64_t> temp, ret;

  {
    std::int64_t i;
    for(i = 1LL; i * i < n; ++i){
      if(n%i == 0){
        temp.push_back(n / i);
        ret.push_back(i);
      }
    }
    if(i * i == n) ret.push_back(i);
  }

  std::reverse(temp.begin(), temp.end());
  ret.insert(ret.end(), temp.begin(), temp.end());
  
  return ret;
}


i64 power(i64 x){
  return x * x * x * x * x;
}


int main(){
  i64 X;

  while(cin >> X){

    //auto divs = divisor_list(X);
    [&](){
      FORE(a,0,300){
        FORE(b,-300,300){
          if(power(a) - power(b) == X){
            pout(a, b);
            return;
          }
        }
      }
    }();
    
  }

  return 0;
}


Measured memory_bytes: 3656
n,k=map(int,input().split())
ans=0
if k==0:
    print(n**2)
    exit()

for b in range(1,n+1):
    if k>b-1:
        continue
    ans+=n//b*(b-k)
    ans+=max(n-n//b*b+1-k,0)

print(ans)

Measured memory_bytes: 64420
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	cin>>n;
	string str,num[10]={"0","1","2","3","4","5","6","7","8","9"};
	string s[10]={" ",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	for(int i=0;i<n;i++){
		cin>>str;
		for(int j=0;j<str.size();j++){
			for(int k=1;k<=9;k++){
				if(num[k][0]==str[j]){
					int cnt=-1;
					while(str[j]!='0'){
						cnt++;
						j++;
					}
					string S=s[k];
					cout<<S[cnt%S.size()];
				}
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include<iostream>
using namespace std;
int main()
{
	int i=0,n,m=0,j=0,a[114];
	for(cin>>n;i<n;cin>>a[i++]);
	for(a[i]=0;j++<114;)for(i=0;i<n;m+=a[i++]-->0&&a[i]<=0);
	cout<<m<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    int H, W;
    static int A[100][100], B[100][100];
    static bool dp[100][100][15000];
    cin>>H>>W;
    rep(i, H) rep(j, W){
        cin>>A[i][j];
    }
    rep(i, H) rep(j, W){
        cin>>B[i][j];
    }
    MEMSET(dp, false);
    dp[0][0][abs(A[0][0]-B[0][0])]=true;
    rep(i, H) rep(j, W) rep(k, 15000) if(dp[i][j][k]==true){
            //cout<<i<<" "<<j;
        dp[i][j+1][k+abs(A[i][j+1]-B[i][j+1])]=true;
        dp[i][j+1][abs(k-abs(A[i][j+1]-B[i][j+1]))]=true;
        
        dp[i+1][j][k+abs(A[i+1][j]-B[i+1][j])]=true;
        dp[i+1][j][abs(k-abs(A[i+1][j]-B[i+1][j]))]=true;
        
    }
    rep(k, 7000){
        if(dp[H-1][W-1][k]==true){
            cout<<k<<endl;
            return 0;
        }
    }
    //cout<<"HELLO"<<endl;
    return 0;
}


Measured memory_bytes: 146816
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vpl vector<pair<long, long> >
#define vppl vector<pair<long, pair<long, long> > >

const int INF = 100100100;
const long LONG_INF = 2147483647;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n >> a >> b;
    if (n*a>=b)
    {
        cout << b;
    } else
    {
        cout << n*a;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    long int N;
    cin >> N;
    long int s = 9*N;
    if(N%2==0||N%5==0){
        //cout << "divided" << endl;
        cout << -1;
        return 0;
    }
    long int d = 9;
    for(long i = 1;i<20000000;i++){
        if((7*d)%s==0){
            //cout << "founded" << endl;
            cout << i;
            return 0;
        }
        d = (d*10+9)%s;
    }
    //cout << "unfounded" << endl;
    cout << -1;
    return 0;
}


Measured memory_bytes: 3176
import sys
sys.setrecursionlimit(500000)

def main():
    N, M = map(int, input().split())
    E = [[] for _ in range(N+1)]
    for u, v, s in zip(*[iter(map(int, sys.stdin.read().split()))]*3):
        E[u].append((v, s))
        E[v].append((u, s))

    V = [[None] * (N+1), [None] * (N+1)]

    def dfs(v=1, sign=1, val=0):
        V[sign][v] = val
        sign = 1 - sign
        for u, s in E[v]:
            if V[sign][u] is None:
                dfs(u, sign, s-val)
            else:
                if V[sign][u] != s-val:
                    print(0)
                    exit()

    dfs()

    mi, ma = 1, float("inf")
    for m, p in zip(V[0][1:], V[1][1:]):
        if m is not None and p is not None:
            mp = m - p
            if mp % 2 == 0:
                a = mp // 2
                mi = max(mi, a)
                ma = min(ma, a)
            else:
                ma = -1
        if p is not None:
            mi = max(mi, 1-p)
        if m is not None:
            ma = min(ma, m-1)

    ans = max(0, ma-mi+1)
    print(ans)

main()


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

int main() {
	// your code goes here
        int num;
        int num2;

	std::cin >> num;
	std::cin >> num2;

	std::cout << num*num2 << " " << num * 2 + num2 * 2 << std::endl;	
	return 0;
}

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

static const int INF = 1001001001;

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

    vector<double> vecV(n);
    for(int i=0; i<n; i++)  cin >> vecV.at(i);

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

    while(vecV.size() > 1){
        vecV[0] = (vecV[0]+vecV[1])/2;
        vecV.erase(vecV.begin() + 1);
    }

    printf("%.10f\n", vecV.front());

    return 0;
}

Measured memory_bytes: 256
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main(void){
     long long a,b,k;
    cin >> a>> b>> k;
    if(k>a){
        b =b-k+a;
        a = 0;
    }else{
        a = a-k;
    }
    if(a <0)a=0;
    if(b<0)b= 0;
    cout << a << " "<< b<< endl;
    return 0;
}

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

// varibable settings
#define int long long
const int INF=1e18;
const int MOD=1e9+7;

// define basic macro {{{
#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 _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

signed main() {
  int n;cin>>n;
  vector<int> a(n);
  rep(i, n) {
    cin>>a[i];
  }
  dump(a);

  int ans = 0;
  int curmin = 1;
  rep(i, n){
    if (a[i]<curmin) continue;
    if (a[i]==curmin){
      curmin++;continue;
    }
    int d;
    ans += d=(a[i]-1)/curmin;
    chmax(curmin, 2LL);
    dump(i, curmin, a[i], d);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1152
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;


class Tpair{
    public: 
	int first, second;
	Tpair(int x,int y) {first=x; second=y;}
	bool operator<(const Tpair &a)const{
		return (first)*(second) < (a.first)*(a.second);
    }
};

typedef Tpair P;


int main()
{
	int i,j,k,l,m,n;
	int w,d,s,p;
	
	while(cin>>n>>w>>d){
		vector<P> cakes; cakes.clear();
		if(n==0&&w==0&&d==0)
			break;
		cakes.push_back(P(w,d));
		rep(i,n){
			cin>>p>>s;
			int ww=cakes[p-1].first, dd=cakes[p-1].second;
			cakes.erase(cakes.begin()+p-1);

			s = s % (2*ww+2*dd);
			vector<P> subcakes; subcakes.clear();
			if(s<ww){ subcakes.push_back(P(s,dd)); subcakes.push_back(P(ww-s,dd));}
			else if(s<ww+dd){s=s-ww; subcakes.push_back(P(ww,s)); subcakes.push_back(P(ww,dd-s));}
			else if(s<2*ww+dd){s-=ww+dd; subcakes.push_back(P(s,dd)); subcakes.push_back(P(ww-s,dd));}
			else{s-=2*ww+dd; subcakes.push_back(P(ww,s)); subcakes.push_back(P(ww,dd-s));}
			sort(subcakes.begin(),subcakes.end());
			cakes.push_back(subcakes[0]);
			cakes.push_back(subcakes[1]);
		}
		sort(cakes.begin(),cakes.end());
		rep(i,cakes.size()-1) cout << cakes[i].first*cakes[i].second << " ";
		cout<<cakes[i].first*cakes[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

// MOD確認

ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}


int main(){
   ll N;
   cin >> N;
   ll ans = modpow(10,N,MOD) - (ll)2 * modpow(9,N,MOD) + modpow(8,N,MOD);
   while(ans < 0) ans += MOD * (ll)1000000000;
   cout << ans % MOD << endl;
}

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

int main(){
 
 ll N,K; cin >> N >> K;
 vector<ll> A(N);
 for(ll i = 0; i < N; i++){ cin >> A[i];}
 
 vector<ll> sub;
 
 for(ll l = 0; l < N; l++){
 ll sum = 0; 
  for(ll r = l; r < N; r++){
   sum += A[r];
   
   sub.push_back(sum);
   }
  }
  //ここまでOK
  
  ll m = sub.size();
  
  ll ans  = 0;
  
  vector<bool> avb(m,true);
  
  for(ll bit = 40; bit >= 0; bit--){
   //K個以上がこのフラグを立てるか調べる
   ll cnt = 0;
   for(ll i = 0; i < m; i++){
     if( ( (sub[i] >> bit) & 1 ) && avb[i]){ cnt++;}
   }
   bool flag = false;
   if( cnt >= K){ flag = true;  ans += (1LL << bit);}
   
   if(flag){
    //ここで使わなかったものを封じる
    
    for(ll i = 0; i < m; i++){
      if( !((sub[i] >> bit) & 1)){ avb[i] = false;}
     }
  }// flag-if
 } //bit-if
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 6260
#include <iostream>
#include <vector>
#include <algorithm>
#define ALL(c) c.begin(),c.end()
#define REP(i, n) for(int i = 0; i < n; i++)

using namespace std;
typedef long long ll;

int main()
{
  ll X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X), B(Y), C(Z);
  REP(i, X) cin >> A[i];
  REP(i, Y) cin >> B[i];
  REP(i, Z) cin >> C[i];
  sort(ALL(A), greater<ll>());
  sort(ALL(B), greater<ll>());
  sort(ALL(C), greater<ll>());
  vector<ll> v;
  for (int i = 1; i <= X; i++) {
    if (i > K) break;
    for (int j = 1; j <= Y; j++) {
      if (i * j > K) break;
      for (int k = 1; k <= Z; k++) {
        if (i * j * k > K) break;
        v.push_back(A[i - 1] + B[j - 1] + C[k - 1]);
      }
    }
  }
  sort(ALL(v), greater<ll>());
  REP(i, K) {
    cout << v[i] << endl;
  }

  return 0;
}

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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

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

    V<int> dp(n + 1, n);
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        for(int p6 = 1; p6 <= i; p6 *= 6){
            dp[i] = min(dp[i], dp[i - p6] + 1);
        }
        for(int p9 = 1; p9 <= i; p9 *= 9){
            dp[i] = min(dp[i], dp[i - p9] + 1);
        }
    }

    cout << dp[n] << endl;

}


Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	ll N = getint(), A = getint(), B = getint();
	int mae = getint();
	ll kotae = 0;
	rep(i, N - 1) {
		int tugi = getint();
		kotae += min(A * (tugi - mae), B);
		mae = tugi;
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(int, const char**)
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> v(n);
    rep(i, n)
    {
        v[i] = s[i] - '0';
    }
    int pc = 0;
    rep(i, n)
    {
        pc += v[i];
    }

    vector<int> baseMods(2);
    vector<vector<int>> mods(2, vector<int>(n));
    int pcs[] = {pc + 1, pc - 1};
    mods[0][n - 1] = 1 % pcs[0];
    mods[1][n - 1] = pcs[1] > 0 ? 1 % pcs[1] : 0;
    rep(i, 2)
    {
        baseMods[i] = 0;
        rep(j, n)
        {
            baseMods[i] = pcs[i] > 0 ? (baseMods[i] * 2 + v[j]) % pcs[i] : 0;
        }
        rep(j, n - 1)
        {
            int index = n - j - 2;
            mods[i][index] = pcs[i] > 0 ? (mods[i][index + 1] * 2) % pcs[i] : 0;
        }
    }

    vector<int> smods(n);
    rep(i, n)
    {
        if(v[i] == 0)
        {
            smods[i] = (baseMods[0] + mods[0][i]) % pcs[0];
        }
        else
        {
            smods[i] = pcs[1] > 0 ? (baseMods[1] - mods[1][i] + pcs[1]) % pcs[1] : -1;
        }
    }

    rep(i, n)
    {
        int count = 1;
        auto m = smods[i];
        if(m == -1)
        {
            cout << 0 << endl;
            continue;
        }
        while(m != 0)
        {
            bitset<64> bs(m);
            auto p = bs.count();
            m %= p;
            count++;
        }
        cout << count << endl;
    }
    return 0;
}


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

using namespace std;

int n;
string s;
int a[300010];

main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    cin >> s;
    for(int i = 0; i < n; i++){
        a[i] = (s[i] == 'E');
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
    }
    int sum2 = 0;
    int an = INT_MAX;
    for(int i = 0; i < n; i++){
        sum -= a[i];
        an = min(an, sum + sum2);
        sum2 += a[i] == 0;
    }
    cout << an << endl;
}


Measured memory_bytes: 1812
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
using namespace std;

int main(void){
    int a;
    cin>>a;
    if(a==25){
        cout<<"Christmas"<<endl;
    }else if(a==24){
        cout<<"Christmas Eve"<<endl;
    }else if(a==23){
        cout<<"Christmas Eve Eve"<<endl;
    }else if(a==22){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
n,d,a = map(int,input().split())
xh = [list(map(int,input().split())) for _ in range(n)]

xh.sort()
j = 0
cnt = [0] * n
taken = 0

def problem(h):
    if h <= 0:return 0
    ans = h//a
    if h%a :
        ans += 1
    return ans

for i in range(n):
    [x,h] = xh[i]
    while xh[j][0] + 2*d < x:
        taken -= cnt[j]
        j += 1
    # if taken * a >= h:
    #     break
    # if not h % a:
    #     cnt[i] = h//a - taken
    # else:
    #     cnt[i] = h//a - taken + 1
    cnt[i] = problem(h - taken * a)
    taken += cnt[i]
print(sum(cnt))


Measured memory_bytes: 83672
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
p = [0 for i in range(N)]
for i in range(N):
    p[i] = int(input())

p.sort()
ans = sum(p)
ans -= p[-1] // 2
print(ans)

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

using namespace std;

const int M = 2e5 + 1;
vector<int> adj[M];
int val[M], L[M], ans[M], n;

void solve(int cur, int parent, int mx) {
    int l = 0, r = n - 1, curAns, prev;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (L[mid] < val[cur])
            l = mid + 1, curAns = mid + 1;
        else
            r = mid - 1;
    }
    prev = L[curAns];
    L[curAns] = val[cur];
    mx = max(mx, curAns);

    for (int x : adj[cur])
        if (x != parent)
            solve(x, cur, mx);
    ans[cur] = mx;
    L[curAns] = prev;
}

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

    cin >> n;
    L[0] = 0;
    for (int i = 1; i <= n; i++)
        cin >> val[i], L[i] = 2e9;

    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    solve(1, 0, 0);

    for (int i = 1; i <= n; i++)
        cout << ans[i] << '\n';

    return 0;
}


Measured memory_bytes: 34076
import sys

sys.setrecursionlimit(1000000000)

maxv,maxe = map(int , input().split())
g = [[] for i in range(maxv)] #グラフ
rg = [[] for i in range(maxv)] #逆グラフ
vs =  [0 for i in range(maxv)] #帰りがけ順の並び(トポロジカル順序)
used = [0 for i in range(maxv)] #既に調べたか
compo = [0 for i in range(maxv)] #属する強連結成分のトポロジカル順序

for i in range(maxe):
    s,t = map(int , input().split())
    g[s].append(t)
    rg[t].append(s)

def dfs(v):
    used[v] = 1
    for nextv in g[v]:
        if(not used[nextv]) :dfs(nextv)
    vs.append(v)

def rdfs(v,k):
    used[v] = 1
    compo[v] = k
    for nextv in rg[v]:
        if (not used[nextv]): rdfs(nextv,k)

for i in range(maxv):
    if not used[i] : dfs(i)

used = [0 for i in range(maxv)]
k=0
for i in reversed(vs):
    if not used[i] : rdfs(i,k)
    k += 1

q = int(input())

for i in range(q):
    u,v = map(int , input().split())
    if compo[u] == compo[v] : print("1") 
    else : print("0")




Measured memory_bytes: 18912
#include<stdio.h>
#include<string.h>

int main(void){
    char str[11];
    scanf("%s",str);
    if(strlen(str)%2){
        puts("No");
        return 0;
    }
    for(int i = 0;i < strlen(str);i+=2){
        if(str[i] != 'h'){
            puts("No");
            return 0;
        }
        if(str[i+1] != 'i'){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 128
while True:
    n,x = map(int,input().split())
    if n == 0 and x == 0:
        break
    ans = 0
    for i in range(1,n+1):
        for j in range(1,n+1):
            if j <= i:
                continue
            k = x-(i+j)
            if k > j and k <= n:
                ans += 1
    print(ans)


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

int main() {
    int n;
    cin >> n;
    auto w = vector<int>(n);
    auto sum = 0;
    for (auto &w_i : w) {
        cin >> w_i;
        sum += w_i;
    }

    auto s1 = 0;
    auto s2 = sum - s1;
    auto diff = abs(s1 - s2);

    for (int i = 0; i < w.size(); i++) {
        s1 += w[i];
        s2 = sum - s1;
        diff = min(diff, abs(s1 - s2));
    }

    cout << diff;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        for(int i=0; i<s.length()-1; i++){
            String tmp = s.substring(i,i+2);
            if(tmp.charAt(0)==tmp.charAt(1)){
                System.out.println((i+1)+" "+(i+2));
                return;
            }
        }
        for(int i=0; i<s.length()-2; i++){
            String tmp = s.substring(i,i+3);
            if(tmp.charAt(0)==tmp.charAt(2)){
                System.out.println((i+1)+" "+(i+3));
                return;
            }
        }
        System.out.println(-1+" "+-1);
    }
}

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

using namespace std;

using ll = long long;

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

    int a, b;
    cin >> a >> b;
    if (a == 1) a += 13;
    if (b == 1) b += 13;

    if (a == b) cout << "Draw\n";
    else if (a > b) cout << "Alice\n";
    else cout << "Bob\n";

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Cryptography.X509Certificates;

namespace hello_world
{class Program
	{
		static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(" ");
			int n = int.Parse(input[0]);
			 int m=int.Parse(input[1]);
			int sum = 0;
			string[] In = Console.ReadLine().Split(" ");
			

			for (int i = 0; i < m; i++)
			{ 

				sum += int.Parse(In[i]);
			}
			n -= sum;
			if (n < 0)
				Console.WriteLine("-1");
			else
				Console.WriteLine(n);
		}



		
	}
}

	

Measured memory_bytes: 28272
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n, a[100100];
ll ans[2];

ll solve(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int k = 0; k < 2; ++k){
        ll sum = 0;
        for(int i = 0, j = -1 + 2 * k; i < n; ++i, j *= -1){
            sum += a[i];
            if(sum * j > 0) continue;
            if(j == -1){
                ans[k] += sum + 1;
                sum = -1;
            }else{
                ans[k] += 1 - sum;
                sum = 1;
            }
        }
    }
    return min(ans[0], ans[1]);
}

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

    cout << solve() << "\n";
    
    return 0;
}

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

int main(){
  int N;cin >> N;
  vector<int> A(N+1,1);
  for(int i=1;i<=N;i++){
    A[i] = i*A[i-1];
  }
  // A[n] is (N!)
  vector<bool> P(N,true);
  vector<bool> Q(N,true);
  int p=1,q=1;
  for(int i=0;i<N;i++){
    int x,sum=0;cin >> x;
    x --;
    for(int j=0;j<x;j++){
      if(P[j]){
        sum ++;
      }
    }
    P[x] = false;
    p += A[N-i-1]*sum;
  }
  for(int i=0;i<N;i++){
    int x,sum=0;cin >> x;
    x --;
    for(int j=0;j<x;j++){
      if(Q[j]){
        sum ++;
      }
    }
    Q[x] = false;
    q += A[N-i-1]*sum;
  }
  cout << abs(p-q) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int q = in();
  set<int> s;
  rep(_,q){
    int kind = in();
    if(kind==0){
      int add = in();
      s.emplace(add);
      cout << s.size() << endl;
    }else if(kind==1){
      int x = in();
      cout << s.count(x) << endl;
    }else{
      int x = in();
      s.erase(x);
    }
  }
}



Measured memory_bytes: 12428
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define ll long long

int main() {
	int n, k;
	string s;
	string ans;
	cin >> n >> k >> s;
	string t = s;
	transform(t.begin(), t.end(), t.begin(), ::tolower);
	
	for (int i = 0; i < s.size(); i++) {
		if (i == k - 1) {
			ans += t[i];
		}
		else {
			ans += s[i];
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	ok := true
	for i := 0; i < len(s); i++ {
		if (i%2 == 0 && s[i] == 'L') || (i%2 == 1 && s[i] == 'R') {
			ok = false
			break
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
n = int(input())
b = list(map(int,input().split()))
a = [0] * n
if n==2:
    print(b[0]*2)
else:
    #c = d = 0
    a[0] = b[0]
    for i in range(n-1,-1,-1):
        if i == n-1:
            a[i] = b[i-1]
        elif i == 0:
            pass
            #a[0] = min(b[0],b[1])
        else:
            a[i] = min(b[i-1],b[i])
    print(sum(a))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin >> n;
	if (n >= 400 and n <= 599)cout << 8;
	else if (n >= 600 and n <= 799) cout << 7;
	else if (n >= 800 and n <= 999) cout << 6;
	else if (n >= 800 and n <= 1199) cout << 5;
	else if (n >= 1000 and n <= 1399) cout << 4;
	else if (n >= 1200 and n <= 1599) cout << 3;
	else if (n >= 1600 and n <= 1799) cout << 2;
	else cout << 1;
}

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

int main() {
  int N,M,sum=0;
  cin >> N >> M;
  for(int i=0; i<M;i++){
    int a;
    cin >> a;
    sum += a;
  }
  if(sum >N){
    cout << -1 << endl;
  }
  else{
    cout << N-sum << endl;
  }
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vb vector<bool>
#define vpli vector<pair<long long,int>>
#define deb(x) cout<<x<<endl;
ll MOD = 1e9+7;
void solve()
{
    int n,k;
    cin>>n>>k;
    vi a(n);
    for(int & x :a) cin>>x;
    sort(a.begin(),a.end());
    int sum = 0;
    for(int i=0;i<k;i++)
    {
        sum += a[i];
    }
    cout<<sum<<endl;
}
int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3644