akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main(){
  int n;
  cin >> n;
  int f = digsum(n);
  if(n % f == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

}



Measured memory_bytes: 256
def main():
	x = [int(i) for i in input().split()]
	y = [int(i) for i in input().split()]
	y.sort()
	if (x[1]!=0):
		z = y[:-x[1]]
	else:
		z = y
	print(sum(z))
if __name__== "__main__":
	main()

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
// using P = std::tuple<int,int>;

int p, q, r;

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

    std::cin >> p >> q >> r;

    int res = std::min({p + q, q + r, r + p});
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
using namespace std;

char s[20];

int main(){
    scanf("%s", s);
    int x;
    x = (s[6]-'0') +(s[5]-'0')*10;
    if(x <= 4)
        printf("Heisei\n");
    else
        printf("TBD\n");
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int x, y, ta = 1;

signed main() {
	cin >> x >> y;
	while (1) {
		x *= 2;
		if (x <= y)ta++;
		else break;
	}
	cout << ta << endl;
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>

#define	mp	make_pair

using namespace std;

typedef	pair<int,int>	pii;

const int dx[]={1,1,0,-1,-1,-1,0,1},dy[]={0,-1,-1,-1,0,1,1,1};
int field[50][50];
bool visited[50][50];

int main(){
	for(int w,h;scanf("%d%d",&w,&h),w;){
		for(int i=0;i<h;i++)for(int j=0;j<w;j++){
			scanf("%d",field[i]+j);
			visited[i][j]=false;
		}

		int cnt=0;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++){
			if(field[i][j]==1 && !visited[i][j]){
				visited[i][j]=true;
				queue<pii> qu;	qu.push(mp(i,j));
				while(!qu.empty()){
					pii a=qu.front();	qu.pop();
					for(int k=0;k<8;k++){
						int xx=a.second+dx[k],yy=a.first+dy[k];
						if(0<=xx && xx<w && 0<=yy && yy<h
						&& field[yy][xx]==1 && !visited[yy][xx]){
							qu.push(mp(yy,xx));
							visited[yy][xx]=true;
						}
					}
				}
				cnt++;
			}
		}

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

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <set>
#include <utility>
#include <vector>
#include <cstring>

using namespace std;

int h, w;
vector<string> s;
vector<pair<int, int>> node[400][400];
pair<long long, long long> cnt;

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

void dfs(int x, int y){
    if(s[x][y] == '?') return;
    if(s[x][y] == '#'){
        cnt.first++;
    }else{
        cnt.second++;
    }
    s[x][y] = '?';
    for(auto&& i : node[x][y]){
        dfs(i.first, i.second);
    } 
}

void hawawa()
{
    cin >> h >> w;
    s.resize(h);
    for (auto&& i : s) {
        cin >> i;
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for(int k = 0; k < 4; k++){
                if(i + dx[k] < 0 || j + dy[k] < 0 || i + dx[k] == h || j + dy[k] == w){
                    continue;
                }
                if(s[i][j] != s[i + dx[k]][j + dy[k]]){
                    node[i][j].push_back(make_pair(i + dx[k], j + dy[k]));
                    node[i + dx[k]][j + dy[k]].push_back(make_pair(i, j));
                }
            }
        }
    }
    long long ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#'){
                cnt = make_pair(0, 0);
                dfs(i, j);
                ans += cnt.first * cnt.second;
            }
        }
    }
    cout << ans << "\n";
}

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


Measured memory_bytes: 24192
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
    int K, A, B; cin >> K >> A >> B;
    if(B - (B%K) >=A){
        cout << "OK" << endl;
    }
    else cout << "NG" << endl;
}

Measured memory_bytes: 3636
import numpy as np
N,M,X = (int(i) for i in input().split())  
c = [[int(i) for i in input().split()] for i in range(N)] 
c = np.array(c)
cost = 12*10**5*10
cmp_flg = False
for i in range(2**N):
  m = np.zeros(M)
  tmp_cost = 0
  for j in range(N):
    if ((i>>j)&1):
      m += c[j][1:]
      tmp_cost += c[j][0]
  if (min(m)>=X) & (tmp_cost<cost):
    cmp_flg = True
    cost = tmp_cost
    
if cmp_flg ==True:
  print(cost)
else:
  print("-1")

Measured memory_bytes: 27092
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
int q,a,b;
string s;
cin>>q;
map<string,int>m;
for(;q--;){
cin>>a;
if(a==0)cin>>s>>b,m[s]=b;
if(a==1)cin>>s,cout<<m[s]<<endl;
if(a==2)cin>>s,m.erase(s);
}
}


Measured memory_bytes: 27724
import collections
import sys
input = sys.stdin.readline

N = int(input())
# o(10**5 * 10**2 = 10**7)
list =  [''.join(sorted(list(input().strip("\n")))) for i in range(N)]
# o(10**5 * log(10**5) = 10**7)
list.sort()

c = collections.Counter(list)
c = c.most_common()
ans = 0
for i,v in c:
    ans += v*(v-1)//2

print(ans)

Measured memory_bytes: 24516
n=gets.chomp.to_i
weights=gets.chomp.split.map(&:to_i)
total=0
array=[]

weights.each do |i|
  total += i
end

