akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
	ios::sync_with_stdio(0),cin.tie(0);
	int array[5],result=0,m=124,temp=0;
	for(int i=0;i<5;i++)
	{
		cin>>array[i];
		if(array[i]%10<m&&array[i]%10!=0)
		{
			m=min(array[i]%10,m);
			temp=i;
		}
	}
	for(int i=0;i<5;i++)
	{
		if(i==temp)
			continue;
		if(array[i]%10!=0)
			result+=(array[i]/10+1)*10;
		else
			result+=array[i];
	}
	result+=array[temp];
	cout<<result<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,x,a[1005],cnt;
int main(){
	cin>>n>>x;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=x;i++) cnt+=a[i];
	cout<<cnt;
	return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    double d, t, s;
    cin >> d >> t >> s;
    cout << ( (d / s) <= t ? "Yes" : "No");

}








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

int main() {
 string S;
 while(true){
  cin >> S;
  if(cin.eof()) break;
  UL JOI,IOI; JOI=IOI=0;
  rep(i,S.size()-2){
   if(S.substr(i,3) == "JOI") JOI++;
   if(S.substr(i,3) == "IOI") IOI++;
  }
  cout<<JOI<<endl<<IOI<<endl;
 }
 return 0;
}



Measured memory_bytes: 3012
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=4000010,Mo=1000000007;
int f[2010][2010],fac[N],inv[N],rev[N];
inline int C(int n,int m) {
    return 1LL*fac[n]*rev[m]%Mo*rev[n-m]%Mo;
}
int main() {
    int n,k;
    cin>>n>>k;
    if(k==1) {puts("1");return 0;}
    f[0][0]=1;
    fac[0]=fac[1]=1,inv[1]=1,rev[0]=rev[1]=1;
    for(int i=2;i<=n*k;i++) {
	fac[i]=1LL*fac[i-1]*i%Mo;
	inv[i]=1LL*(Mo-Mo/i)*inv[Mo%i]%Mo;
	rev[i]=1LL*rev[i-1]*inv[i]%Mo;
    }
    for(int i=1;i<=n;i++)
	for(int j=i;j>=0;j--) {
	    f[i][j]=f[i][j+1];
	    if(j) (f[i][j]+=1LL*f[i-1][j-1]*C(i*k-j-1,k-2)%Mo)%=Mo;
	}
    cout<<1LL*f[n][0]*fac[n]%Mo;
    return 0;
}

Measured memory_bytes: 62848
import java.lang.Math.abs
import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()
val M = sc.nextInt()

fun main(args: Array<String>) {
    val a = Array(N) { 0 }
    val b = Array(N) { 0 }
    val c = Array(M) { 0 }
    val d = Array(M) { 0 }

    for (i in 0 until N) {
        a[i] = sc.nextInt()
        b[i] = sc.nextInt()
    }

    for (j in 0 until M) {
        c[j] = sc.nextInt()
        d[j] = sc.nextInt()
    }

    for (i in 0 until N) {
        var key = 0
        var valu = Int.MAX_VALUE
        for (j in 0 until M) {
            val tmp = abs(a[i] - c[j]) + abs(b[i] - d[j])
            if (tmp < valu) {
                valu = tmp
                key = j + 1
            }
        }
        println(key)
    }
}


Measured memory_bytes: 29472
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();
		
		if (x < -100 || y < -100 || x > 100 || y > 100 || W <= 0 || H <= 0 || r > 100) {
			System.out.println("Error!");
		}
		
		if ((x + r) > W || (x - r) < 0 || (y + r) > H || (y - r) < 0) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}

}

Measured memory_bytes: 17356
import sys
import bisect
n = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for j in range(n)]
dp = A[:1]
for a_i in A[1:]:
    if dp[-1] < a_i:
        dp.append(a_i)
    else:
        dp[bisect.bisect_left(dp, a_i)] = a_i
print(len(dp))

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

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int r = x%y;
    if (r == 0) {
        return y;
    }
    return gcd(y, r);
}

ll mypow(int x, int n) {
    if (n == 0) return 1;
    return x*mypow(x, n-1);
}

