akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc135/tasks/abc135_d

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// ll lcm(long a, long b) { return a * b / gcd(a, b); }

ll dp[100001][13];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    dp[0][0] = 1;
    REP(i, (int)s.length()) {
        if (s[i] == '?') {
            for (int j = 0; j < 10; j++) {
                for (int k = 0; k < 13; k++) {
                    dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
                }
            }
        } else {
            int j = s[i] - '0';
            for (int k = 0; k < 13; k++) {
                dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
            }
        }
        for (int j = 0; j < 13; j++)
            dp[i + 1][j] %= MOD;
    }
    cout << dp[s.length()][5] << endl;

    return 0;
}


Measured memory_bytes: 10704
#include<bits/stdc++.h>
#define nl '\n'
#define dbg(a) cout<<#a<<"="<<a<<nl
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define ll long long
#define vl vector<ll>
#define pll pair<ll, ll>
#define ii pair<int,int>
#define vi vector<int>
#define md 998244353

using namespace std;

int solve()
{
    ll n;
    cin>>n;
    ll x=(n+1000-1)/1000;
    cout<<x*1000-n<<endl;
    return 0;
}

int main()
{
    fast;
    solve();

    return 0;
}












Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)




int main() {
	int n;
	cin >> n;
	vector<double>v(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	sort(all(v));

	double cur =(v[0]+v[1])/2;
	for (int i = 2; i < n; i++) {
		cur = (cur + v[i]) / 2;
	}
	cout << setprecision(20) << cur << endl;

	
	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    n,a, b = map(int, input().split())
    sum = 0
    if (a+b)*10 ** 100 > n:
        mod = n %(a+b)
        ans = n // (a+b)
        sum = ans * a
        if mod > a:
            sum =sum + a
        else:
            sum = sum + mod
    else:
        sum = b * (10 ** 100)
    print(sum)


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main(){
	int h, w;
	cin >> h >> w;

	vector<string> s(h);
	rep(i, 0, h) cin >> s[i];

	vvi ox(h), oy(w);
	rep(i, 0, h) ox[i].pb(-1);
	rep(i, 0, w) oy[i].pb(-1);

	rep(i, 0, h){
		rep(j, 0, w){
			if(s[i][j] == '#'){
				ox[i].pb(j);
				oy[j].pb(i);
			}
		}
	}

	rep(i, 0, h) ox[i].pb(w);
	rep(i, 0, w) oy[i].pb(h);

	int ans = 0;
	rep(y, 0, h){
		rep(x, 0, w){
			if(s[y][x] == '#') continue;

			int x1 = lower_bound(all(ox[y]), x) - ox[y].begin();
			int y1 = lower_bound(all(oy[x]), y) - oy[x].begin();

			int tmp = (ox[y][x1]-ox[y][x1-1]-1) + (oy[x][y1]-oy[x][y1-1]-1) - 1;
			chmax(ans, tmp);
		}
	}
	
	cout << ans << endl;

	return 0;
}


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

class Student {
public:
	int order;
};

int main() {
	Student* student;
	int N;
	int* num;

	cin >> N;

	student = new Student[N];
	num = new int[N];

	for (int i = 0; i < N; i++) {
		cin >> student[i].order;
		num[student[i].order - 1] = i + 1;
	}
	for (int j = 0; j < N; j++) {
		cout << num[j] << ' ';
	}
	delete[] student;
	delete[] num;
	return 0;
}

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

int main(){//選択ソート

    int n,A[100],minj;
    int count = 0;

    cin >> n;

    for (int i = 0; i < n; i++){
        cin >> A[i];
    }

    for (int i = 0; i <= n - 1; i++){
        minj = i;
        for (int j = i; j <= n - 1; j++){
            if (A[j] < A[minj]){
                minj = j;
            }
        }
        swap(A[i],A[minj]);
        if (A[i] != A[minj]){
            count += 1;
        }
    }

    for (int i = 0; i < n; i++){
            if (i != n - 1){
                cout << A[i] << " ";
            } else {
                cout << A[i] << endl;
            }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3108
s=input()
n=len(s)
lst=[]
cnt=1

if n==2:
  print(1)
  
for i in range(n-1):
  if s[i]==s[i+1]:
    cnt+=1
  else:
    lst.append(cnt)
    cnt-=(cnt-1)

if s[n-2]!=s[n-1]:
  lst.append(1)
else:
  lst.append(cnt)
    
totl=0
l=len(lst)
if s[0]=='<':
  for j in range(l):
    if j%2==0:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,l-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)
else:
  totl+=lst[0]
  for j in range(len(lst)):
    if j%2==1:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,l-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)

      
      
      
      
      
  


Measured memory_bytes: 6300
Tmp = []
Tmp = input().rstrip().split(' ')

nN = int(Tmp[0])
nM = int(Tmp[1])
nX = int(Tmp[2])

nAns1 = 0
nAns2 = 0
Tmp = input().rstrip().split(' ')
for i in range(nM):
  nTmp = int(Tmp[i])
  if nTmp < nX:
    nAns1 += 1
  else:
    nAns2 += 1

if nAns1 < nAns2:
  print(nAns1)
else:
  print(nAns2)
  




Measured memory_bytes: 3060
#include <iostream>
#include<cmath>
#define ll long long
using namespace std;
 
  
int main() {
 
      
 ll i,j,n,m,t;
  ll sum=0;
     
       cin>>n;
       sum=n%1000;
       if(sum!=0)
       cout<<1000-sum;
       else cout<<0;
 
    return 0;
}

Measured memory_bytes: 3632
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,k = readInts()
    A = readInts()
    g = 0
    for i in range(n):
        g = gcd(g,A[i])

    if k <= max(A) and k % g == 0:
        print("POSSIBLE")
    else:
        print('IMPOSSIBLE')
if __name__ == '__main__':
  main()


Measured memory_bytes: 16336
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect
import functools

def is_prime(n):
    if n == 1:
        return False
    if n == 2:
        return True
    for i in range(2,int(n**0.5)+1):
        if n%i != 0:
            continue
        else:
            return False
    return True

n = int(input())
A = [int(input()) for i in range(n)]
cnt = 0
for i in range(n):
    if is_prime(A[i]):
        cnt+=1
print(cnt)


Measured memory_bytes: 6776
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector <int> n;

int main(){
	int a,b,c,d,i;
	cin>>a>>b;
	for(int i=1;i<1100;i++){
		c=i*0.08;
		d=i*0.1;
		if(c==a&&d==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main(){
  ll n,W;cin>>n>>W;
  ll w[100], v[100];rep(i,n)cin>>w[i]>>v[i];
  ll dp[100010];rep(i,100010)dp[i] = 0;
  repd(i,w[0],W+1)dp[i] = v[0];
  repd(i,1,n){
    for(int j = W;j >= w[i];j--){
      dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
    }
  }
  cout << dp[W] << endl;
}



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

int A, B, C, K;

int main(){
  cin >> A >> B >> C >> K;
  int ans = 0;
  if (K < A) ans += K;
  else{
    ans += A;
    K -= A;
    if (K < B) ans += K;
    else{
      K -= B;
      if (K < C) ans -= K;
      else ans -= C;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include<iostream>

int main(void){
    int n;
    std::cin >> n;
    std::string s;
    std::cin >> s;
    int cnt = 1;
    char b = s[0];
    for(int i = 1; i < n; i++){
        if(s[i] != b){
            cnt++;
            b = s[i];
        }
    }
    std::cout << cnt << std::endl;
    return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    ll n,k;cin>>n>>k;
    ll ans=0;
    FOR(i, k, n+1){
        ll mn=(i-1)*i / 2;
        ll mx=(2*n-i+1) * i / 2;
        ans += mx-mn+1;
        ans%=mod;
    }
    cout<<ans%mod<<endl;
    return 0;
}


Measured memory_bytes: 3556
/*
                            Author: Ankit Kaul
*******Code Belongs to Respective Author Only*************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
/*freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
        {   if(n % 2 ==1)
            result=(result * x)%M;
            x=(x*x)%M;
            n=n/2;
        }
    return result%M;
}
bool isPrime(int n)
    {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
    }
int inv(int a,int m)
{   return power(a,m-2);
}   
int lcm(int a,int b)
{   return a*b/(gcd(a,b));
}
signed main()
{   jaldi   
    string str;
    cin>>str;
    int sum=0,n=str.length()-1;
    while(n>=0)
    {   int x=str[n]-'0';
        sum+=x;
        n--;
    }
    if(sum%9==0)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}


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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0, acnum=0, wanum=0, tlenum=0, renum=0;
vector<ll> A;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        string a;
        cin >> a;
        if(a[0]=='A') {
            acnum++;
        }
        if(a[0]=='W') {
            wanum++;
        }
        if(a[0]=='T') {
            tlenum++;
        }
        if(a[0]=='R') {
            renum++;
        }
    }
    cout << "AC x " << acnum << endl;
    cout << "WA x " << wanum << endl;
    cout << "TLE x " << tlenum << endl;
    cout << "RE x " << renum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)

const string YES = "YES";
const string NO = "NO";

void solve(std::string S){
    ll cnt = 0;
    for(auto x:S){
        if(x == 'x') cnt++;
    }
    cout << (cnt<=7? YES:NO)<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main() {
  int N ,sum ,Ai ;
  sum = 100000000000;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> Ai ;
    int sumi =0;
    while ( Ai % 2 == 0){
      Ai = Ai/2;
      sumi ++;
    }
    if (sumi < sum){
      sum = sumi;
  }
  }
cout << sum  << endl;
}


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

using ll = long long int ;
using pii = pair<int,int >;
using vec = vector<int> ;
const int nax = 1e5 + 10;

vec indegree(nax);
vec graph[nax] ;
vector<ll> dp(nax, -1 ) ;

ll dfs(int node){
	if(dp[node] != -1 ) return dp[node];
	ll cnt = 0;
	for(auto x : graph[node] ){
		cnt = max(dfs(x) , cnt );
	}
	return dp[node] = cnt + 1; 
}


int main()
{
	int vertex, edge ;
	scanf("%d%d",&vertex,&edge);
	
	for(int i = 0 ; i < edge ; i++){
		int a , b; 
		scanf("%d%d",&a,&b);
		graph[a].emplace_back(b);
		indegree[b] ++;
	}
	
	ll ans = 0;
	for( int i = 1; i <= vertex ; i++){
		if(indegree[i] == 0 ){
			ans = max(ans,dfs(i) );
		}
		
	}
	
	printf("%lld\n",ans-1);
    return 0;
}


Measured memory_bytes: 11520
N = int(input())
B = list(map(int,input().split()))
A = [B[0]] + B
#print(A,B)
for i in range(N-1):
    #print(i,B[i] >= max(A[i],A[i+1]))
    if B[i] < max(A[i],A[i+1]):
        A[i] = A[i+1]
print(sum(A))

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

using Graph = vector<vector<ll>>;

ll N;
char field[510][510];
bool A[510],B[510];

int main(){
    cin >> N;
    bool flag = 0;
    rep(i,N){
        rep(j,N){
            cin >> field[i][j];
            if(field[i][j] == '#'){
                A[j] = 1;
                flag = 1;
            }
        }
    }
    if(!flag){
        cout << -1 << endl;
        return 0;
    }
    ll ans = INF;
    rep(i,N){
        ll cnt = 0;
        rep(j,510) B[j] = A[j];
        rep(j,N){
            if(field[i][j] == '.' && B[i]){
                cnt++;
            }else if(field[i][j] == '.'){
                cnt += 2;
                B[i] = 1;
            }
        }
        if(ans > cnt){
            ans = cnt;
        }
    }
    rep(i,N){
        rep(j,N){
            if(field[j][i] == '.'){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
x,y=map(int,input().split())
tx=x
flag=False
i=y
while(i>=0):
    if (i%2) ==0 and (i//2)==x:
        flag=True
        break
    x-=1
    i-=4
    if(x<0):
        break
if(flag):
    print("Yes")
else:
    if (y%4)==0 and (y//4)==tx:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 9196
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int M = scan.nextInt();
			int count = 0;
			Integer []A =new Integer[N];
			for(int i = 0;i<N;i++)A[i]=scan.nextInt();
			
			Arrays.sort(A);
			
			PriorityQueue<Integer>queue = new PriorityQueue<Integer>(new COMP());
			
			for(int i = 0;i<N;i++) {
				queue.add(A[i]);
			}
			
			
			while(count!=M) {
				Integer a = queue.poll();
				a/=2;
				count++;
				queue.add(a);
			}
			
			long goukei = 0;
			
			while(!queue.isEmpty()) {
				goukei+=queue.poll();
			}
	
			System.out.println(goukei);
			
		}
		
		
	}
	
	 static class COMP implements Comparator<Integer>{	
			public int compare(Integer x,Integer y) {
				if(x>y) return -1;
				if(x<y) return 1;
				return 0;
				}
				}
		

}


Measured memory_bytes: 62388
//#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <utility>
#include <algorithm>
//#include <map>
//#include <vector>
using namespace std;

int main() {
	pair<pair<string, int>, int> pp[100];
	int n;
	char s[100][11];
	int p[100];

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s%d", s[i], &p[i]);
	}
	for (int i = 0; i < n; i++) {
		pp[i] = make_pair(make_pair(s[i], -p[i]), i);
	}

	sort(pp, pp + n);
	for (int i = 0; i < n; i++) {
		printf("%d\n", pp[i].second + 1);
	}
	//while (1);
}

Measured memory_bytes: 256
/*
* @Author: _dp95
* @Date:   2020-04-14 13:00:55
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

signed main( ){
  timesaver ;
  int a, b ;
  cin >> a >> b ;
  if( a == b ){
    return cout << "Draw" << nl, 0 ;
  }
  string ans = "";
  if( a == 1 ){
    ans = "Alice" ;
  }
  else if( b == 1 ){
    ans = "Bob" ;
  }
  else if( a < b ){
    ans = "Bob" ;
  }
  else if( a > b ){
    ans = "Alice" ;
  }
  cout << ans << nl ;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

ll n;
vl a;

int main(){
	cin>>n;
	a=vl(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vpll b(n);
	for(int i=0;i<n;i++){
		b[i].first=a[i];
		b[i].second=i;
	}
	sort(b.rbegin(),b.rend());
	vl s(n);
	vpll ans;
	for(int i=0;i<n;i++) s[i]=b[i].first;
	for(int i=1;i<n;i++) s[i]+=s[i-1];
	ll I=-1,now=n;
	while(I<n-1){
		I++;
		if(b[I].second>now) continue;
		now=b[I].second;
		ans.push_back({I==0?0:s[I]-b[I].first*(I+1),now});
	}
	vl res(n);
	for(int i=1;i<ans.size();i++){
		res[ans[i-1].second]=ans[i].first-ans[i-1].first;
	}
	res[0]=s[n-1]-ans[ans.size()-1].first;
	for(int i=0;i<n;i++) cout<<res[i]<<endl;
}

Measured memory_bytes: 7024
#include <bits/stdc++.h>
using namespace std;
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; }

using ll = long long;

const long long INF = 1LL << 60;
const ll MOD = ll(1e9)+7;


int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll vector_finder(vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  if (itr == vec.end()) {
    return -1;
  }
  size_t index = std::distance( vec.begin(), itr );
  return index;
}

bool has_key_using_find(unordered_map<ll, string> &m, ll n){
    if (m.find(n) == m.end()){
        return false;
    }
    else{
        return true;
    }
}


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

  vector<ll> num(100000, 0);
  vector<ll> A(N);
  for(ll i = 0; i < N; i++) {
    cin >> A.at(i);

    num.at(A.at(i)-1)++;
  }

  ll Q;
  cin >> Q;
  vector<ll> B(Q);
  vector<ll> C(Q);
  vector<ll> S(Q, 0);


  ll tmp_sum = 0;

  for (ll j = 0; j < num.size(); j++) {
    tmp_sum += num.at(j) * (j+1);
  }


  unordered_map<string, ll> map;

  for(ll i = 0; i < Q; i++) {
    cin >> B.at(i) >> C.at(i);


    tmp_sum += num.at(B.at(i)-1) * C.at(i);
    num.at(C.at(i)-1) += num.at(B.at(i)-1);
    tmp_sum -= num.at(B.at(i)-1) * B.at(i);
    num.at(B.at(i)-1) = 0;
    
    S.at(i) = tmp_sum;
    

  }

  for (ll i = 0; i < Q; i++) {
    cout << S.at(i) << endl;
  }
  
  
  return 0;
}

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

int main(){
    int N,K;
    cin>>N>>K;
    long long x[N],tmp,ans=1e+18;
    for(int i=0;i<N;i++){
        cin>>x[i];
    }
    for(int j=0;j<N-K+1;j++){
        tmp = min(abs(x[j])+abs(x[j+K-1]-x[j]),abs(x[j+K-1])+abs(x[j+K-1]-x[j]));
        ans = min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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



int main(){
    int H, W; cin >> H >> W;
    vii cost(10, vi(10));
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cin >> cost[i][j];
        }
    }
    vii a(H, vi(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> a[i][j];
        }
    }


    for(int k=0; k<10; k++){
        for(int i=0; i<10; i++){
            for(int j=0; j<10; j++){
                chmin(cost[i][j], cost[i][k]+cost[k][j]);
            }
        }
    }

    ll sum=0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(a[i][j] == -1) continue;
            sum+=cost[a[i][j]][1];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3664
#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>a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int b=0,c=0;
  for(int i=0;i<n;i+=2)b+=a[i];
  for(int i=1;i<n;i+=2)c+=a[i];
  cout<<b-c<<endl;
}

Measured memory_bytes: 3552
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto inf = (llint)1<<31;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main(){
	string s;
	cin >> s;
	string ans = "";
	rep(i, 0, s.size()) {
		if (s[i] == '?')ans += 'D';
		else ans += s[i];
	}
	cout << ans << endl;
	return 0;
}


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

int Dad[100000+10];int N,M;
int val[100000+10];

int find(int x){
	int i=x;
	while(Dad[i]!=i){
		i=Dad[i];
	}
	while(i!=x){
		Dad[x]=i;
		x=Dad[x];
	}
	return x;
}

void merge(int x,int y){
	int m=find(x);
	int n=find(y);
	Dad[m]=n;
	return;
}

void init(){
	cin>>N;cin>>M;
	for(int i=1;i<=N;i++){
		scanf("%d",&val[i]);
		Dad[i]=i;
	}
	return;
}

int main(){
	init();int v1,v2;int ans=0;
	while(M--){
		scanf("%d%d",&v1,&v2);
		merge(v1,v2);
	}
	for(int i=1;i<=N;i++){
		if(find(i)==find(val[i])){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int main(){
  int player_num;
  int winner_idx;
  int cut_off_rate;
  while(~scanf("%d %d %d",&player_num,&winner_idx,&cut_off_rate)){
    if(player_num == 0) break;
    int vote_num[101];
    int carry = 0;
    for(int i=1;i<=player_num;i++){
      scanf("%d",vote_num + i);
      carry += vote_num[i]*100;
    }
    
    carry *= (double)(100-cut_off_rate)/100.0 + EPS;
    
    printf("%d\n",vote_num[winner_idx] == 0 ? 0 : carry/vote_num[winner_idx]);
  }
  
}

Measured memory_bytes: 1188
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<climits>
#include<cmath>
#include<fstream>
#include<numeric>

int main(){
	int N;
	std::vector<int> H;
	int max=0;
	int cnt=0;

	std::cin >> N;
	for(int i=0;i<N;i++){
		int h;
		std::cin >> h;
		if(max<h) max=h;
		if(max<=h) cnt++;
	}

	std::cout << cnt << std::endl;

	return 0;
}


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

using namespace std;

#define int long long

template <typename T> T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T> T lcm(T m, T n) { return n * m / gcd(n, m); }
template <typename T> T fact(T n) { return (n == 0 ? 1 : n * fact(n - 1)); }
template <typename T> T modpow(T a, T e, T m) { return (e == (T)0 ? 1 : ((a % m) * modpow((a % m), e - 1, m)) % m); }

constexpr int MOD = 1e9 + 7;

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

  if (n % 2 == 1)
    cout << 0 << endl;
  else {
    int num = 0;
    int r = 10;
    while (r <= n) {
      num += n / r;
      r *= 5;
    }
    cout << num << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,sum=0,by=1000;
  cin >>N;
  for(int i=0;i<4;i++){
    if(N/by==2){
      sum++;
      N=N-(N/by)*by;
      by/=10;
    }else{
      sum+=0;
      N=N-(N/by)*by;
      by/=10;
    }
  }
  cout <<sum;
}
  


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

using namespace std;

#define IoFast ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long int
#define float long double
#define foor(i, a, b) for ( int (i) = (a); (i)<(b); (i)++ )
#define foor2(i, a, b) for( int (i) = (a); (i)>(b); (i)-- )
#define foorl(i, a, b) for ( ll (i) = (a); (i)<(b); (i)++ )
#define foorl2(i, a, b) for( ll (i) = (a); (i)>(b); (i)-- )
#define mp make_pair
#define f1 first
#define f2 second
#define pb push_back
#define pii pair<int,int>
#define vpii vector <pii>
#define vi vector<int>
#define sz(a) (int) a.size( )
#define fillArr(n, a) foor(i, 0, n) cin >> a[i];
#define print(a) cout << #a << endl;
#define umax(a,b) a = max ( a, b )
#define umin(a,b) a = min ( a, b )
#define all(k) k.begin ( ), k.end( )
#define rall(k) k.rbegin ( ), k.rend( )
#define clean(k) memset( k, 0, sizeof(k) )
#define endl '\n'


int main(){
	IoFast;
	string s;
	cin >> s;
	int ans = 0;
	int j = 0;
	foor(i,0,sz(s)){
		if (s[i] == 'S')
			ans++;
		if (s[i] == 'T' && ans > 0){
			ans --;
			j++;
		}
	}
	cout << sz(s) - (2 * j) << endl;
}



Measured memory_bytes: 720
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef complex<ld> Point;
const ll mod = 1000000007;
const ld INF = 1e+30;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

bool used[1 << 17];
vector<int> G[1 << 17];
void solve() {
	int n, m; cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int l = 0, r = G[0][0]; used[0] = used[r] = true;
	vector<int> le({ 0 }), ri({ r });
	while (true) {
		bool f = true;
		rep(j, G[l].size()) {
			int to = G[l][j];
			if (used[to])continue;
			else {
				f = false;
				le.push_back(to);
				used[to] = true;
				l = to;
				break;
			}
		}
		if (f)break;
	}
	while (true) {
		bool f = true;
		rep(j, G[r].size()){
			int to = G[r][j];
			if (used[to])continue;
			else {
				f = false;
				ri.push_back(to);
				used[to] = true;
				r = to;
				break;
			}
		}
		if (f)break;
	}
	reverse(le.begin(), le.end());
	rep(i, ri.size())le.push_back(ri[i]);
	cout << le.size() << endl;
	rep(i, le.size()) {
		if (i > 0)cout << " ";
		cout << le[i]+1;
	}
	cout << endl;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	//stop
	return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

vector<string> vec;

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

    ll N;
    string S,T;
    cin >> S>>T;

    bool flag = true;
    bool flag1 = true;

    if(S.size()<T.size()){
        cout << "UNRESTORABLE" << endl;
    }
    else{
        REP(i,S.size()-T.size()+1){
            REP(j,T.size()){
                char S_tmp = S.at(i + j);
                char T_tmp = T.at(j);
                flag = true;

                if(S_tmp=='?'){

                }
                else if(S_tmp==T_tmp){

                }
                else{
                    flag = false;
                    break;
                }
            }
            if(flag){
                string U = S;

                REP(j,T.size()){
                    U.at(i + j) = T.at(j);
                }
                REP(j,U.size()){
                    if (U.at(j) == '?')
                    {
                        U.at(j) = 'a';
                    }
                }

                vec.push_back(U);
            }
        }

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

        if(vec.size()==0){
            cout << "UNRESTORABLE" << endl;
        }
        else{
            cout << vec.at(0) << endl;
        }
    }
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int freq[100100];
int main () {
	int n;
	cin >> n;
	int a[n];
	long long sum = 0;
	for (int i=0; i<n; i++) {
		cin >> a[i];
		freq[a[i]]++;
		sum += a[i];
	}
	int q;
	cin >> q;
	long long bi, ci;
	while (q--) {
		cin >> bi >> ci;
		sum -= bi*freq[bi];
		sum += ci*freq[bi];
		freq[ci] += freq[bi];
		freq[bi] = 0;
		cout << sum << endl;
	}
}

Measured memory_bytes: 4392
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int fun(int arr[],int ind,int n,vector<int>&v)
{
    if(ind==n-1)
        return 0;
    else if(v[ind]!=-1)
        return v[ind];
    {
        int x = INT_MAX,y = INT_MAX;
        x = abs(arr[ind]-arr[ind+1]) + fun(arr,ind+1,n,v);
        if(ind!=n-2)
        {
            y = abs(arr[ind]-arr[ind+2]) + fun(arr,ind+2,n,v);
        }
        v[ind] = min(x,y);
        return v[ind];
    }
}
int main()
{
 int n;
 cin>>n;
 int arr[n];
 vector<int>v(n+2,-1);
 for(int i=0;i<n;i++)
    cin>>arr[i];
    fun(arr,0,n,v);
 cout<<v[0]<<endl;
}


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

const int N = 100 * 1000 + 5;
int nparts = 0;

int a[N];
vector <int> adj[N];
int part[N];
vector <int> vec[N];
vector <int> rm;

void dfs(int v) {
	for (auto u : adj[v]) {
		if (!part[u]) {
			part[u] = part[v];
			dfs(u);
		}
	}
}
int main() {
	long long ans = 0;
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	if (m == n - 1) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < n; i++) {
		if (!part[i]) {
			nparts++;
			part[i] = nparts;
			dfs(i);
		}
	}
	for (int i = 0; i < n; i++) {
		vec[part[i]].push_back(a[i]);
	}
	for (int i = 1; i <= nparts; i++) {
		sort(vec[i].begin(), vec[i].end());
		ans += vec[i][0];
		for (int j = 1; j < vec[i].size(); j++) {
			rm.push_back(vec[i][j]);
		}
	}
	sort(rm.begin(), rm.end());
//	cout << nparts << endl;
	if (2 * (nparts - 1) > n) {
		cout << "Impossible" << endl;
	}
	else {
		for (int i = 0; i < nparts - 2; i++) {
			ans += rm[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 10108
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            a[i] = Math.abs(temp - x);
        }
        int ans = a[0];
        for (int i = 1; i < n; i++) {
            ans = getGcd(ans, a[i]);
        }
        System.out.println(ans);
    }

    private static int getGcd(int x, int y) {
        return y == 0 ? x : getGcd(y, x % y);
    }
}

Measured memory_bytes: 48016
import java.io.*;

class Main
{
   public static void main(String[] args) throws IOException
   {

      BufferedReader br =
       new BufferedReader(new InputStreamReader(System.in));

      String str = br.readLine();
      int x = Integer.parseInt(str);

      System.out.println( (int)Math.pow(x,3) );

   }
}

Measured memory_bytes: 24308
#include <bits/stdc++.h>
#define ll long long int
#define INF 1000000000000
#define MOD 1000000007
#define DEBUG(x) cerr<<'>'<<#x<<':'<<x<< endl
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, m;
    cin >> n >> m;
    ll sum = 0;
    for(ll i = 0; i < m; i++)
    {
        ll el;
        cin >> el;
        sum += el;
    }    
    cout << max((ll)-1, (n - sum)) << endl;
    return 0;
}


Measured memory_bytes: 3644
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
using namespace literals;

constexpr int64_t Mod = 998244353;

long long modpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % Mod;
    a = a * a % Mod;
    n >>= 1;
  }
  return res;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> D(N);
  for (auto& v : D)cin >> v;
  int M = *max_element(begin(D), end(D));
  vector<int> t(M + 1, 0);
  for (auto& v : D)++t[v];
  if (D[0] != 0 || t[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  int64_t ans = 1;
  for (int i = 0; i < M; ++i)
    ans = ans * modpow(t[i], t[i + 1]) % Mod;
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	int n;
	long a[200000];
	
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	
	sort(a, a + n);
	
	bool b = true;
	for (int i = 0; i < n - 1; i++)
		if (a[i] == a[i + 1])
				b = false;
	
	switch(b) {
	 case true: cout << "YES"; break;
	 case false: cout << "NO"; break;
	}
}


Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main(void){
	int l,a,b,c,d;
	cin>>l>>a>>b>>c>>d;
	int j = a % c != 0 ? a / c + 1 : a / c;
	int m = b % d != 0 ? b / d + 1 : b / d;
	cout<<(j > m ? l - j : l - m)<<endl;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int a[100][100],b[100][100];
bool dp[82][82][30000];

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

int main(){
	int h,w;cin>>h>>w;
	rep(i,h)rep(j,w)scanf("%d",&a[i][j]);
	rep(i,h)rep(j,w)scanf("%d",&b[i][j]),a[i][j]-=b[i][j],a[i][j]=abs(a[i][j]);
	int K=15000;
	dp[0][0][K+a[0][0]]=1;
	dp[0][0][K-a[0][0]]=1;
	rep(i,h)rep(j,w){
		rep(k,K*2){
			if(dp[i][j][k]==0)continue;
			if(i+1<h)dp[i+1][j][k+a[i+1][j]]=1,dp[i+1][j][k-a[i+1][j]]=1;
			if(j+1<w)dp[i][j+1][k+a[i][j+1]]=1,dp[i][j+1][k-a[i][j+1]]=1;
		}
	}
	int Min=INT_MAX;
	rep(i,30000){
		if(dp[h-1][w-1][i]==1)Min=min(Min,abs(i-K));
	}
	cout<<Min<<endl;
}

Measured memory_bytes: 191488
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
#define INF 1<<21
using pii = std::pair<int,int>;
#define SORT(v) std::sort(v.begin(), v.end())

int main(){
    int N;
    std::cin >> N;
    int input,ans=0;
    std::map<long long,int> mp;
    for (int i = 0; i < N; i++) {
        std::cin >> input;
        mp[input]++;
        if (mp[input] % 2 == 0) {
            mp[input] = 0;
        }

    }
     
    for (auto i = mp.begin(); i !=mp.end(); i++) {
        ans += i->second;
    }
    std::cout << ans << std::endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> b(n-1);
  for(int i=0; i<n-1; i++) cin >> b[i];
  
  int ans = b[0]+b[b.size()-1];
  for(int i=1; i<n-1; i++) ans += min(b[i-1], b[i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
import sys
input = sys.stdin.readline

N = int(input())
edges = []
for _ in range(N-1):
    u, v = map(int, input().split())
    u, v = u-1, v-1
    if u > v:
        u, v = v, u
    edges.append((u, v))

numV = 0
for i in range(N):
    numV += (i+1) * (N-i)

numE = 0
for u, v in edges:
    numE += (u+1) * (N-v)

ans = numV - numE
print(ans)


Measured memory_bytes: 36044
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=500005;
int n,K,P[maxn],ans[maxn];priority_queue<int> H;bool vis[maxn];
inline int read()
{
	int ret=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){ret=ret*10+ch-'0';ch=getchar();}
	return ret*f;
}
struct SegmentTree
{
	int Tree[maxn*4];
	inline void PushUp(int rt){Tree[rt]=(P[Tree[rt*2]]<P[Tree[rt*2+1]]?Tree[rt*2+1]:Tree[rt*2]);}
	inline void Build(int L=1,int R=n,int rt=1)
	{
		if(L==R){Tree[rt]=L;return;}
		int M=(L+R)>>1;
		Build(L,M,rt*2);
		Build(M+1,R,rt*2+1);
		PushUp(rt);
	}
	inline void Update(int P,int L=1,int R=n,int rt=1)
	{
		if(L==R) return;
		int M=(L+R)>>1;
		if(P<=M) Update(P,L,M,rt*2);
		if(M<P) Update(P,M+1,R,rt*2+1);
		PushUp(rt);
	}
	inline int Query(int LL,int RR,int L=1,int R=n,int rt=1)
	{
		if(LL<=L&&R<=RR) return Tree[rt];
		int ret=0,M=(L+R)>>1;
		if(LL<=M)
		{
			int tep=Query(LL,RR,L,M,rt*2);
			if(P[tep]>P[ret]) ret=tep;
		}
		if(M<RR)
		{
			int tep=Query(LL,RR,M+1,R,rt*2+1);
			if(P[tep]>P[ret]) ret=tep;
		}
		return ret;
	}
}ST;
inline void Solve()
{
	for(int i=1;i<=n;i+=K)
	{
		int t=ST.Query(i,min(n,i+K-1));
		if(t==ST.Query(max(1,t-K+1),min(n,t+K-1))){H.push(t);vis[t]=true;}
	}
	for(int i=n;i;i--)
	{
		int qh=H.top();H.pop();ans[qh]=i;
		P[qh]=0;ST.Update(qh);
		for(int j=(qh-1)/K;j<=(qh-1)/K+2;j++)
		{
			int L=(j-1)*K+1,R=j*K;
			if(L>n||R<1) continue;
			L=max(1,L);R=min(n,R);
			int t=ST.Query(L,R);
			if(t&&t==ST.Query(max(1,t-K+1),min(n,t+K-1))&&!vis[t]){H.push(t);vis[t]=true;}
		}
	}
}
int main()
{
	n=read();K=read();
	for(int i=1;i<=n;i++) P[i]=read();
	ST.Build();Solve();
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 17776
#include<bits/stdc++.h>
using namespace std;
int main(){ 
  long long n,a[100],b[100],c=0;
  cin>>n;
  for(int i=0;i<n-1;i++){
    cin>>a[i];
  }
  b[0]=a[0];
  b[n-1]=a[n-2];
  for(int i=0;i<n-2;i++){
   if(a[i]<=a[i+1]){
         b[i+1]=a[i];
      }
      else{
        b[i+1]=a[i+1];
      }
    
  }
  for(int i=0;i<n;i++)
    c+=b[i];
 
  cout<<c<<endl;
  return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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 a,b;cin >> a >>b;
    cout << a*b <<endl;
}

Measured memory_bytes: 3604