(0..(n - 1)).each do |t|
  s_1=0
  (0..t).each do |i|
    s_1 += weights[i]
  end
  s_2= total - s_1
  if s_1 > s_2
    s=s_1 - s_2
  else
    s=s_2 - s_1
  end
  array << s
end

array_=array.sort

print array_[0]


Measured memory_bytes: 1788
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		P[] kk=new P[n];
		for(int i=0; i<n; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			kk[i]=new P(a,b);
		}
		Arrays.sort(kk,(t,y)->t.b-y.b);
		long time=0;
		for(int i=0; i<n; i++){
			if(kk[i].a>kk[i].b-time){
				System.out.println("No");
				return;
			}
			time+=kk[i].a;
		}
		System.out.println("Yes");
	}
	static class P{
		int a;
		int b;
		public P(int a,int b){
			this.a=a;
			this.b=b;
		}
	}
}



Measured memory_bytes: 104744
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

#define int long long

int N,M;


bool sou[101010];

int cnt[202020];

int fff = 0;

int ss[202020];
int sum[202020];

int func(int x) {
  int res = ss[101010 - 1] - ss[x - 1] - (sum[101010 -1] - sum[x - 1]) * (x - 1) + fff;
  return res;
}



signed main() {
  cin >> N >> M;
  for(int i = 0;i < M;i++) {
    int m;
    cin >> m;
    m--;
    sou[m] = true;
  }

  sou[N] = true;

  int fi = 0;
  while(!sou[fi]) fi++;

  fff = fi;
  {
    int c = 0;
    for(int i = fi;i <= N;i++) {
      if(sou[i]) {
        cnt[c]++;
        c = 0;
      }
      else {
        c++;
      }
    }
  }

  cnt[0] = 0;

  for(int i = 1;i < 101010;i++) {
    sum[i] += sum[i - 1] + cnt[i];
  }

  for(int i = 1;i < 101010;i++) {
    ss[i] += ss[i - 1] + cnt[i] * i;
  }

  int Q;
  cin >> Q;
  vector<int> ans;
  for(int qq = 0;qq < Q;qq++) {
    int l;
    cin >> l;
    int ok = 101010;
    int ng = 0;
    while(ok - ng > 1) {
      int mid = (ok + ng) / 2;
      if(func(mid) <= l) ok = mid;
      else ng = mid;
    }
    ans.push_back(ok);
  }

  for(auto x : ans) {
    if(x == 101010) { cout << -1 << endl; }
    else { cout << x << endl;}
  }

}



Measured memory_bytes: 5652
import scala.io.StdIn.readLine

object Main {
  val gesIndex = Map("Rock"->0,"Fire"-> 1, "Scissors" -> 2, "Snake" -> 3,
                    "Human"->4, "Tree"->5, "Wolf"->6, "Sponge"->7,
                    "Paper"->8, "Air"->9, "Water"->10, "Dragon"->11,
                    "Devil"->12, "Lightning"->13, "Gun" -> 14)

  def scan(list:Array[Int],i:Int,n:Int):String = {
    if(i==n) "Draw"
    else {
      val win = (list((i+1)%n)-list(i)+15)%15
      val j = if(i>0) i-1 else n-1
      val lose = (list(i)-list(j)+15)%15
      if(win<=7 && lose>7) gesIndex.find(_._2==list(i)).map(_._1).get
      else scan(list,i+1,n)
    }
  }

  def main(args:Array[String]) = {
    var n = 0
    while({n=readLine.trim.toInt;n}!=0) {
      val unsorted = new Array[Int](n)
      for(i<-0 until n)
        unsorted(i) = gesIndex(readLine.trim)
      val list = unsorted.sorted
      println(scan(list,0,list.length))
    }
  }
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	vector<float> a(n);
	rep (i, 0, n)
		cin >> a[i];

	float res = 0;
	rep (i, 0, n) {
		res += 1.0 / a[i];
	}

	cout << 1.0 / res << endl;

	return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  rep(i, n) {
    int h;
    cin >> h;
    if (h >= k) ans++;
  }

  cout << ans << endl;

  return 0;
}

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

int main(){
  int A=0,a,B=0,b;

  for(int i=0;i<4;i++)cin >> a, A+=a;
  for(int i=0;i<4;i++)cin >> b, B+=b;

  if(A>B)cout << A << endl;
  else cout << B << endl;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
    int s[5],sum=0,i;
    for(i=0;i<3;i++)
        scanf("%d",&s[i]);
    sort(s,s+3);
    if(s[0]==s[1]&&s[1]==s[2]&&s[0]==s[2])
        printf("0\n");
    else if(s[1]==s[2])
    {
        if((s[1]-s[0])%2==1)
            printf("%d\n",(s[1]-s[0]+1)/2+1);
        else
            printf("%d\n",(s[1]-s[0])/2);
    }
    else
    {
        for(;;)
        {
            s[0]=s[0]+1;
            s[1]=s[1]+1;
            sum=sum+1;
            if(s[1]==s[2])
                break;
        }
        if((s[1]-s[0])%2==1)
            printf("%d\n",(s[1]-s[0]+1)/2+1+sum);
        else
            printf("%d\n",(s[1]-s[0])/2+sum);
    }
    return 0;
}


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