int main(){
    int X;
    cin >> X;
    for (int i=-1000; i<=1000; i++) {
        for (int j=-1000; j<=1000; j++) {
            if (mypow(i, 5) - mypow(j, 5) == X) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

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

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9+7
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
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;
}
int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    //vector<vector<int>> data(3, vector<int>(4));
    //初期値0
    //vector<int> data(i, 0);
    if (A == 0) {
        cout << 0 << endl;
        return 0;
    }
    if (N%(A+B) == 0) {
            ll res = (N/(A+B))*A;
            cout << res << endl; 
    } else {
        ll a = N%(A+B);
        if (A>=a) {
            ll res = (N/(A+B))*A + a;
            cout << res << endl; 
        } else {
            ll res = (N/(A+B))*A + A;
            cout << res << endl; 
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;
const int N = 6e5 + 500;
const int LN = 21;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;

long long n, m, u, v, k, t, q, x, d, b, c, p;

long long arr[N];

long long solve(int from, int to, long long cnta, long long cntb) {
   if (to - from == 1) return 0;
   
   long long best = INF;
   
   for (int i = from + 1; i < to; ++i) {
      best = min(best, arr[i] * (cnta + cntb) + solve(from, i, cnta, cnta + cntb) + solve(i, to, cntb + cnta, cntb));
   }
                 
   return best;
}

int main() {
   ios::sync_with_stdio(false);cin.tie(0);
   cin >> n;
   
   for (int i = 1; i <= n; ++i) {
      cin >> arr[i];
   }
   
   cout << arr[1] + arr[n] + solve(1, n, 1, 1) << endl;
   return 0;
}







Measured memory_bytes: 384
import sys

mod = 1000000007

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))

def nCr(n,r):

    if r * 2 > n:
        r = n-r

    now = 1
    for i in range(r):
        now *= n - i
        now *= gdic[r-i]
        now %= mod
    return now


mod = 1000000007
X,Y = map(int,input().split())

a = 0
b = 0

while X > 0 and Y > 0:

    if X > Y:
        a += 1
        X -= 2
        Y -= 1

    else:
        b += 1
        X -= 1
        Y -= 2

"""
factorial = [1]
for n in range(1, a+b):
    factorial.append(factorial[n-1]*n%mod)

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

inverseFactorial = [0] * (a+b)
inverseFactorial[a+b-1] = power(factorial[a+b-1], mod-2)
for n in range(a+b-2, -1, -1):
    inverseFactorial[n] = inverseFactorial[n+1] * (n+1) % mod

def combi(n, m):
    return factorial[n] * inverseFactorial[m] * inverseFactorial[n-m] % mod
"""

sys.setrecursionlimit(500000)

gdic = [0]
gyaku = 1
for i in range(min(a,b)):

    i += 2
    gdic.append(gyaku)
    gyaku = mod -gdic[mod % i] * (mod // i) % mod



if X != 0 or Y != 0:
    print (0)

else:
    print (nCr(a+b,a) % mod)


Measured memory_bytes: 16348
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  scanf("%d", &n);
  int odd = 0;
  int even = 0;
  rep (i, n) {
    int tmp;
    scanf("%d", &tmp);
    if ((tmp&1) == 1) {
      odd += 1;
    }
  }
  if ((odd&1) == 0) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }

  return 0;
}


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

class Program {
    static void Main (string[] args) {
        var inp = Console.ReadLine().Split(' ');
        int A = int.Parse(inp[0]);
        long B = long.Parse(inp[1]);
        long N = long.Parse(inp[2]);

        long ans = -1;
        long tmp = -1;

        ans = (long)(A * N / B) - A * (long)(N / B);

        long index = B - 1;

        while(true) {
            if(B <= 100) break;
            if(index >= N) break;

            tmp = (long)(A * index / B) - index / B;
            if(tmp > ans) {
                ans = tmp;
            }

            index += B;
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 27484
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>
//#include <bits/stdc++.h>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<char> right = { 'p', 'o', 'i', 'u', 'y', 'l', 'k', 'j', 'h', 'm', 'n' };
	
	while (1)
	{
		string str; cin >> str;
		vector<int> move((int)str.size() + 5, 0);
		int cnt = 0;
		if (str[0] == '#') { return 0; }
		rep(i, (int)str.size())
		{
			if (count(all(right), str[i]) > 0){ move[i] = 1;	}
		}
		for (int i = 1; i < (int)str.size(); i++)
		{
			if (move[i - 1] != move[i]){ cnt += 1; }
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 3292
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;


int main(){
    string b;
    cin >> b;

    string ans;
    if(b == "A") ans = "T";
    if(b == "C") ans = "G";
    if(b == "G") ans = "C";
    if(b == "T") ans = "A";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import math
 
N = int(input())
 
def calc_power(num):
    if num > 1:
        m = 5
        power = 2
        while True:
            if num <= m:
                return_num = power
                break
            else:
                m = m * 4 + 1
                power += 2 
    elif num == 1:
        return_num = 0
    elif num == 0:
        print('0')
        exit()
    else:
        m = -2
        power = 1
        while True:
            if num >= m:
                return_num = power
                break
            else:
                m = m * 4 - 2
                power += 2
 
    return return_num
 
num = N
pre_power = calc_power(N) + 1
ans = ''
while num != 0:
    power = calc_power(num)
    num -= (-2) ** power
    if power == pre_power - 1:
        ans += '1'
    else:
        for _ in range(pre_power - 1 - power):
            ans += '0'
        ans += '1'
    if num == 0:
        for _ in range(power):
            ans += '0'
    pre_power = power
 
print(ans)

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,x,t; cin>>n>>x>>t;
  ll ans=(n+x-1)/x*t;
  cout<<ans<<endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		 double   ld;
typedef		vector<ll>      vll;
#define     fi              first
#define     print(v)        for(ll i:v) cout<<i<<ss
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;


const ll N=1e6+9;

vll v[N];
ll vis[N];

int main()
{
//    ios::sync_with_stdio(0);
//    cin.tie(0);
    for(ll i=2; i<N; i++)
    {
        if(!vis[i])
            for(ll j=i; j<N; j+=i)
            {
                vis[j]=1;
                v[j].pb(i);
            }
    }

    ll n;
    cin>>n;
    ll ar[n+10];
    ll g=0;
    for(ll i=0; i<n; i++)
    {
        cin>>ar[i];
        g=gcd(ar[i],g);
    }
    map<ll,ll>mp;
    ll f=1;
    for(ll i=0; i<n; i++)
    {
        ll num=ar[i];
        for(ll j: v[num])
        {
            if(mp[j])
                f=0;
            mp[j]=1;
        }

    }
    if(f)
        cout<<"pairwise coprime"<<nn;
    else if (g==1)
        cout<<"setwise coprime"<<nn;
    else
        cout<<"not coprime"<<nn;







}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






Measured memory_bytes: 94156
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

int main()
{	
	string N;
	cin >> N;

	int K;
	cin >> K;

	//dp0[i][j] := 上からi桁目まで決めて、0でない桁がj個あり、Nより小さいことが確定している
    //dp1[i][j] := 上からi桁目まで決めて、0でない桁がj個あり、Nより小さいことが確定していない
	vector<vector<ll>> dp0(N.size() + 1, vector<ll>(K + 1, 0));
	vector<vector<ll>> dp1(N.size() + 1, vector<ll>(K + 1, 0));
	
	
	dp1[0][0] = 1;

	rep(i, N.size())
	{
		int d = N[i] - '0';

		reple(j, 0, 9)
		{
			if (j == 0)
			{
				//0の場合個数を増やさない
				reple(k, 0, K)
				{
					dp0[i + 1][k] += dp0[i][k];

					if (j < d)
					{
						//N[i]より小さい・・・Nより必ず小さい
						dp0[i + 1][k] += dp1[i][k];
					}
					else if(j == d)
					{
						//N[i]以下・・・Nより小さいかわからない
						dp1[i + 1][k] += dp1[i][k];
					}
				}
			}
			else
			{
				rep(k, K)
				{
					dp0[i + 1][k + 1] += dp0[i][k];

					if (j < d)
					{
						//N[i]より小さい・・・Nより必ず小さい
						dp0[i + 1][k + 1] += dp1[i][k];
					}
					else if (j == d)
					{
						//N[i]以下・・・Nより小さいかわからない
						dp1[i + 1][k + 1] += dp1[i][k];
					}
				}
			}
		}
	}

	cout << dp0[N.size()][K] + dp1[N.size()][K] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  char tmp[1000];
  int h,w;
  char *board[40];

  while(scanf("%d%d",&w,&h),w+h){
    int i,j;
    memset(tmp,'#',sizeof(tmp));
    for(i=1;i<=h;i++){
      char buff[40];
      scanf("%s",buff);
      board[i]=&tmp[(w+2)*i];
      memcpy(board[i]+1,buff,w);
    }
    board[0]=tmp;
    board[h+1]=&tmp[(w+2)*(h+1)];

    int f=1;
    int ans=1;
    while(f){
      f=0;
      for(i=1;i<h+1;i++){
	for(j=1;j<w+1;j++){
	  if(board[i][j]=='@'){
	    int x,y;
	    for(y=-1;y<=1;y++){
	      for(x=-1;x<=1;x++){
		if(x*y!=0) continue;
		if(board[i+y][j+x]=='.'){
		  board[i+y][j+x]='@';
		  f=1;
		  ans++;
		}
	      }
	    }
	  }
	}
      }
    }

    printf("%d\n",ans);
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n;
  in(n);
  vector<ll> a(n);
  rep(i, n)
    in(a[i]);
  sort(all(a));
  out(a[n / 2] - a[n / 2 - 1]);
  memi;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  vector<ll> va, vb, vc;
  rep(i, 0, n) {
    ll a;
    cin >> a;
    va.pb(a);
  }
  rep(i, 0, n) {
    ll a;
    cin >> a;
    vb.pb(a);
  }
  rep(i, 0, n) {
    ll a;
    cin >> a;
    vc.pb(a);
  }
  sort(all(va));
  sort(all(vb));
  sort(all(vc));
  ll ans = 0;
  ll index1 = 0;
  ll index2 = 0;
  rep(i,0,vb.sz){
    ll m = vb[i];
    while(index1<=n-1){
      if(va[index1]<m)index1++;
      else break;
    }
    while(index2<=n-1){
      if(vc[index2]<=m)index2++;
      else break;
    }
    ans += index1 * (n-index2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3316
s=input()
s=s.replace("BC","1")
s=s.replace("A","0")
s=s.replace("B","2")
s=s.replace("C","2")
l=[]
cnt1=0
ans=0
for ss in reversed(s):
  if ss=="0":
    ans+=cnt1
  elif ss=="1":
    cnt1+=1
  else:
    cnt1=0
print(ans)

Measured memory_bytes: 3500
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    map<string, vector<int> > index;
    for(;;){
        string s;
        int n;
        if(!(cin >> s >> n))
            break;
        index[s].push_back(n);
    }

    map<string, vector<int> >::iterator it;
    for(it=index.begin(); it!=index.end(); ++it){
        cout << it->first << endl;
        sort(it->second.begin(), it->second.end());
        cout << it->second[0];
        for(unsigned i=1; i<it->second.size(); ++i){
            cout << ' ' << it->second[i];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> snuke(n);
  rep(i, k) {
    int d;
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a;
      --a;
      snuke[a]++;
    }
  }
  int ans = 0;
  rep(i, n) {
    if (!snuke[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
D=gets.to_i
C=gets.split.map &:to_i
S=$<.take(D).map{_1.split.map &:to_i}
T=$<.map &:to_i
s=0
L=[0]*26
D.times{|d|
t=T[d]-1
s+=S[d][t]
L[t]=d+1
26.times{|i|
s-=C[i]*(d+1-L[i])
}
p s
}

Measured memory_bytes: 14236
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
constexpr lnt INF = 2e18;
/*-*/

constexpr lnt MOD = 998244353;
struct mint
{
    lnt v;
    mint():v(0){}
    mint(lnt v):v((v+MOD)%MOD){}
    mint operator-()const{ return mint(0) - *this; }
    mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
    mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
    mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
    mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
    mint operator+(const mint& a)const{ return mint(*this) += a; }
    mint operator-(const mint& a)const{ return mint(*this) -= a; }
    mint operator*(const mint& a)const{ return mint(*this) *= a; }
    mint operator/(const mint& a)const{ return mint(*this) /= a; }
    bool operator<(const mint& a)const{ return v < a.v; }
    bool operator==(const mint& a)const{ return v == a.v; }
    mint pow(lnt k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
    mint inv()const{ return pow(MOD-2); }
    static mint comb(lnt n, lnt k) {
        if(n-k<k) k=n-k;
        mint num(1), dom(1);
        for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
        return num/dom;
    }
    static std::vector<mint> construct_comb(int n) {
        std::vector<mint> c(n+1);
        mint a = 1; c[0] = a;
        for(int i=1;i<=n;i++) {
            a = a*mint(n+1-i)/i;
            c[i] = a;
        }
        return c;
    }
    static std::vector<mint> construct_fact(int n) {
        std::vector<mint> f(n+1,1);
        for(int i=2;i<=n;i++) f[i]=f[i-1]*i;
        return f;
    }
};
std::istream& operator>>(std::istream&i,mint&a){ lnt t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


int main() {
	lnt n,s;
	std::cin >> n >> s;
	std::vector<lnt> a(n);
	rep(i,n) std::cin >> a[i];
	std::vector<mint> dp(s+1,0);
	dp[0]=1;
	rep(i,n) {
		for(int j=s;j>=0;j--) {
			if(j-a[i]<0) break;
			dp[j]+=dp[j-a[i]]/mint(2);
		}
	}
	print(dp[s]*mint(2).pow(n));
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    string st;
    cin >> st;
    
    int ans = 0, cnt = 0;
    rep(i, st.size()) {
        if (st[i] == 'A' || st[i] == 'C' || st[i] == 'G' || st[i] == 'T') {
            cnt++;
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }

    std::cout << max(ans, cnt) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int arr[1001];
int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    int sum = 0;
    for(int i=0; i<n; i++) {
        scanf("%d", arr + i);
        sum += arr[i];
    }

    int curSum = 0;
    int res = 1e9;
    for(int i=0; i<n; i++){
        curSum += arr[i];
        sum -= arr[i];
        res = min(abs(sum - curSum), res);
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e15
vector<vector<long long>>dp(100,vector<long long>(1e5+1,-1));
vector<pair<long,long long>>knap;
long long konap(int loc,long long left){
    if(left<0) return -inf;
    if(loc>=knap.size()||left==0){
        return 0;
    }
    if(dp[loc][left]!=-1){
        //cout<<dp[loc][left]<<"x"<<left<<"x";
        return dp[loc][left];
    }
    else{
        dp[loc][left]=max(konap(loc+1,left-knap[loc].first)+knap[loc].second,konap(loc+1,left));
    
        return dp[loc][left];
    }
}
int main(){
  
  long long n,tot;
  cin>>n>>tot;
  //cout<<tot;
  knap.resize(n);
  for(int i=0;i<n;i++){
      cin>>knap[i].first>>knap[i].second;
  }
 long long ans=konap(0,tot);
  cout<<ans;
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    long A, sum = 0;
    rep(i, N){
        cin >> A;
        sum += A;
    }
    cout << (sum % 2 == 0 ?  "YES" : "NO") << endl;
}

Measured memory_bytes: 256
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


MOD = 10**9 + 7
N = 10**6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

s = int(input())

ans = 0
for i in range(1, s // 3 + 1):
    rest = s - 3 * i
    ans += cmb(rest + i - 1, rest, MOD)

print(ans % MOD)

Measured memory_bytes: 127552
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = pi * r * r;
        double length = 2 * pi * r;
        System.out.printf("%f %f", area, length);
        sc.close();
    }
}



Measured memory_bytes: 28372
#include <stdio.h>
#include <stdlib.h>
#define MAX 100005
#define NIL -1

typedef struct _n {
  int deg;
  int right;
  int left;
  int r;
  int parent;
  int sib;
  int depth;
  int height;
} node;

node tree[MAX];
int n;
void calcDepth(int r) {
  if(tree[r].right !=NIL){
    tree[tree[r].right].depth+=1+tree[r].depth;
  calcDepth(tree[r].right);
  }
  if(tree[r].left != -1){
    tree[tree[r].left].depth+=1+tree[r].depth;
  calcDepth(tree[r].left);
  }
}
int calcHeight(int a) {
  int i,h=0,l,r,n;
  if(tree[a].deg == 0) {
    tree[a].height = 0;
    return 0;
  }
  if(tree[a].left!=NIL)l=calcHeight(tree[a].left);
  else l=0;
  if(tree[a].right!=NIL)r=calcHeight(tree[a].right);
  else r=0;
  if(l<r)h=r;
  else h=l;
  tree[a].height=h+1;
  return h+1;
}
int main() {
  int i,j,k,l,r;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    tree[i].parent=NIL;
    tree[i].sib=NIL;
    tree[i].depth=0;
    tree[i].height=0;
    tree[i].deg=0;
  }
  for(k=0;k<n;k++) {
    scanf("%d",&i);
    scanf("%d %d",&tree[i].left,&tree[i].right);
    if(tree[i].left!=NIL){
      tree[tree[i].left].sib=tree[i].right;
    tree[tree[i].left].parent=i;
    tree[i].deg++;
  }
    if(tree[i].right!=NIL){
      tree[tree[i].right].sib=tree[i].left;
   tree[tree[i].right].parent=i;
   tree[i].deg++;
  }
  }
  for(i=0;i<n;i++) {
    if(tree[i].parent==NIL) k=i;
  }
  calcDepth(k);
  calcHeight(k);
  for(i=0;i<n;i++) {
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree[i].parent,tree[i].sib,tree[i].deg,tree[i].depth,tree[i].height);
    if(tree[i].parent==NIL) {
      printf("root\n");
    }
    else if(tree[i].deg==0) {
      printf("leaf\n");
    }
    else{
      printf("internal node\n");
    }
  }
  return 0;
}





Measured memory_bytes: 2108
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


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

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    int x;
    cin>>x;
    if(x>=30)cout<<"Yes";
    else cout<<"No";

    return 0;
}

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

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

  string s;
  cin >> s;
  bool isSame = s[2] == s[3] && s[4] == s[5];
  cout << (isSame ? "Yes" : "No") << endl;
  return 0;
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;


int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        //int n; cin>>n; int arr[n]; for(int i = 0; i<n; i++) cin>>arr[i];
		int a,b; cin>>a>>b;
		cout<<(a * (a- 1) +  b * (b - 1)) / 2;

		
		cout<<endl;
    }
    return 0;

}


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

int main(){
  long long int x, a, b;
  cin >> x;
  for(a = -200; a<=200;a++)
    for(b = -200; b<=200;b++)
      if(a*a*a*a*a - b*b*b*b*b == x){
        cout << a << " " << b;
        return 0;
      }
}

Measured memory_bytes: 3628
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int X = sc.nextInt();
      	int Y = sc.nextInt();
      	int[] num = new int[Y];
      	int dist = 10000;
      	int ans = X;
      	for(int i=0;i<Y;i++){
          num[i] = sc.nextInt();
        }
      	Arrays.sort(num);
      	int pos = 0;
      	for(int i=-101;i<102;i++){
          if( pos < Y && num[pos] == i ){
            pos++;
            continue;
          }
          if( Math.abs( i-X ) < dist ){
            dist = Math.abs( i-X );
            ans = i;
          }
        }
      System.out.println(ans);    	
	}
}

Measured memory_bytes: 27140
#!/usr/bin/env python
#-*- coding:utf-8 -*-
while True:
	n = input()
	if n == 0: break
	a = [ input() for i in xrange(n) ]
	m = -100000
	for i in xrange(n):
		s = 0
		for j in xrange(i, n):
			s += a[j]
			m = max(m, s)
	print m

Measured memory_bytes: 4324
// AOJ ALDS1_1_D Maximum Profit
// 2018.4.27 bal4u

#include <stdio.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int main()
{
	int n, a, min, ans;

	n = in()-2;
	min = in(), a = in();
	ans = a-min;
	if (a < min) min = a;
	while (n--) {
		a = in();
		if (a < min) min = a;
		else if (a-min > ans) ans = a-min;
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 2100
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
tmp = n
for i in a:
    i = i - 1
    ans += b[i]
    if i == tmp + 1: ans += c[tmp]
    tmp = i
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int num, flag=0;
    char s[102], t[102];
    
    scanf("%s%s", s, t);
    num=strlen(s);
    
    for (int j=1; j<=num; j++) {
        flag=0;
        for (int i=num-1; i>=0; i--) {
            s[i+1]=s[i];
        }
        s[0]=s[num];
        
        //printf("%s%s", s, t);
        
        rep(i, num){
            if (s[i]==t[i]) {
                flag++;
            }
        }
        
        if (flag==num) {
            printf("Yes");
            return 0;
        }
    }
    
    printf("No");
    
    return 0;
}


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

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt", "r", stdin)
#define write freopen("out.txt", "w", stdout)
#define mem(x, n) memset(x, n, sizeof(x))
#define all(x) x.begin(), x.end()
#define endl "\n"

int main() {
	faster;

	ll n;
	cin >> n;

	vector<ll> h(n),dp(n+1,0);

	for (auto &x : h)
		cin >> x;
	
	dp[1] = 0;
	dp[2] = abs(h[1]-h[0]);

	for(ll i = 3; i <= n; i++){
		dp[i] = min(dp[i-1] + abs(h[i-1]-h[i-2]),dp[i-2] + abs(h[i-1]-h[i-3]));
	}

	cout << dp[n] << endl;

	return 0;
}

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

int main(void){
  string s;
  int ans,tmp_length;
  cin>>s;
  tmp_length=0;
  ans=0;
  for(int i=0;i<s.size();i++){
  	if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
  	  tmp_length++;
  	  if(tmp_length>ans){
  	  	ans=tmp_length;
  	  }
  	}else{
  	  tmp_length=0;
  	}
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		double d=Math.cos(Math.toRadians(c));
		double e=Math.sin(Math.toRadians(c));
		double S=0,L=0,h=0,t=0;
		
		t=Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2)-(2*a*b*d));
		S=(a*b*e)/2;
		L=a+b+t;
		h=b*e;
		System.out.printf("%.11f\n",S);
		System.out.printf("%.11f\n",L);
		System.out.printf("%.11f\n",h);
		scan.close();
	}
}



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

// c++11でコンパイルしてください

void push(int st[], int& top, int x) { st[++top] = x; }

int pop(int st[], int& top) {
    int return_value = st[top--];

    return return_value;
}

int main() {
    int a, b, top = 0, st[1000];
    string str;

    while (cin >> str) {
        if (str == "+") {
            a = pop(st, top);
            b = pop(st, top);
            push(st, top, b + a);
        } else if (str == "-") {
            a = pop(st, top);
            b = pop(st, top);
            push(st, top, b - a);
        } else if (str == "*") {
            a = pop(st, top);
            b = pop(st, top);
            push(st, top, b * a);
        } else {
            // stoi -> string to int
            push(st, top, stoi(str));
        }

        if (getchar() == '\n') {
            cout << pop(st, top) << endl;
            return 0;
        }
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> h(n + 1);
    h.at(0) = 0;
    rep(i, n) cin >> h.at(i + 1);
    bool flag = true;
    rep(i, n) if(h.at(i) < h.at(i + 1)) h.at(i + 1)--;
    rep(i, n) if(h.at(i) > h.at(i + 1)) flag = false;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(long long int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)
 
int main(){
  long long int N;
  int M; cin >> N >> M;
  vector<int> a(M);
  REP(i, M){ cin >> a[i]; }
  long long int sum = std::accumulate(a.begin(), a.end(), 0);
  int out = N - sum;
  if(out<0){ cout << -1 << endl; }
  else{ cout << out << endl; }
  return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	t.pop_back();
	if (s == t){
		cout << "Yes";
	}
	else cout << "No";
	return 0;

}

Measured memory_bytes: 3588
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
int cin1[3];
int main(){
	int sum=0,t;
	cin>>cin1[0]>>cin1[1]>>cin1[2];
	sort(cin1,cin1+3);
	sum+=cin1[2]-cin1[1];
	cin1[0]+=cin1[2]-cin1[1];
    sum+=(cin1[2]-cin1[0])/2;
    cin1[0]+=(cin1[2]-cin1[0])/2*2;
       if(cin1[2]-cin1[0]==1) sum+=2;
	printf("%d\n",sum);
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
ll mod=pow(10,9)+7;

int main(){
    string K;cin>>K;
    int D,N=K.size();cin>>D;
    mat dp0(2,vec(D)),dp1(2,vec(D));
    //初期化
    for(int j=0;j<D;j++){
        dp0[0][j]=dp1[0][j]=0;
    }
    dp0[0][0]=1;
    //漸化式
    for(int i=1;i<=N;i++){
        for(int j=0;j<D;j++){
            int k=K[i-1]-'0';
            dp0[1][j]=dp0[0][(j-k+10*D)%D];
            ll rev=0;
            for(int l=0;l<10;l++){
                rev=(rev+dp1[0][(j-l+10*D)%D])%mod;
            }
            for(int l=0;l<k;l++){
                rev=(rev+dp0[0][(j-l+10*D)%D])%mod;
            }
            dp1[1][j]=rev;
        }
        dp0[0]=dp0[1];dp1[0]=dp1[1];
    }
    ll ans=(dp0[0][0]+dp1[0][0]-1+mod)%mod;
    printf("%lld\n",ans);
    return 0;
}

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

int main(){
  int h, w;  cin >> h >> w;
  int field[1010][1010] = {0};
  queue<pair<int, int>> que;
  for(int i=0; i<h; i++){
    string s;  cin >> s;
    for(int j=0; j<w; j++)
      if(s[j] == '#')  que.push({i+1, j+1});
      else  field[i+1][j+1] = 1e9;
  }

  int d[] = {1, 0, -1, 0, 1}, ans = 0;
  while(!que.empty()){
    auto now = que.front();  que.pop();
    for(int i=0; i<4; i++)
      if(field[now.first][now.second] + 1 < field[now.first+d[i]][now.second+d[i+1]]){
	field[now.first+d[i]][now.second+d[i+1]] = field[now.first][now.second] + 1;
	ans = max(ans, field[now.first+d[i]][now.second+d[i+1]]);
	que.push({now.first+d[i], now.second+d[i+1]});
      }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15220
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T &a){int t = 0;for(auto itr :a){if(t++)cout << " "; cout << itr;} cout <<endl; }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    //    std::ios_base::sync_with_stdio(false);
    //    cin.tie(NULL);
    int n,q;
    cin >> n  >> q;
    string s;
    cin >> s;
    vector<int>dp(n,0LL);
    rep(i,n){
        if(i==0) continue;
        dp[i] = dp[i-1];
        if(s[i] == 'C' and s[i-1] == 'A')
            dp[i]++;
    }
    rep(_,q){
        int l,r;
        cin >> l >> r;
        if(r == 1)cout << dp[r - 1 ] << endl;
        else cout << dp[r-1] - dp[l-1] << endl;
    }
}




Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
typedef array<int, 3>arr3;
void die(string s) { cout << s << endl; exit(0); }
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };


void solve() {
	int A, B; cin >> A >> B;
	if (A <= 5)print(0);
	else if (A <= 12)print(B / 2);
	else print(B);
}


signed main() {
	solve();
}



Measured memory_bytes: 256
/*
	Auther:_Destiny
	time:2020.5.17
*/

#include <bits/stdc++.h>
#define ll long long
#define N 100010
#define M 1010

using namespace std;
int n;
char ss[M];

int read() {
	int s = 0, f = 0; char ch = getchar();
	while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

int main() {
	cin >> n;
	cin >> ss;
	int len = strlen(ss);
	if (len <= n) cout << ss << "\n";
	else {
		for (int i = 0; i < n; i++)
			cout << ss[i];
		cout << "...\n";
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	int flag=0;
	cin>>a>>b>>c;
	for(int i=1;i<=b;i++){
		if((i*a)%b==c){printf("YES\n");return 0;} 
	}
	printf("NO");
	return 0;
}
//QAZWSXEDCRFVTGBYHNUJMIKOLP


Measured memory_bytes: 384