akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define N 3500
ll a[N];
int c[N];
ll b[N][7];

int main () {
	for (int i = 0; i < N; i ++) {
		// c = i%7
		int c = i%7;
		if (i) {
			for (int j = 0; j < 7; j ++) b[i][j] = b[i-1][j];
		}
		if (c == 0) b[i][0] ++;
		else b[i][c] += b[i-1][c-1];
		a[i] = b[i][6];
		//if (a[i] < 0) cout << i << endl;
		//cout << a[i] << endl;
	}
	ll n;
	cin >> n;
	for (int i = N-1; i >= 0; i--) if (a[i]) {
		c[i] = n/a[i];
		n %= a[i];
	}
	for (int i = N-1; i >= 0; i--) {
		cout << string(c[i], 'F');
		cout << "ESTIVAL"[6-i%7];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 30 14:29:37 2019

@author: liang
"""

def showlist(list):
    for slist in list:
        stri = str()
        for s in slist:
            stri += str(s) + " "
        print(stri[:-1])
        
        
n , m , l = map(int,input().split())

alist = list()
blist = [list() for x in range(l)]


for i in range(n):
    alist.append(list(map(int,input().split())))
        
for x in range(m):
    tlist = list(map(int,input().split()))
    for s in range(l):
        blist[s].append(tlist[s])

clist = [list() for x in range(n)]
for j in range(n):
    for s in range(l):
        sum = 0
        for i in range(len(alist[j])):
            sum += alist[j][i] * blist[s][i]
        clist[j].append(sum)

showlist(clist)
        


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

int main() {
string A,B,U;
  int a,b;
  cin >> A >> B;
  cin >> a >> b;
  cin >> U;
  if(U == A){
  	cout << a-1 << " " << b << endl;
  }
  
  if(U == B){
  	cout << a << " " << b-1 << endl;
  }
  
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(S: str):
    if(15-len(S)+S.count('o') >= 8) :
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

int main() {
  string s;
  cin>>s;
  int sum=0;
  for(int i=0;i<s.length();i++){
    sum+=(s.at(i)-'0');
  }
  if(sum%9 == 0){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}



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

int main() {
  long long x;
  cin >> x;
  
  long long res = 0;
  
  long long fh = x / 500;
  long long l = x - 500 * fh;
  long long f = l/5;
  
  res = fh * 1000 + f * 5;

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();

        int count = 0;
        for(int i = Math.min(a,b);i >= 1;i--){
            if(a%i == 0 && b%i==0){
                count++;
                if(count == k){
                    System.out.println(i);
                    return ;
                }
            }
        }
    }
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    REP(i, M) cin >> B[i];
    int A[20][20];
    REP(i, N) REP(j, M) cin >> A[i][j];
    
    int result = 0;
    REP(i, N) {
        int x = C;
        REP(j, M) {
            x += A[i][j] * B[j];
            PRINT(A[i][j]);
            PRINT(B[j]);
        }
        PRINT(x);
        if (x > 0) {
            result ++;
        }
    }
    cout << result << endl;


    return 0;
}



Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	string s;
	scans(s);
	unordered_map<char, int> a;
	printyn((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]));
	
	Please AC;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

int main() {

    double N;
    cin >> N;
    
    if (N <= 111) {
        cout << "111" << endl;
    } else if (N <= 222) {
        cout << "222" << endl;
    } else if (N <= 333) {
        cout << "333" << endl;
    } else if (N <= 444) {
        cout << "444" << endl;
    } else if (N <= 555) {
        cout << "555" << endl;
    } else if (N <= 666) {
        cout << "666" << endl;
    } else if (N <= 777) {
        cout << "777" << endl;
    } else if (N <= 888) {
        cout << "888" << endl;
    } else if (N <= 999) {
        cout << "999" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[5],n,p,q,r,w,h;
int main(){
	cin>>w>>h>>n;a[1]=0;a[2]=w;a[3]=0;a[4]=h;
	for(int i=0;i<n;i++){
		cin>>p>>q>>r;
		if(r==1)a[1]=max(a[1],p);
		if(r==2)a[2]=min(a[2],p);
		if(r==3)a[3]=max(a[3],q);
		if(r==4)a[4]=min(a[4],q);
	}
	if(a[1]>a[2] || a[3]>a[4])cout<<"0"<<endl;
	else{cout<<(a[1]-a[2])*(a[3]-a[4])<<endl;}
	return 0;
}

Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    s = input()
    b = ["A","C","G","T"]

    max =0
    count = 0
    for i in s:
        if i in b:
            count +=1
        else:
            count =0
        if max < count:
            max =count

    print(max)


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int H, W;
int C[30];

string solve(int o, int e)
{
    if (H % 2 == 0)
    {
        if (W % 2 == 0)
        {
            if (o == 0 && e == 0)
                return "Yes";
            return "No";
        }
        if (H / 2 >= e && o == 0)
            return "Yes";
        return "No";
    }

    if (W % 2 == 0)
    {
        if (W / 2 >= e && o == 0)
            return "Yes";
        return "No";
    }

    if (o != 1)
        return "No";
    if (H / 2 + W / 2 >= e)
        return "Yes";
    return "No";
}

int main()
{
    cin >> H >> W;
    REP(i, H)
    {
        string s;
        cin >> s;
        REP(j, W)
        {
            C[s[j] - 'a']++;
        }
    }
    int o = 0, e = 0;
    REP(i, 26)
    {
        int n = C[i] % 4;
        if (n == 1)
            o++;
        if (n == 2)
            e++;
        if (n == 3)
        {
            o++;
            e++;
        }
    }
    cout << solve(o, e) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//

int main(){
    LLI n,a,b; cin>>n>>a>>b;
    LLI ans=0;
    if(n==1&&a==b) ans=1;
    if(n>1&&a<=b) ans=(n-2)*(b-a)+1;
    co(ans);
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


r = I()
print(int(r**2))

Measured memory_bytes: 38384
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}	
int N;
ll K, A[200010], F[200010];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin >> N >> K;
	for (int i = 0; i < N; ++i)
		cin >> A[i];
	for (int i = 0; i < N; ++i)
		cin >> F[i];
	sort(A, A + N);
	sort(F, F + N);
	reverse(F, F + N);
	ll l = 0, r = A[N - 1] * F[0], ans;
	while (l <= r){
		ll m = l + r >> 1;
		ll cnt = 0;
		for (int i = 0; i < N; ++i){
			if (A[i] * F[i] > m){
				cnt += A[i] - (m / F[i]);
			}
		}
		if (cnt > K) l = m + 1;
		else { ans = m; r = m - 1; }
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define bug(x) cerr << (#x) << " = " << (x) << endl;
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define X first
#define Y second

using namespace std;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<double, double> dd;
typedef pair<float, float> ff;
const int Nmax = 100001;
int n, k, arr[Nmax], f[Nmax];

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	scanf("%d %d", &n, &k);
	REP1(i, n) scanf("%d", &arr[i]);
	FOR(i, 2, n) {
		f[i] = f[i - 1] + abs(arr[i] - arr[i - 1]);
		FORB(j, i - 2, max(1, i - k)) f[i] = min(f[i], f[j] + abs(arr[i] - arr[j]));
	}
	cout << f[n];
	return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
# stdin.readlines?
x = [[0, 0] for i in range(m)]
for i in range(m):
    x[i][0], x[i][1] = map(int, input().split())
x = sorted(x, key=lambda y: y[0])
ans = 1
mx = max([x[i][0] for i in range(m)])
while len(x) > 0:
    for i in range(len(x)-1, -1, -1):
        if mx < x[i][1]:
            x.pop(i)
            break
        else:
            mx = x[i][0]
            ans += 1
            break
print(ans)


Measured memory_bytes: 23440
#include<bits/stdc++.h>
#define taskname "VirtualACM"
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif // CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    int a, b;   cin >> a >> b;
    cout << max(max(a + b, a - b), a * b);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int ans = 0;
  for (int i=1; i<=n; i+=2) {
    int count = 0;
    for (int j=1; j<=(i/2); ++j) {
      if (i%j==0) count++;
    }
    if (count==7) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	std::string str;
	bool okada;
	int a, b, k, x;
	int num[100];
	std::cin >> a >> b >> k;
	if (a > k) {
		cout << "NO" << endl;
	}
	else if (a + b >= k) {
	  cout << "YES" << endl;
	}
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
#define ld long double
const int mod=1e9 + 7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};
 
 
 
 
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

int a,b;
cin>>a>>b;
  cout<<(a*b)/__gcd(a,b);
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'o') count++;
        }

        System.out.println(700 + 100 * count);
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <functional>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <algorithm>

#define range(i, l, r) for (int i = (l); i <= (r); i++)

using i64 = int64_t;

using namespace std;

const int N = 500;

const i64 modp = 998244353;

int n, m, a[N][N];

void swap_row(int x, int y) {
	static int t[N];
	memcpy(t, a[x], sizeof(int) * m);
	memcpy(a[x], a[y], sizeof(int) * m);
	memcpy(a[y], t, sizeof(int) * m);
}

void xor_row(int x, int y) {
	range(i, 0, m - 1) a[x][i] ^= a[y][i];
}

// return rank
int gaussian(int x, int y) {
	if (x >= n) return n;
	if (y >= m) {
		return x;
	}
	int p = n;
	range(i, x, n - 1) if (a[i][y] == 1) { p = i; break; }
	if (p >= n) {
		return gaussian(x, y + 1);
	} else {
		if (x != p) swap_row(x, p);
		range(i, x + 1, n - 1) {
			if (a[i][y] == 0) continue;
			xor_row(i, x);
		}
		return gaussian(x + 1, y + 1);
	}
}

i64 qpow(i64 a, i64 b) {
	if (b == 0) return 1;
	i64 t = qpow(a, b >> 1ll);
	t = t * t % modp;
	if (b & 1) t = t * a % modp;
	return t;
}

int main() {
	cin >> n >> m;
	range(i, 0, n - 1) range(j, 0, m - 1) scanf("%d", &a[i][j]);
	int r = gaussian(0, 0);
	i64 ans = qpow(2, m - 1) * ((qpow(2, n) - qpow(2, n - r)) % modp) % modp;
	ans = (ans + modp) % modp;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

using namespace std;

const ll N = 1e5 + 5;

int n, m;
vector < int > g[N];

bool F[N];
int dp[N];
int a[N], b[N], nn;
int ans;

void dfs (int k){
    F[k] = 1;
    for (int u: g[k])
        if (F[u] == 0)
        	dfs (u);
    a[--nn] = k;
    b[k] = nn;
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    while (m--){
        int u, v;
        cin>>u>>v;
        g[u].pb (v);
    }
    nn = n + 1;
    for (int i = 1; i <= n; i++)
        if (F[i] == 0)
            dfs (i);
    for (int i = 1; i <= n; i++){
        int u = a[i];
        ans = max (ans, dp[i]);
        for (int v: g[u])
            dp[b[v]] = max (dp[b[v]], dp[i] + 1);
    }
    cout<<ans<<endl;
    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

void solve()
{
    int N;
    cin >> N;
    int M;
    cin >> M;
    vector<int> A(M);
    LL sum = 0;
    REP0 (i, M)
    {
        cin >> A[i];
        sum += A[i];
    }

    std::cout << (N < sum ? -1 : N - sum) << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


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

queue < int > que[200001];
unordered_map< int, bool > v[100000];
bool visited[100000];
int N, M;
unordered_map< int, vector< int > > g[100001];
vector< pair< int, int > > graph[100000];
 
void dfs(queue< int >& q, int idx, const int cc)
{
  if(v[idx][cc]++) return;
  if(!visited[idx]++) q.push(idx);
  for(auto to : g[idx][cc]) dfs(q, to, cc);
}
 
int main()
{
  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    int p, q, c;
    cin >> p >> q >> c;
    --p, --q;
    g[p][c].push_back(q);
    g[q][c].push_back(p);
    graph[p].push_back({q, c});
    graph[q].push_back({p, c});
  }
 
  que[0].push(0);
  visited[0] = true;
  for(int i = 0; !que[i].empty(); i++) {
    while(!que[i].empty()) {
      int p = que[i].front();
      if(p == N - 1) {
        cout << i << endl;
        return (0);
      }
      for(auto to : graph[p]) dfs(que[i + 1], to.first, to.second);
      que[i].pop();
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 207104
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n;
  cin >> n;
  vector<ll> l(n);
  ll mmax = -1,sum = 0;
  rep(i,n) {
    ll lll;
    cin >> lll;
    mmax = max(mmax, lll);
    sum += lll;
  }

  sum -= mmax;
  if (mmax < sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int K, N; cin >> N >> K;
    double D[N]; rep(i, N) cin >> D[i];
    double sum[1001] = {}; for(int i = 1; i <= 1000; i++) sum[i] = sum[i-1] + i;
    double mu[N]; rep(i, N) mu[i] = sum[(int)D[i]]/D[i];
    double ans = 0.0;
    rep(i, K) ans += mu[i];
    double temp = ans;
    for(int i = K; i < N; i++){
        temp += mu[i]-mu[i-K];
        ans = max(ans, temp);
    }
    printf("%.10f\n",ans);
    return 0;
}

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

ll INF = 1LL << 60;
int maxi = 0;

void
dfs(int node, int color, vector<map<int, int>> &tree, vector<bool> &seen, vector<int> &ans)
{
  seen[node] = true;
  int inc = 1;
  for(auto child: tree[node]){
    if(seen[child.first]) continue;
    int child_color = (color + inc++) % maxi;
    int id = child.second;
    ans[id] = child_color;
    dfs(child.first, child_color, tree, seen, ans);
  }
}

int 
main() {

  int N; cin >> N;
  vector<bool> seen(N + 1, false);
  vector<int> ans(N + 1, 0);
  vector<map<int, int>> tree(N + 1);
  rep(i, 0, N - 1){
    int a, b; cin >> a >> b;
    tree[a][b] = i + 1;
    tree[b][a] = i + 1;
  }
  tree[0][1] = 0;
  tree[1][0] = 0;

  rep(i, 0, N){
    if(maxi < (int)tree[i].size()){
      if(i == 1) maxi = tree[i].size(), --maxi;
      else maxi = tree[i].size();
    } 
  }
  cout << maxi << endl;

  dfs(0, -2, tree, seen, ans);

  rep(i, 1, N){
    cout << ans[i] + 1 << endl;
  }

}

Measured memory_bytes: 17608
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

class iunionfind {
   public:
    // 連続するuintにのみ使える。vectorであるため定数時間がとれる。
    // 基本的にこれだけあればよい。任意の構造体を扱うときは、IDと構造体のマッピングをとるvectorを別途用意する。
    // libs-test.cppの iuf_map あたりを検索。
    vector<ull> partition;
    vector<ull> rank;

    iunionfind(ull n) {
        partition.resize(n);
        rank.resize(n);
        for (ull x = 0; x < n; x++) {
            partition[x] = x;
            rank[x] = 0;
        }
    }
    ull find(ull x) {
        if (partition[x] == x) {
            return x;
        } else {
            partition[x] = find(partition[x]);
            return partition[x];
        }
    }
    void unite(ull x, ull y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return;
        }
        if (rank[x] < rank[y]) {
            partition[x] = y;
        } else {
            partition[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
    }
    bool same(ull x, ull y) {
        return find(x) == find(y);
    }
};

int main() {
    ll N, M;
    cin >> N >> M;

    auto uf = iunionfind(N);
    for (ll i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
    }
    set<ll> clusters;
    for (ll i = 0; i < N; i++) {
        ll cluster_id = uf.find(i);
        clusters.insert(cluster_id);
    }
    print(clusters.size() - 1);
}


Measured memory_bytes: 8380
#include <algorithm>
#include<iostream>
#include <string>
using namespace std;
 
int main() {
  string S;
  cin>>S;
  long Q;
  cin>>Q;
  if(Q==0){
      cout<<S;
      exit(0);
  }
  int judge;
  int F;
  string C;
   bool reverse_flag = false;
   string flont_string;
   string back_string;
   for(int i=0;i<Q;i++){
      cin>>judge;
      if(judge==1){
          reverse_flag = !reverse_flag;
//          reverse(S.begin(),S.end());
      }else{
        cin>>F;
        cin>>C;
        if(F==1){
            if(!reverse_flag){
            //S=C+S;
                flont_string =C+flont_string;
            }else{
                back_string=back_string+C;
            }
        }else{
            if(!reverse_flag){
               back_string=back_string+C;
            }else{
               flont_string=C+flont_string;
            }
        }
      }
  } 
  if(reverse_flag){
      reverse(S.begin(),S.end());
      reverse(flont_string.begin(),flont_string.end());
      reverse(back_string.begin(),back_string.end());
 //     cout<<"flont:"<<flont_string;
 //     cout<<"back:"<<back_string;
      cout<<back_string+S+flont_string;
  }else{
 //           cout<<"flont:"<<flont_string;
 //     cout<<"back:"<<back_string;
  cout<<flont_string+S+back_string;
  }
  return 0;
}

Measured memory_bytes: 1464
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

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(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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 SQ(a) ((a)*(a))
#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,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
	string str;
	cin >> str;
	if (str == "A") cout << "T" << endl;
	if (str == "T") cout << "A" << endl;
	if (str == "C") cout << "G" << endl;
	if (str == "G") cout << "C" << endl;
	return 0;
}

Measured memory_bytes: 256
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    a = int(input())

    return a + a ** 2 + a ** 3


def main():
    print(solve())


if __name__ == "__main__":
    main()


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

string swith;
string snum[] = {  "0111111",  "0000110",  "1011011","1001111",
		   "1100110",  "1101101",  "1111101",  "0100111",
		   "1111111",  "1101111",  "1000110"};

void kirikae(int a){
  for(int i = 0 ; i < 7 ; i++){
    if(snum[a][i] != swith[i])cout << "1";
    else cout << "0";
  }
  cout << endl;
  swith = snum[a];
}

int main(){
  int n;

  while( cin >> n ){

    if(n == -1)break;
    swith = "0000000";
    for(int i = 0 ; i < n ; i++){
      int num;
      cin >> num;
      if(num == -1)num = 10;
      kirikae(num);
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;

ll dp[310][310];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N,K;
    cin>>N>>K;
    ll H[N+1];
    for(int i=1;i<=N;i++) cin>>H[i];
    H[0]=0;
    for(int i=0;i<=305;i++) for(int j=0;j<=305;j++) dp[i][j]=INF;
    dp[0][0]=0;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=305;j++){
            for(int k=0;k<i;k++){
                chmin(dp[i][j],dp[k][j-1]+max(0LL,H[i]-H[k]));
            }
        }
    }
    ll ans=INF;
    for(int i=N-K;i<=N;i++) chmin(ans,dp[i][N-K]);
    out(ans);
}

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

int main(){
  	int n , w;
    cin>>n>>w;
    int weight , value ;
    
    long long int dp[w+1] = {0};
    
    // dp[i] = max val at capacity i . dp[i] =        
    for(int i = 0 ;  i < n ; i++) {
        cin>>weight>>value;
        for(int weightnow = w - weight ; weightnow >= 0 ; weightnow--)
        {
            dp[weightnow + weight] = max ( dp[weightnow] + value , dp[weightnow + weight] );
        }
    }
    
    
    long long int ans = 0 ; 
    
    for(int i = 0; i <= w ; i++ )
        ans = max ( ans , dp[i] );
    
    
    cout<<ans<<endl;
 
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#define fir first
#define sec second
using namespace std;
typedef long long ll;
const int maxn = 3e3+7;
const ll mod = 998244353;


int n,s;
int a[maxn];
ll dp[maxn][maxn];


int main() {
    scanf("%d%d",&n,&s);
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
    }
    ll ans = 0;
    for(int i=1;i<=n;i++) {
        for(int j=0;j<=s;j++) {
            if(j<a[i]) dp[i][j] = dp[i-1][j]%mod;
            else if(j == a[i]) dp[i][j] = (dp[i-1][j] + i)%mod;
            else dp[i][j] = (dp[i-1][j-a[i]] + dp[i-1][j])%mod;
        }
        ans += dp[i][s];
        ans %= mod;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 70784
n = int(input())
arr = list(map(int, input().split()))

MOD = 10**9 + 7

dp = [0] * (n + 1)
dp[0] = 3
ans = 1
for x in arr:
    ans *= dp[x]
    dp[x] -= 1
    dp[x + 1] += 1
    ans %= MOD

print(ans)

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

using namespace std;

#define ll long long int

int main(){
		ll ans1,ans2;
  		vector<ll>ans;
  		long long int a,b,c,d;
  		cin>>a >>b >>c >>d;
  
  		ans.push_back(a*c);
  		ans.push_back(b*d);
  ans.push_back(a*d);
  ans.push_back(b*c);
  
  sort(ans.begin(),ans.end());
  
  	ll an=ans.back();
  	cout<<an<<endl;
  	
  		
  
  		
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }

  template< typename C >
  int find_subtree(int a, const C &check, Monoid &M, bool type) {
    while(a < sz) {
      Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
      if(check(nxt)) a = 2 * a + type;
      else M = nxt, a = 2 * a + 1 - type;
    }
    return a - sz;
  }


  template< typename C >
  int find_first(int a, const C &check) {
    Monoid L = M1;
    if(a <= 0) {
      if(check(f(L, seg[1]))) return find_subtree(1, check, L, false);
      return -1;
    }
    int b = sz;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) {
        Monoid nxt = f(L, seg[a]);
        if(check(nxt)) return find_subtree(a, check, L, false);
        L = nxt;
        ++a;
      }
    }
    return -1;
  }

  template< typename C >
  int find_last(int b, const C &check) {
    Monoid R = M1;
    if(b >= sz) {
      if(check(f(seg[1], R))) return find_subtree(1, check, R, true);
      return -1;
    }
    int a = sz;
    for(b += sz; a < b; a >>= 1, b >>= 1) {
      if(b & 1) {
        Monoid nxt = f(seg[--b], R);
        if(check(nxt)) return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  SegmentTree<int> seg(n, [](int a, int b) { return a|b; }, 0);
  rep(i, n) seg.update(i, 1<<int(s[i]-'a'));
  int q; cin >> q;
  rep(_, q) {
    int t;
    cin >> t;
    if(t == 1) {
      int i;
      char c;
      cin >> i >> c;
      seg.update(i-1, 1<<int(c-'a'));
    } else {
      int l, r;
      cin >> l >> r;
      cout << __builtin_popcount(seg.query(l-1, r)) << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 7956
#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <list>
#include <random>
#include <functional>


#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

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


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



int main(void){
    int n; scanf("%d", &n);
    for(int x = 0; x <= n; ++x){
        int d = x * 1.08;
        if(d == n){
            printf("%d\n", x);
            return 0;
        }
    }
    puts(":(");

    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll d[100];

int main() {
  std::cin >> N;

  rep( i, N )
    std::cin >> d[i];

  ll ans = 0;

  rep( i, N ) rep( j, i )
    ans += d[i]*d[j];

  std::cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) <= (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;          using vi  = vector<int>;
using unit= unsigned;           using vl  = vector<ll>;
using ull = unsigned long long; using vvi = vector<vi>;
using P   = pair<int,int>;      using vvl = vector<vl>;
                                using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>string join(const v(T)&v){ stringstream s; rep(i,0,sz(v))s<<' '<<v[i]; return s.str().substr(1); }
template<class T>istream &operator>>(istream&i, v(T)&v){ fore(x,v){ i >> v; } return i; }
template<class T>ostream &operator<<(ostream&o, const v(T)&v){ o<<"["; fore(x,v)o<<x<<","; o<<"]"; return o; }
template<class T>ostream &operator<<(ostream&o, const deque<T>&v){ o<<"deq["; fore(x,v)o<<x<<","; o<<"]"; return o; }
template<class T>ostream &operator<<(ostream&o, const set<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T>ostream &operator<<(ostream&o, const unordered_set<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T>ostream &operator<<(ostream&o, const multiset<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T>ostream &operator<<(ostream&o, const unordered_multiset<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T1,class T2>ostream &operator<<(ostream &o, const pair<T1,T2>&p){ o<<"("<<p.fi<<","<<p.se<<")"; return o; }
template<class TK,class TV>ostream &operator<<(ostream &o, const map<TK,TV>&m){ o<<"{"; fore(x,m)o<<x.fi<<"=>"<<x.se<<","; o<<"}"; return o; }
template<class TK,class TV>ostream &operator<<(ostream &o, const unordered_map<TK,TV>&m){ o<<"{"; fore(x,m)o<<x.fi<<"=>"<<x.se<<","; o<<"}"; return o; }
template<class T>void YES(T c){ if(c) cout<<"YES"<<endl; else cout<<"NO"<<endl; }
template<class T>void Yes(T c){ if(c) cout<<"Yes"<< endl; else cout<<"No"<<endl; }
template<class T>void POSS(T c){ if(c) cout<<"POSSIBLE"<<endl; else cout<<"IMPOSSIBLE"<<endl; }
template<class T>void Poss(T c){ if(c) cout<<"Possible"<<endl; else cout<<"Impossible"<<endl; }
template<class T>void chmax(T &a, const T &b){ if(a<b) a=b; }
template<class T>void chmin(T &a, const T &b){ if(b<a) a=b; }
template<class T>T gcd(T a, T b){ return (b==0) ? a : gcd(b,a%b); }
template<class T>T lcm(T a, T b){ return a * (b / gcd(a,b)); }
const double  EPS = 1e-10;
const double  PI  = acos(-1.0);
const int     INF = INT_MAX / 2;
const ll      INFL= 1LL << 60;
const int dx[] = { -1, 0, 1, 0 , -1,-1, 1, 1 };
const int dy[] = {  0, 1, 0,-1 , -1, 1,-1, 1 };

void _main() {
  int A, B;
  cin >> A >> B;

  int ans = max({A+B,A-B,A*B});
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N=1005,mo=1e9+7;
int n,m,a[N],b[N],i,j,k,ans=1,p,q;
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)scanf("%d",a+i);std::sort(a+1,a+n+1);
	for(i=1;i<n;++i)if(a[i]==a[i+1])return puts("0"),0;
	for(i=1;i<=m;++i)scanf("%d",b+i);std::sort(b+1,b+m+1);
	for(i=1;i<m;++i)if(b[i]==b[i+1])return puts("0"),0;
	for(i=n+1,j=m+1,k=n*m;k;--k){
		for(;a[i-1]>=k;--i);for(;b[j-1]>=k;--j);
		if(a[i]==k && b[j]==k)continue;
		if(a[i]==k)ans=1ll*ans*(m-j+1)%mo;else if(b[j]==k)ans=1ll*ans*(n-i+1)%mo;
			else p=n*m-k+1,q=(n-i+1)*(m-j+1),ans=p<=q?1ll*ans*(q-p+1)%mo:0;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fast() ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
     Fast();
     ll n,t,x,y,i,j,k,mini=LONG_LONG_MAX,maxi=LONG_LONG_MIN,flag =0 ,sum=0,mul=1;
     vector<ll>vi;
     string s,s1="";
    cin>>n;
    for(i=1 ;;i*=2)
    {
        n/=2;
        sum+=i;
        if(n==0)
            break;
    }
    cout<<sum<<endl;

}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct edge {
  int u, v, w, id;
  edge(){}
  edge(int u, int v, int w, int id):u(u), v(v), w(w), id(id){}
  bool operator < (const edge& e) {
    return w != e.w ? w < e.w : id < e.id;
  }
};

struct UnionFind {
  vint data;
  UnionFind(int n):data(n, -1){}
  int find(int x) {
    if(data[x] < 0) return x;
    return data[x] = find(data[x]);
  }
  int size(int x) {
    return -data[find(x)];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, m, k;
  while(cin >> n >> m >> k, n || m || k) {
    vint u(m), v(m), w(m);
    vector<char> id(m);
    rep(i, m) {
      cin >> u[i] >> v[i] >> w[i] >> id[i];
      --u[i], --v[i];
    }
    auto check = [&](int mb) -> pair<int, int> {
      vector<edge> vec;
      rep(i, m) {
	if(id[i] == 'A') vec.emplace_back(u[i], v[i], w[i]+mb, 1);
	else vec.emplace_back(u[i], v[i], w[i], 0);
      }
      sort(all(vec));
      UnionFind uf(n);
      int cnt = 0;
      int sum = 0;
      for(edge e : vec) {
	if(!uf.same(e.u, e.v)) {
	  uf.unite(e.u, e.v);
	  cnt += e.id;
	  sum += e.w;// - e.id*mb;
	}
      }
      if(uf.size(0) < n) return make_pair(inf, -inf);
      return make_pair(sum, cnt);
    };
    Pi p = check(-1000), q = check(1000);
    if(p.second < k || q.second > k) {
      cout << -1 << endl;
      continue;
    }
    int lb = -1000, ub = 1000;
    while(lb+1 < ub) {
      int mb = (lb+ub)/2;
      if(check(mb).second <= k) ub = mb;
      else lb = mb;
    }
    auto ans = check(ub);
    //cout<<ub<<endl;
    //cout<<ans.first<<" "<<ans.second << endl;
    //if(ans.second == k) cout << ans.first << endl;
    //else cout << -1 << endl;
    cout << ans.first-k*ub << endl;
  }

  return 0;
}



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

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

 int main() {
   int N, ans;
   cin >> N;
   vector<int> A(N);
   map<int, int> a;

   rep(i, N) {
     cin >> A.at(i);
     a[A.at(i)]++;
   }

   for (auto p: a) {
     if (p.second == p.first) continue;
     else if (p.second < p.first) ans += p.second;
     else if (p.second > p.first) ans += p.second - p.first;
   }

   cout << ans << endl;
 }


Measured memory_bytes: 5120
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int num;
 	cin >> num;
 	long sum=0;
 	while(num--){
 		int x;
 		cin >> x;
 		sum+=--x;
 	}
 	cout << sum << "\n";
 }

Measured memory_bytes: 384