int main() {
    int a, b, c; cin >> a >> b >> c;
    int min = a, min2 = b, max = c;
    if (min > min2) {
        swap(min, min2);
    }
    if (min2 > max) {
        swap(min2, max);
    }
    if (min > min2) {
        swap(min, min2);
    }
    
    cout << min << ' ' << min2 << ' ' << max << endl;
}


Measured memory_bytes: 3088
// problem: "https://atcoder.jp/contests/abc142/tasks/abc142_f"

#include<bits/stdc++.h>

using namespace std;

vector<int> bfs(int i,vector<int>G[],int n)
{
    queue<int>Q;
    vector<bool>Vis(n+1,0);
    vector<int>P(n+1,-1);

    Q.push(i);
    Vis[i] = 1;

    while(!Q.empty())
    {
        int p = Q.front();
        Q.pop();

        int j;

        for(j=0;j!=G[p].size();j++)
        {
            if(Vis[G[p][j]])
            {
                if(G[p][j] == i)
                {
                    vector<int>V;

                    while(p != -1)
                    {
                        V.push_back(p);
                        p = P[p];
                    }

                    return V;
                }

                continue;
            }

            Vis[G[p][j]] = 1;
            P[G[p][j]] = p;
            Q.push(G[p][j]);
        }
    }

    vector<int>E;
    return E;
}

vector<int> shortestCycle (vector<int>G[],int n)
{
    vector<vector<int>>SC;
    int i,s;

    for(i=1;i!=n+1;i++)
    {
        vector<int>V = bfs(i,G,n);      // define

        if(!V.empty())
            SC.push_back(V);
    }

    if(SC.empty())
    {
        vector<int>E;
        return E;
    }

    s = 0;
    for(i=0;i!=SC.size();i++)
    {
        if(SC[s].size() > SC[i].size())
            s = i;
    }

    return SC[s];
}

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

    vector<int>G[n+1];
    int i,x,y;

    for(i=0;i!=m;i++)
    {
        cin>>x>>y;
        G[x].push_back(y);
    }

    vector<int>V = shortestCycle(G,n);      // define

    if(V.empty())
        cout<<-1;

    else
    {
        cout<<V.size()<<'\n';
        for(i=V.size()-1;i!=-1;i--)
            cout<<V[i]<<'\n';
    }

    return 0;
}


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

template<typename T>
using vec = vector<T>;

using tup = tuple<string,int,int>;

int main(){
	int N; cin>>N;
	vec<tup> book(N);
	rep(i,N){
		string s; int p;
		cin>>s>>p;
		book[i]=tup(s,-p,i+1);
	}
	sort(book.begin(),book.end());
	for(auto &e:book){
		int ans; tie(ignore,ignore,ans)=e;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll l;
    cin >> n >> l;
    vector<ll> a(n);
    int p = -1;
    rep(i,n){
        cin >> a[i];
        if(i > 0){
            if(a[i] + a[i-1] >= l){
                p = i;
            }
        }
    }
    if(p == -1){
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    for(int i = 1; i < p; ++i) cout << i << endl;
    for(int i = n-1; i > p; --i) cout << i << endl;
    cout << p << endl;
    return 0;
}


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

using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 int N;
 string s;
 cin>>N;
 int A,B,C,D;
 cin>>A>>B>>C>>D>>s;
 A--;
 B--;
 C--;
 D--;
 
 int flag=1;
 if(D>C)
 {
    while(B!=D)
    {
        if(B+2<=D && s[B+2]!='#')
        {
            B=B+2;
        }
        else if(B+1<=D && s[B+1]!='#')
        {
            B+=1;
        }
        else break;
    }
   // cout<<"INDIA";
    if(B!=D)
    {cout<<"No";return 0;}
    while(A!=C)
    {
        if(A+2<=C && s[A+2]!='#')
        {
            A+=2;
        }
        else if(A+1<=C && s[A+1]!='#')
        {
            A++;
        }
        else break;
    }
    if(A!=C){
        cout<<"No";
        return 0;
    }
 }
 else
 {
     while(A!=C)
     {
         if(A+2<=C && s[A+2]!='#' && A+2!=B)
         {
             A+=2;
         }
         else if(A+1<=C && s[A+1]!='#' && A+1!=B)
         {
             A+=1;
         }
         else if(A+1==B)
         {
             if(B+1<=D && s[B+1]!='#')
             {
                 B++;
             }
             else if(B+2<=D && s[B+2]!='#')
             {
                 B+=2;
             }
             else break;
         }
         else if(A+2==B)
         {
             if(B+1<=D && s[B+1]!='#')
             B++;
             else if(B+2<=D && s[B+2]!='#')
             {
                 B+=2;
             }
             else break;
         }
         else break;
     }
     if(A!=C) {cout<<"No";
     return 0;}
    while(B!=D)
    {
        if(B+2<=D && s[B+2]!='#')
        {
            B=B+2;
        }
        else if(B+1<=D && s[B+1]!='#')
        {
            B+=1;
        }
        else break;
    }
    if(B!=D)
    {cout<<"No";return 0;}
 }
 cout<<"Yes";
	return 0;
	
}

Measured memory_bytes: 592
#include <iostream>
using namespace std;
const int Prime[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
int num,n;
int a[100],ans;
int main(){
    cin>>n;
    for(int i=0;i<25;i++){
        int x=n;
        num=0;
        while(x){
            x/=Prime[i];
            num+=x;
        }
        a[num]++;
    }
    for(int i=99;i;i--)a[i-1]+=a[i];
    ans+=a[74];
    ans+=a[24]*(a[2]-1);
    ans+=a[14]*(a[4]-1);
    ans+=a[4]*(a[4]-1)*(a[2]-2)/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
 
s= sys.stdin.readline().strip()
#
MOD=10**9+7
mmap= []
for i in range(6):
    b = 10**i % 13
    mmap.append( [ [ (b*i+j)%13 for i in range(1,10) ] for j in range(13) ] )
#
dp= [ 0 ] * 13
dp[0] = 1
j= 0
for c in reversed(s):
    tmp = dp.copy()
    #
    if c=="0": pass
    elif c=="?":
        bset = mmap[j]
        for m,num in enumerate(tmp):
            if num==0: continue
            for idx in bset[m]: dp[idx]+=num
        #
        for i in range(13): dp[i]%=MOD
    else:
        b= mmap[j][0][int(c)-1]
        for m in range(13):
            idx= (m+b)%13
            dp[idx]= tmp[m]
    #
    if j==5: j=0
    else: j+=1
#
print(dp[5])


Measured memory_bytes: 3316
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);


int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);

int main()
{
    ll n, m, x;
    cin >>n >> m;
    for(int i = 0 ; i < m ; i++){
    cin >> x;
    n -= x;
    }

    if(n>=0)
    cout << n << endl;
    else
    cout <<"-1" << endl;
    return 0;
}





Measured memory_bytes: 3596
import java.util.Scanner;

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

		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = 0;

		ans = (B-1)*(A-1);

		System.out.println( ans );
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
const int N=200005;
int n,a[N],b[N],dp[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]),b[a[i]]=i;
	int ans=0;
	for (int i=1;i<=n;i++){
		int p=b[a[i]-1];
		dp[i]=dp[p]+1;
		ans=max(ans,dp[i]);
	}
	printf("%d",n-ans);
	return 0;
}

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

using Lint=long long;
using P=pair<int,int>;
using Graph=vector<vector<int>>;

int main()
{
   int N,M; cin>>N>>M;
   Graph G(N);
   for(int i=0;i<N-1;i++){
      int a,b; cin>>a>>b;
      a--; b--;
      G[a].push_back(b);
      G[b].push_back(a);
   }

   vector<map<int,int>> dp(N);
   function<int(int,int)> dfs=[&](int v,int p)
   {
      int res=1;
      for(int u:G[v]) if(u!=p) res=(Lint)res*(dfs(u,v)+1)%M;
      return dp[v][p]=res;
   };
   vector<int> ans(N);
   function<void(int,int)> reroot=[&](int v,int p)
   {
      int N=G[v].size();
      vector<int> L(N+1,1),R(N+1,1);
      for(int i=0  ;i< N;i++){ L[i+1]=(Lint)L[i]*(dp[G[v][i]][v]+1)%M; }
      for(int i=N-1;i>=0;i--){ R[i]=(Lint)(dp[G[v][i]][v]+1)*R[i+1]%M; }
      ans[v]=R[0];
      for(int i=0;i<N;i++) if(G[v][i]!=p){
         dp[v][G[v][i]]=(Lint)L[i]*R[i+1]%M;
         reroot(G[v][i],v);
      }
   };
   dfs(0,-1); reroot(0,-1);
   for(int i=0;i<N;i++) cout<<ans[i]<<endl;
   return 0;
}


Measured memory_bytes: 35840
n=int(input())
ans=0
i=2
while i*i<=n:
    cnt=0
    while n%i==0:
        n//=i
        cnt+=1
    j=0
    # print(i,cnt)
    for k in range(1,cnt+1):
        if (k*(k+1))//2<=cnt:
            j=max(j,k)
    ans+=j
    i+=1
# print('n',n)
if n>1:
    ans+=1
print(ans)


Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n,c,k;cin>>n>>c>>k;
  vector<int> t(n);rep(i,n)cin>>t[i];
  sort(all(t));
  int ans = 0;

  int cnt = 0;
  int first = -INF;
  rep(i,n){
    cnt++;
    if(first + k < t[i] || cnt > c){
      ans++;
      cnt = 1;
      first = t[i];
      // test(first);
    }
  }
  print(ans);
  return 0;
}




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n;
  cin>>n;
  ll sum =0;
  for(ll i = 1 ; i<=n ;i++)
  {
    if(i%3==0 || i%5==0)
      continue;
    else
      sum+=i;

  }
  cout<<sum;
  
  return 0;
}

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

using namespace std;

int main()
{
  int n;
  vector<int> a;

  cin >> n;
  for (int i = 0; i < n; i++) {
    int m;
    cin >> m;
    a.push_back(m);
  }
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());

  cout << a.size() << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;
int main()
{
    string a;
    while(cin>>a){
        int len=a.length();
        cout<<a[0]<<len-2<<a[len-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (sc.hasNext()) {
			int h1 = sc.nextInt();
			int h2 = sc.nextInt();
			int h_now = h1+h2;
			int e1 = sc.nextInt();
			
			int num = 0;
			for (int i=1; i<=10; i++) {
				if (i==h1 || i==h2 || i==e1) {
					continue;
				}
				if (i+h_now <= 20) {
					num++;
				}
			}
			
			out.println(num>3?"YES":"NO");
		}
	}
}


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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define repr(i, n) for (ll i = n - 1; i >= 0; --i)
#define INF 10e8
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    int h, w;
    cin >> h >> w;
    vector<vector<int>> c(10, vector<int>(10));
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    vector<vector<int>> a(h, vector<int>(w));
    rep(i, h) rep(j, w) cin >> a[i][j];

    rep(k, 10) rep(i, 10) rep(j, 10) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);

    int ans = 0;
    rep(i, h) rep(j, w) if (a[i][j] != -1) ans += c[a[i][j]][1];
    cout << ans << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3776
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int n1[1002]={};
	int n2[1002]={};
	string K;
	while(getline(cin,K)&&K!=""){
		int a=0;
		for(int i=0;i<K.size();i++)
		{
			if(K[i]!=','){
				a=a*10;
				a+=K[i]-'0';
			}
			else{
				n1[a]++;
			}
		}
	}
	while(getline(cin,K)&&K!=""){
		int a=0;
		for(int i=0;i<K.size();i++)
		{
			if(K[i]!=','){
				a=a*10;
				a+=K[i]-'0';
			}
			else{
				n2[a]++;
			}
		}
	}
	for(int i=0;i<1001;i++)
	{
		if(n1[i]>0&&n2[i]>0){
			cout<<i<<" "<<n1[i]+n2[i]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>

#define N 100000

int binarySearch(int A[], int aLength, int key) {
  int left = 0;
  int right = aLength;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key) return 1;
    if (A[mid] < key) {
      left = mid + 1;
    }
    else if (A[mid] > key) {
      right = mid;
    }
  }
  return 0;
}

int main() {
  int i, length, tLength;
  int count = 0;
  int S[N], T[N];
  scanf("%d", &length);
  for (i = 0; i < length; i++) {
    scanf("%d", &S[i]);
  }
  scanf("%d", &tLength);
  for (i = 0; i < tLength; i++) {
    scanf("%d", &T[i]);
    if (binarySearch(S, length, T[i]) == 1) {
      count++;
    }
}
  printf("%d\n", count);
return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin>>N;
vector<int>A(N);
for(int i=0;i<N;i++)
{cin>>A[i];}
vector<int>B(N);
for(int i=0;i<N;i++)
{B[i]=A[i];}
sort(A.begin(),A.end());
for(int i=0;i<N;i++)
{if(B[i]==A[N-1]){cout<<A[N-2]<<endl;
}
else{cout<<A[N-1]<<endl;
}
}











}

Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,s,g1,g2;
long d[111][111];
main()
{
	while(cin>>n>>m>>s>>g1>>g2,n)
	{
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(i!=j)d[i+1][j+1]=1e18;
		for(;m--;)
		{
			int a,b,c;cin>>a>>b>>c;
			d[a][b]=c;
		}
		for(int k=1;k<=n;k++)for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)
			d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		long ans=1e18;
		for(int i=1;i<=n;i++)
		{
			ans=min(ans,d[s][i]+d[i][g1]+d[i][g2]);
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3176
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
 
		int tmp = sc.nextInt();
		int num = tmp % 10;
 
        if (num == 2 || num == 4 || num == 5 || num == 7 || num == 9) {
			System.out.println("hon");
		} else if (num == 0 || num == 1 || num == 6 || num == 8) {
			System.out.println("pon");
		} else {
			System.out.println("bon");
		}
 
	}
 
}

Measured memory_bytes: 35752
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    vector<int> h(n);
    for (auto i = 0; i < n; i++) cin >> h[i];

    vector<vector<int>> r(n, vector<int>(0));
    for (auto i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        r[a - 1].push_back(b - 1);
        r[b - 1].push_back(a - 1);
    }

    int ans = 0;
    for (auto i = 0; i < n; i++) {
        bool flg = true;
        for (auto elm : r[i]) {
            if(h[i] <= h[elm]) {
                flg = false;
                break;
            }
        }
        if(flg) {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

    int pre_time =0;
    int pre_x =0;
    int pre_y =0;


    bool can = true;

    for(int i=0; i<N; i++ ){
    	int delta_time, delta_x, delta_y, delta_dis;
    	int cur_time, cur_x, cur_y;
    	cin >> cur_time >> cur_x >> cur_y;

    	delta_time= cur_time - pre_time;
    	delta_x= abs(cur_x - pre_x);
    	delta_y= abs(cur_y - pre_y);
    	delta_dis = delta_x + delta_y;

    	//cout << delta_time << delta_x << delta_y << endl;

    	if(delta_time < delta_dis){
    		can = false;
    		break;
    	}
    	if((delta_time % 2)  != (delta_dis % 2) ){
    		can = false;
    		break;
    	}
    	pre_x=cur_x;
    	pre_y=cur_y;
    	pre_time=cur_time;
    }

	if(can)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


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

ans = -float("inf")
for i in range(1,1 << 10):
    l = [0]*n
    for j in range(10):
        #bin(i)をj桁シフトして0001と&をとる　＝　j桁目が1なら採用
        if ((i >> j) & 1) == 1:
            # fが一日どうか
            for k in range(n):
                if f[k][j] == 1:
                    l[k]+= 1
    
    ansi = 0
    for m in range(n):
        ansi += p[m][l[m]]
    ans = max(ans,ansi)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define ui unsigned int 
using namespace std;

int main() {
	int x, y;
	cin >> x >> y;
	if (x > y) { cout << "a > b" << endl; }
	else if (x == y) { cout << "a == b" << endl; }
	else { cout << "a < b" << endl; }
}



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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 5e5+10;

vector<pair<ll,ll> > a;
vector<pair<ll,ll> > b;

int main(){
fast;
int n;
cin>>n;
a.clear();
b.clear();
for(int i=0;i<n;i++) {
    ll x,y;
    cin>>x>>y;
    a.push_back(make_pair(x,y));
    b.push_back(make_pair(-1*y,-1*x));
}

sort(a.begin(),a.end());
sort(b.begin(),b.end());

if(n%2==1){
    if(n==1) {
        cout<<a[n/2].second-a[n/2].first+1<<endl;
    } else {
        ll x = a[n/2].first;
        ll y =-1*b[n/2].first;
        cout<<y-x+1<<endl;
    }
} else {
    ll prevx = a[n/2-1].first;
    ll prevy = -1*b[n/2-1].first;
    ll curx =  a[n/2].first;
    ll cury = -1*b[n/2].first;

    ll avgx = (prevx+curx);
    ll avgy = (prevy+cury);

    cout<<avgy-avgx+1<<endl;
}
return 0;
}

Measured memory_bytes: 9788
N,M = map(int,input().split())
H = list(map(int,input().split()))

li = [1 for i in range(N)]

for i in range(M):
    a,b = map(int,input().split())
    a-=1
    b-=1

    if H[a]>=H[b]:
        li[b]=0
    if H[a]<=H[b]:
        li[a]=0
# print(li)
ans = 0
for i in range(N):
    if li[i]:
        ans += 1
print(ans)


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

int main() {
	int n;
	int m, x;
	cin >> n;
	cin >> m;
	cin >> x;

	vector<int> price(n);
	vector<vector<int>> point(n, vector<int>(m));

	for (int i = 0; i < n; i++) {
		cin >> price[i];
		for (int j = 0; j < m; j++) {
			cin >> point[i][j];
		}
	}

	int least = INT_MAX;

	for (int bit = 0; bit < (1 << n); bit++) {
		vector<int> target(m, 0);
		int amount = 0;
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) {
				amount += price[i];
				for (int j = 0; j < m; j++) {
					target[j] += point[i][j];
				}
			}
		}
		bool accomplished = true;
		for (int j = 0; j < m; j++) {
			if (target[j] < x) {
				accomplished = false;
			}
		}
		if (accomplished && least > amount) {
			least = amount;
		}
	}

	if (least == INT_MAX) {
		least = -1;
	}

	cout << least << endl;

	return 0;
}

Measured memory_bytes: 3648
h, w, k = map(int, input().split())
c = [input() for _ in range(h)] # 行列の入力楽

ans = 0

for i in range(1 << h):#bit全探索行準備塗らない場所の選び方
    for j in range(1 << w): #bit全探索列準備塗らない場所の選び方
        cnt = 0
        for x in range(h):
            for y in range(w):
                if c[x][y] == '#' and (i >> x) & 1 and (j >> y) & 1: #c[x][y]が黒で赤色に塗られていない
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)


Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

bool cmp(pint a, pint b) {return a.second < b.second;}
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; }

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

    rep(i, s.size()) s[i] = 'x';

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;

const int Mod = 998244353;
inline int Add(int x, int y) {
  x += y;
  return x >= Mod ? x - Mod : x;
}
inline int Mul(int x, int y) {
  return 1LL * x * y % Mod;
}

const int maxn = 2e5 + 10;
int n, f[2][3][3][2];
char s[maxn];

namespace Brute {
  set<string> A;

  void Dfs(string now) {
    if (A.find(now) != A.end()) return;
    A.insert(now);
    // cout << now << endl;
    for (int i = 1; i < now.length(); ++i) {
      if (now[i - 1] != now[i]) {
        bool ch[3];
        ch[0] = ch[1] = ch[2] = 0;
        ch[now[i - 1] - 'a'] = ch[now[i] - 'a'] = 1;
        char vis;
        for (int j = 0; j < 3; ++j)
          if (!ch[j]) vis = 'a' + j;
        string nxt = now;
        nxt[i - 1] = nxt[i] = vis;
        // cout << i << ' ' << vis << ' ' << nxt << endl;
        Dfs(nxt);
      }
    }
  }
  void Solve(void) {
    string p = "";
    for (int i = 1; i <= n; ++i)
      p = p + s[i];
    Dfs(p);
    printf("%d\n", (int)A.size());
  }
}

inline void Upd(int &x, int y) {
  x = Add(x, y);
}
int main(void) {
  scanf("%s", s + 1);
  n = strlen(s + 1);

  bool flag = 1;
  for (int i = 2; i <= n; ++i)
    if (s[i - 1] != s[i]) {
      flag = 0;
      break;
    }
  if (flag) {
    puts("1");
    return 0;
  }

  if (n <= 3) {
    Brute::Solve();
    return 0;
  }

  int cur = 1;
  f[0][0][0][0] = f[0][0][1][0] = f[0][0][2][0] = 1;
  for (int i = 2; i <= n; ++i) {
    memset(f[cur], 0, sizeof f[cur]);

    for (int pre = 0; pre < 3; ++pre)
      for (int j = 0; j < 3; ++j) {
        int now = (pre + j) % 3;
        for (int k = 0; k < 3; ++k)
          if (j != k) {
            Upd(f[cur][now][k][0], f[cur ^ 1][pre][j][0]);
            Upd(f[cur][now][k][1], f[cur ^ 1][pre][j][1]);
          } else {
            Upd(f[cur][now][k][1], f[cur ^ 1][pre][j][0]);
            Upd(f[cur][now][k][1], f[cur ^ 1][pre][j][1]);
          }
      }
    
    cur ^= 1;
  }

  flag = 1;
  for (int i = 2; i <= n; ++i)
    if (s[i - 1] == s[i]) flag = 0;

  int sum = 0;
  for (int i = 1; i <= n; ++i)
    sum = (sum + s[i] - 'a') % 3;
  
  int ans = flag;
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      if ((i + j) % 3 == sum)
        ans = Add(ans, f[cur ^ 1][i][j][1]);
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] z = new int[N];

        for (int i = 0; i < M; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();

            if ((z[a-1] != 0 && z[a-1] != b) || (N >= 2 && a == 1 && b == 0)){
                System.out.println(-1);
                return;
            }
            z[a-1] = b;
        }

        if (N >= 2 && z[0] == 0){
            z[0] = 1;
        }

        for (int i = 0; i < z.length; i++){
            System.out.print(z[i]);
        }

    }
}

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    //good luck kittu!
    int n, r; cin>>n>>r;
    if(n>=10) cout<<r<<"\n";
    else cout<<r+100*(10-n)<<"\n";
    return 0;
}

Measured memory_bytes: 256
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
const vl dx = {1,0,-1,0,1,0,-1,0};
const vl dy = {0,1,0,-1,0,1,0,-1};
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modpow(ll x,ll n,ll mod){ll res=1;for(ll i=0;i<n;i++){res=res*x%mod;}return res;}
ll MODpow(ll x,ll n){ll res=1;for(ll i=0;i<n;i++){res=res*x%MOD;}return res;}


/*--------------------------------------------------------------------------*/

//main関数
int main() {
    ll n,r; cin >> n >> r;
    if(n >= 10) cout << r << endl;
    else cout << r + 100 * (10 - n) << endl;
}



Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define px(str) cout<<(str)<<endl,exit(0);
#define pe(str) return cout<<(str)<<endl,0;
#define IF(a,b,c) ((a)?(b):(c))
using namespace std;

int main(int argc,char** argv){
	int a,b,c;
	cin>>a>>b>>c;

	if(a+b<c)px("NA");
	px(IF(a>=c,0,c-a));
	return 0;
}



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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int res = min(b, d) - max(a, c);
    if (res >= 0) cout << res << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int n,A[100010],B[100010];
int main() {
	scanf("%d",&n);
	int i;
	for(i=1;i<=n+1;i++)scanf("%d",A+i);
	ll res=0;
	for(i=1;i<=n;i++) {
		scanf("%d",B+i);
		ll val=min(A[i],B[i]);
		A[i]-=val,B[i]-=val;res+=val;
		val=min(A[i+1],B[i]);
		A[i+1]-=val,B[i]-=val;res+=val;
	}
	printf("%lld",res);
	return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A * A % MOD, N / 2);
  return Pow(A * A % MOD, N / 2) * A % MOD;
}

int N; ll DP[int(1e5+5)][4];
string S;

int main(){
  cin >> S; N = S.length();

  int cnt = 0;
  DP[0][0] = 1;
  for (int i = 1; i <= N; i++){
    if (S[i-1] == 'A'){
      for (int j = 1; j < 4; j++) DP[i][j] += DP[i-1][j];
      DP[i][1] += DP[i-1][0];
    }else if (S[i-1] == 'B'){
      for (int j = 1; j < 4; j++) DP[i][j] += DP[i-1][j];
      DP[i][2] += DP[i-1][1];
    }else if (S[i-1] == 'C'){
      for (int j = 1; j < 4; j++) DP[i][j] += DP[i-1][j];
      DP[i][3] += DP[i-1][2];
    }else{
      for (int j = 1; j < 4; j++){
        DP[i][j] += DP[i-1][j] * 3 + DP[i-1][j-1];
      }
      cnt++;
    }
    DP[i][0] = Pow(3, cnt);
    for (int j = 0; j < 4; j++) DP[i][j] %= MOD;
  }
  cout << DP[N][3] << endl;


  return 0;
}


Measured memory_bytes: 6840
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    const ll INF = 1LL<<40;
    int A, B, Q; cin >> A >> B >> Q;
    vector<ll> s, t;
    s.push_back(-INF);
    t.push_back(-INF);
    for(int i = 0; i < A; i++)
    {
        ll x; cin >> x;
        s.push_back(x);
    }
    s.push_back(INF);
    for(int i = 0; i < B; i++)
    {
        ll x; cin >> x;
        t.push_back(x);
    }
    t.push_back(INF);
    vector<ll> v(Q), ans(Q, INF);
    for(int i = 0; i < Q; i++) cin >> v[i];
    for(int k = 0; k < 2; k++)
    {
        for(int l = 0; l < 2; l++)
        {
            for (int i = 0; i < v.size(); i++)
            {
                ll sd = *(lower_bound(s.begin(), s.end(), v[i]) - k);
                ll td = *(lower_bound(t.begin(), t.end(), sd) - l);
                ans[i] = min(ans[i], abs(v[i] - sd) + abs(sd - td));
            }
            for (int i = 0; i < v.size(); i++)
            {
                ll td = *(lower_bound(t.begin(), t.end(), v[i]) - k);
                ll sd = *(lower_bound(s.begin(), s.end(), td) - l);
                ans[i] = min(ans[i], abs(v[i] - td) + abs(td - sd));
            }
        }
    }
    for(int i = 0; i < ans.size(); i++) cout << ans[i] << "\n";
    return 0;
}



Measured memory_bytes: 4596
#include <iostream>
using namespace std;
 
int main() {
  int N;
  int Y;
  cin >> N >> Y;
  int sum = 0;
  for(int i=0; i<=N; i++){
    for(int j=0; j<=N-i; j++){
      sum = i * 10000 + j * 5000 + (N-i-j) * 1000;
      if(sum == Y){
        cout << i << " " << j << " " << N-i-j;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1;
  return 0;
}


Measured memory_bytes: 256
h = Array.new(4) { Array.new(3) { Array.new(10,0) }}

n = gets.to_i
n.times {
    b,f,r,v = gets.split.map &:to_i
    h[b-1][f-1][r-1] += v
}

4.times {|i|
    3.times{|j|
        10.times{ |k|
            print " ",h[i][j][k]
        }
        puts
    }
    if i < 3
        puts "####################"
    end
}

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

int main()
{
	long long int n,b,k;
	scanf("%lld%lld%lld",&n,&b,&k);
	if(n>=k)
	{
		printf("%lld %lld \n",n-k,b );
	}
	else
	{
		long long int ans = b-(k-n);
		if(ans<0)ans=0;
		printf("%lld %lld\n",n-n,ans );

	}
}

Measured memory_bytes: 256
fact = [1, 1]; factinv = [1, 1]; inv = [0, 1]; p = 10**9+7
for i in range(2, 2001):
    fact.append(fact[-1]*i%p)
    inv.append(-inv[p%i]*(p//i)%p)
    factinv.append(factinv[-1]*inv[-1]%p)
def cmb(n, r, p):
    return fact[n]*factinv[r]*factinv[n-r]%p
s = int(input()); c = 0
for i in range(1, s//3+1):
    c += cmb(s-i*3+i-1, i-1, p)
print(c%p)

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

int main(void){
  int s1, s2, dg, rec = 0, rho = 0;
  while(scanf("%d,%d,%d", &s1, &s2, &dg) != EOF){
    if(s1 * s1 + s2 * s2 == dg * dg) rec++;
    else if(s1 == s2) rho++;
  }
  cout << rec << endl << rho << endl;
  return 0;
}

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

#define MAX_NUM(v, w) ((v) > (w) ? (v) : (w))

long long int pow_mod(long long int x, long long int y, long long int m)
{
	long long int mod, next_mod;

	if (y == 0)
	{
		return 1;
	}
	else if ((y % 2) == 0) {
		next_mod = pow_mod(x, (y / 2), m);
		mod = (next_mod*next_mod) % m;
	}
	else {
		next_mod = pow_mod(x, ((y - 1) / 2), m);
		mod = (next_mod*next_mod) % m;
		mod = (mod*x) % m;
	}

	return mod;
}

int main()
{
	long long int n, answer = 1, d = 1;
	long long int a, b;
	long long int n_step = 1, n_step_reverse = 1, a_step, n_a_step, b_step, n_b_step, n_c_a, n_c_b;

	for (int i = 0; i<9; i++)
	{
		d *= 10;
	}

	d += 7;

	scanf("%lld %lld %lld", &n, &a, &b);

	answer = pow_mod(2, n, d);

	for (long long int i = 0; i<MAX_NUM(a, b); i++)
	{

		n_step *= (i + 1);
		n_step_reverse *= (n - i);

		if (n_step >d)
		{
			n_step %= d;
		}

		if (n_step_reverse > d)
		{
			n_step_reverse %= d;
		}

		if ((i + 1) == a)
		{
			a_step = n_step;
			n_a_step = n_step_reverse;
		}

		if ((i + 1) == b) {
			b_step = n_step;
			n_b_step = n_step_reverse;
		}

	}

	n_c_a = n_a_step;
	n_c_b = n_b_step;

	n_c_a *= pow_mod(a_step, (d - 2), d);
	n_c_b *= pow_mod(b_step, (d - 2), d);

	n_c_a %= d;
	n_c_b %= d;

	answer += 2 * d;

	answer = answer - n_c_a - n_c_b;

	answer += -1;

	answer %= d;

	printf("%lld", answer);

	return 0;
}

Measured memory_bytes: 1732