akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),a=nxt(),b=nxt();
    map <ll,int> m1;
    vector <ll> v(n);
    generate(all(v),nxtl);
    sort(all(v),greater<ll>());
    for(auto i:v)
        m1[i]+=1;
    ll test=0;
    for(int i=0;i<a;i++)
        test+=v[i]; 
    //for(auto i:v)
        //cout<<i<<endl;
    //cout<<test<<endl;
    double ans=test;
    ans/=a;
    cout<<setprecision(15)<<fixed<<ans<<endl;
    ll x=v[a-1];
    ll fin2=0;
    bool f=1;
    for(int i=0;i<a-1;i++)
        if(v[i]!=v[i+1])
        {
            f=0;
            break;
        }
    for(int i2=a-1;i2<b;i2++)
    {
        if(i2>a-1)
        {
            if(!f||v[i2]!=x)
                break;
        }

        ll count=0;
        for(int i=0;i<i2+1;i++)
            if(v[i]==x)
                count++;
        ll y=m1[x];
        ll z=count;
        
        //cout<<y<<" "<<
        ll fin=binomialCoeff(y,z);
        //cout<<y<<" "<<z<<" "<<fin<<endl; 
        fin2+=fin;
    }
    
    cout<<fin2<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
use std::io::Read;
use std::str::SplitWhitespace;
use std::str::FromStr;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse<T> {
    fn parse(&mut self) -> T;
}

impl<'a, T> Parse<T> for SplitWhitespace<'a>
where
    T: FromStr,
{
    fn parse(&mut self) -> T {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn factorization(x: u32) -> Vec<u32> {
    let mut base = x;
    let mut div = 2;
    let mut v = Vec::new();

    let last = (base as f64).sqrt() as u32;
    while last >= div {
        if base % div == 0 {
            base /= div;
            v.push(div);
            continue;
        }
        div += 1;
    }
    v.push(base);
    v
}

fn rec(v: Vec<u32>, index: usize) -> u32 {
    let n = v.len();
    let a = factorization(v[index]);
    let mut vv = v.iter().cloned().collect::<Vec<_>>();
    let mut m = vec![vec![false; n]; a.len()];
    for (i, &aa) in a.iter().enumerate() {
        for j in 0..n {
            m[i][j] = vv[j] % aa == 0;
            if m[i][j] {
                vv[j] /= aa;
            }
        }
    }

    let mut base = 1_u32;
    let mut additional = Vec::new();
    for i in 0..a.len() {
        let mut c = None;
        let mut d = Some(a[i]);
        for j in 0..n {
            if !m[i][j] {
                d = None;
                if c == None {
                    c = Some((j, a[i]));
                } else {
                    c = None;
                    break;
                }
            }
        }
        if let Some(aa) = d {
            base *= aa;
        }
        additional.push(c);
    }

    let mut max = vec![base; n];
    for c in additional {
        if let Some((j, aa)) = c {
            max[j] *= aa;
        }
    }

    max.into_iter().max().unwrap()
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n: usize = iter.parse();
    let mut v: Vec<u32> = (0..n).map(|_| iter.parse()).collect();
    v.sort();

    println!(
        "{}",
        std::cmp::max(rec(v.iter().cloned().collect::<Vec<_>>(), 0), rec(v, 1))
    );
}

Measured memory_bytes: 10492
#include<stdio.h>
#include<math.h>

int main(void){
    int n,t,a,titen;
    int min=5000000;
    scanf("%d%d%d",&n,&t,&a);
    int h[n];
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    for(int i=0;i<n;i++){
        int kion=1000*t-(6*h[i]+1000*a);
        if(fabs(kion)<min){
            titen=i+1;
            min=fabs(kion);
        }
    }
    printf("%d",titen);
    return 0;
}

Measured memory_bytes: 128
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
while len(Counter(str(N)).keys()) != 1:
    N += 1
print(N)


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#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 P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"


int main()
{
    string a, b, c = "";
    cin >> a >> b >> c;
    char card = 'a';
    char ans = 'A';
    bool end = false;
    while (true)
    {
        switch (card)
        {
            case 'a':
                if (a.empty())
                {
                    ans = 'A';
                    end = true;
                    break;
                }
                card = a[0];
                a.erase(0,1);
                break;

            case 'b':
                if (b.empty())
                {
                    ans = 'B';
                    end = true;
                    break;
                }
                card = b[0];
                b.erase(0,1);
                break;

            case 'c':
                if (c.empty())
                {
                    ans = 'C';
                    end = true;
                    break;
                }
                card = c[0];
                c.erase(0,1);
                break;
        }
        if (end)
        {
            break;
        }
    }

    COUT(ans);

    return 0;
}

Measured memory_bytes: 256
from math import floor,ceil,sqrt
import fractions
from collections import deque
import itertools
from collections import deque
import collections
import heapq
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
q=[list(map(int,input().split())) for _ in range(Q)]
nums={}
su=sum(A)
#print(q)
for i in range(N):
    if nums.get(A[i])==None:
        nums[A[i]]=1
    else:
        nums[A[i]]=nums[A[i]]+1
#print(nums)
for i in range(Q):
    b,c=q[i]
    bnum=nums.pop(b,None)
    cnum=nums.pop(c,None)
    #print(anum,bnum)
    if bnum!=None:
        if cnum!=None:
            su=su+(c-b)*bnum
            nums[c]=cnum+bnum
            print(su)
        else:
            su = su + (c - b) * bnum
            nums[c]=bnum
            print(su)
    else:
        if cnum!=None:
            nums[c]=cnum
        print(su)
    #print(nums)

Measured memory_bytes: 106140
#include<cmath>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define fori(i,k,n) for(int i=k;i<n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
/*
(char)'1' - (int)48 = (int)1; 


*/


int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		int y, m, d,x;
		
		int ans = 0;
		cin >> y >> m >> d;
		ans += d;
		m--;
		ans += m * 20;
		if (y % 3)ans -= (m / 2);
		y--;
		ans += y * 195;
		ans += (y / 3) * 5;
		cout << 196471 - ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
int bp(int pow, int n){
    int d = 1;
    while(n)
    {
        if(n%2==1)d=(d*pow)%mod;
        pow=(pow*pow)%mod;
        n/=2;
    }
    return d;
}
void solve(){
    int a, b, n;
    cin>>a>>b>>n;
    if(n>=b)n-=(n-b+1);
    cout<<(a*n)/b;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

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

string s;
int use;

bool parse(int l,int r){
  for(int i=l;i<r;i++)
    if(s[i] == '=')return parse(l,i) == parse(i+1,r);

  int p = 0;
  for(int i=l;i<r;i++){
    if(s[i] == '(')p++;
    if(s[i] == ')')p--;
    if(!p){
      if(s[i] == '*')return parse(l,i) && parse(i+1,r);
      if(s[i] == '+')return parse(l,i) || parse(i+1,r);
      if(s[i] == '-' && s[i+1] == '>')return !parse(l,i) || parse(i+2,r);
    }
  }

  if(s[l] == '-')return !parse(l+1,r);
  if(s[l] == '(' && s[r-1] == ')')return parse(l+1,r-1);
  if(s[l] == 'T')return true;
  if(s[l] == 'F')return false;
  return ( ( use >> (s[l]-'a') ) & 1);
}

int main(){
  while(cin >> s,s!="#"){
    bool f = true;
    for(use=0;use<(1<<11);use++){
      f &= parse(0,s.size());
      if(!f)break;
    }
    if(f)cout << "YES\n";
    else cout << "NO\n";
  }
}

Measured memory_bytes: 940
N = int(input())
S = input()
B = [0 for _ in range(N+1)]
W = [0 for _ in range(N+1)]
for i in range(N):
    B[i+1] = B[i] + (S[i] == '#')
for i in range(N, 0, -1):
    W[i-1] = W[i] + (S[i-1] == '.')
print(min(B[i]+W[i] for i in range(N+1)))

Measured memory_bytes: 25196
#include<stdio.h>
#include<math.h>

int search(int k,int n,int A[]){
	int l=1;
	int r=pow(10,9);
	double x;
	int count;
	int i;

while (r>l){
x=floor((r-l)/2)+l;
    count=0;
	for(i=0;i<n;i++){
	     count+=ceil(A[i]/x)-1;
	}
	if(count<=k){
      r=x;//どちらかは＋１にしておく
	}
	else
	{
		l=x+1;
		if(r==l) x+=1;//最後がNoだと＋１がいる場合分け
	}
}
	
return x;
}

int main(void){
int n,k;
int i;
int ans;
scanf("%d %d",&n,&k);

int A[n];
for(i=0;i<n;i++)
   scanf("%d",&A[i]);



ans=search(k,n,A);
printf("%d\n",ans);



	return 0;
}

Measured memory_bytes: 2460
// cand <genesis?>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const ll base = 7;
const ll N = 1e5 + 9;
const ll inf = 1000100009;
typedef pair<ll,ll> LL;
vector<ll> g[N];
ll n,m,H[N],i,x,y;
bool b[N];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("test.INP", "r", stdin);
    cin>>n>>m;
    for (i=1;i<=n;i++) cin>>H[i];
    while(m--){
        cin>>x>>y;
        g[x].push_back(y);
    }
    ll cnt = 0;
    for (i=1;i<=n;i++){
        for (auto j : g[i]){
            if (H[i] < H[j]){
                if (!b[i]){
                    cnt++;
                    b[i] = true;
                }
            }
            else if (H[i] > H[j]){
                if (!b[j]){
                    cnt++;
                    b[j] = true;
                }
            }
            else{
                if (!b[i]){
                    cnt++;
                    b[i] = true;
                }
                if (!b[j]){
                    cnt++;
                    b[j] = true;
                }
            }
        }
    }
    cout<<n - cnt;
}


Measured memory_bytes: 8968
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
#define vl vector<ll>
#define vi vector<int>
 
#define ff first
#define ss second
 
#define pb push_back
#define MOD 1000000007
//const int nax = 1e6+5;
#define inf 4e18
 
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
ll sqr(ll x){return x*x;}
inline ll add(ll a, ll b){ ll c = a + b; if(c >= MOD) c -= MOD; return c; }
inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
const int nax = 200*1000 + 10;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
   int x; cin>>x;
   if(x>=30)cout << "Yes";
   else cout << "No\n";

  
    return 0;
}
    

// Химаншу


Measured memory_bytes: 3652
H, W = map(int, input().split())
s = ["".join(["0"]*(W+2))] + ["0"+input()+"0" for _ in range(H)] + ["".join(["0"]*(W+2))]
failed = False
for i in range(1, H+1):
    for j in range(1, W+1):
        if '#' != s[i][j]:
            continue
        if '#' in [s[i+x][j+y] for x, y in [(0, -1), (-1, 0), (1, 0), (0, 1)]]:
            continue
        else:
            failed = True
            break
    if failed:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;


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



    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main(){
   int n,m;
   cin>>n>>m;
   vector<int> k(n);
   vector<int> f(m,0);
   rep(i,0,n){
      cin>>k[i];
      rep(j,0,k[i]){
         int a;
         cin>>a;
         f[a-1]++;
      }
   }
   int ans=0;
   rep(i,0,m){
      if(f[i]==n) ans++;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int, int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef pair<double, int> PDI;
typedef vector<PDI> VD;

int n, k, l;
int p[100010], q[100010], r[100010], s[100010];

map<PII, int> mp;

struct uf
{
  int parent[200010];

  void reset()
  {
    for(int i = 1; i <= n; i++){
      parent[i] = i;
    }
  }

  int top(int x)
  {
    return x == parent[x] ? x : (parent[x] = top(parent[x]));
  }

  void bond(int x, int y)
  {
    if(top(x) != top(y)){
      parent[top(x)] = top(y);
    }
  }
} uf1, uf2;

signed main()
{
  scanf("%lld%lld%lld", &n, &k, &l);
  for(int i = 0; i < k; i++){
    scanf("%lld%lld", &p[i], &q[i]);
  }
  for(int i = 0; i < l; i++){
    scanf("%lld%lld", &r[i], &s[i]);
  }

  uf1.reset();
  uf2.reset();

  for(int i = 0; i < k; i++){
    uf1.bond(p[i], q[i]);
  }
  for(int i = 0; i < l; i++){
    uf2.bond(r[i], s[i]);
  }

  for(int i = 1; i <= n; i++){
    uf1.top(i);
    uf2.top(i);
  }
  
  for(int i = 1; i <= n; i++){
    if(mp.find(MP(uf1.parent[i], uf2.parent[i])) == mp.end()){
      mp[MP(uf1.parent[i], uf2.parent[i])] = 1;
    }
    else{
      mp[MP(uf1.parent[i], uf2.parent[i])]++;
    }
  }

  for(int i = 1; i <= n; i++){
    printf("%lld", mp[MP(uf1.parent[i], uf2.parent[i])]);

    if(i < n){
      putchar(' ');
    }
    else{
      putchar('\n');
    }
  }
  return 0;
}


Measured memory_bytes: 18048
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map> 
using namespace std;
typedef long long ll;
const double pi=acos(-1.0);

const ll mod=1e9+7;
ll z[200005];
int main()
{
	ll a,b,c,d;
	ll n=0,q=0;
	scanf("%lld%lld",&a,&b);
	c=0;a++;
	for(int i=1;i<=a;i++)
	{
		n+=a-i+1;
		q+=i;
		if(i<b)continue;
		c+=n-q+1;
		c%=mod;
	}
	
	printf("%lld\n",c);

}



Measured memory_bytes: 1728
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long n = long.Parse(input[0]);
		long k = long.Parse(input[1]);
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long memo = nums[0];
    long max = nums[0];

    for(int i = 1; i < n; i++)
    {
      memo = Gcd(memo, nums[i]);
      max = Math.Max(max, nums[i]);
      //Console.WriteLine(memo+" "+max);
    }
		Console.WriteLine((k <= max && (max-k) % memo == 0) ? "POSSIBLE" : "IMPOSSIBLE");
	}

  static long Gcd(long a, long b) 
      {//引数a,bの最大公約数を返す
           if (a < b)
               return Gcd(b, a);//入れ替え
           while (b != 0) 
           {
               long changeTo = a % b;
               a = b;
               b = changeTo;
           }
           return a;
       }
  
}

Measured memory_bytes: 17632
#include<iostream>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    int n,m,l;
    cin >> n >> m >> l;
    int a[n][m],b[m][l];
    F(i,0,n) F(j,0,m) cin >> a[i][j];
    F(i,0,m) F(j,0,l) cin >> b[i][j];
    long c[n][l]={};
    F(i,0,n){
        F(j,0,l){
            F(k,0,m){
                c[i][j]+=a[i][k]*b[k][j];
            }
        }
    }
    F(i,0,n){
        F(j,0,l){
            cout << c[i][j];
            if(j!=l-1) cout << ' ';
        }
        cout << endl;
    }
    return 0;
}


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

using lli = long long int;

using namespace std;

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

    lli a;
    cin >> a;
    lli ans = a;
    for (lli i = 1; i < N; i++) {
        cin >> a;
        ans = std::__gcd(a, ans);
    }

    cout << ans << endl;

    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010];
ll L[101010],R[101010];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N+1) cin>>A[i];
	L[N]=R[N]=A[N];
	for(i=N-1;i>=0;i--) {
		L[i]=A[i]+(L[i+1]+1)/2;
		R[i]=A[i]+R[i+1];
	}
	if(L[0]>1) return _P("-1\n");
	ll cur=1;
	ll ret=0;
	FOR(i,N+1) {
		ret+=cur;
		cur-=A[i];
		cur=min(cur*2,R[i+1]);
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 5584
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


int main() {
	int K, A, B;
	cin >> K >> A >> B;

	if (A % K == 0 || A % K == 0) {
		cout << "OK" << endl;
	}
	else if(B/K-A/K>0){
		cout << "OK" << endl;
	}
	else {
		cout << "NG" << endl;
	}
}


Measured memory_bytes: 3612
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;


public class Main {
	Scanner sc = new Scanner(System.in);
	void a() {
		while(true) {
			int n = sc.nextInt();
			if(n == 0) return;
			int[] a = new int[n];
			int sum = 0;
			for(int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
				sum += a[i];
			}
			sum /= (double)(n);
			int cnt = 0;
			for(int i = 0; i < n; i++) {
				if(a[i] <= sum) {
					cnt++;
				}
			}
			System.out.println(cnt);
		}

	}
	
	void b() {
		while(true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int t = sc.nextInt();
			int p = sc.nextInt();
			if(n == 0 && m == 0 && t == 0 && p == 0) return;
			int[][] pe = new int[m * 2][n * 2];
			for(int i = 0; i < m * 2; i++) {
				Arrays.fill(pe[i], 0);
			}
			for(int i = 0; i < m; i++) {
				for(int j = 0; j < n; j++) {
					pe[i][j] = 1;
				}
			}
			/*for(int i = 0; i < m * 2; i++) {
				System.out.println(Arrays.toString(pe[i]));
			}*/
			int x = 0;
			int y = 0;
			for(int k = 0; k < t; k++) {
				int d = sc.nextInt();
				int c = sc.nextInt();
				//System.out.println(d);
				if(d == 1) {	
					for(int i = x; i < c + x; i++) {
						for(int j = 0; j < m * 2; j++) {
							int num = pe[j][i]; 
							pe[j][i] = 0;
							//System.out.println(i + (c - i) * 2 + " " + j);
							pe[j][i + (c - i + x) * 2 - 1] += num;
						}
					}
					x += c;
					//System.out.println(x);
				}
				if(d == 2) {
					for(int i = y; i < c + y; i++) {
						for(int j = 0; j < n * 2; j++) {
							int num = pe[i][j]; 
							pe[i][j] = 0;
							pe[i + (c - i + y) * 2 - 1][j] += num;
						}
					}
					y += c;
				}
			}
			/*
			for(int i = 0; i < m * 2; i++) {
				System.out.println(Arrays.toString(pe[i]));
			}
			*/
			
			for(int i = 0; i < p; i++) {
				int X = sc.nextInt();
				int Y = sc.nextInt();
				int ans = pe[y + Y][x + X];
				//System.out.println(x + X + " " + (y + Y) + " " + x + " "  + y);
				System.out.println(ans);
			}
			
	
		}

	}
	

	public static void main(String[] args) {
		new Main().a();
	}

}



Measured memory_bytes: 58956
a,b,x = map(int,input().split())
tal1 = (b-x/(a**2))*2/a
tal2 = a*(b**2)/2/x
tal = b/a
ans = tal1
if tal1>tal:
  ans = tal2
import math
ans = math.degrees(math.atan(ans))

print(ans)

Measured memory_bytes: 3060
from itertools import permutations
n,m = map(int,input().split())

rel_t = [[False for i in range(n)] for j in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    rel_t[a-1][b-1]=True
    rel_t[b-1][a-1]=True

cnt=0
n_list = [i for i in range(n)]
for l in permutations(n_list,len(n_list)):
    if(l[0]!=0):
        continue
    judge=[rel_t[l[i]][l[i+1]] for i in range(n-1)]
    if all(judge):
        cnt+=1

print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>

#define INF 100000000000000007

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

    std::vector<int> x(n);
    for(int i = 0; i < n; ++i){
        std::cin >> x.at(i);
    }

    long long ans = INF;
    for(int p = 1; p <= 100; ++p){
        long long val = 0;
        for(int i = 0; i < n; ++i){
            val += std::pow(x.at(i) - p, 2);
        }
        ans = std::min(ans, val);
    }

    std::cout << ans << std::endl;

    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
ll N,A,B;
	cin >> N>>A>>B;
	vecl(H);
	fx(N) {
		vecpl(H);
	}
	A -= B;
	ll left = 0, right = 2000000000;
	ll mid;
	while(right-left>1) {
		mid = (left + right) / 2;
		ll k = mid;
		fy(N) {
			if (H[y] >mid*B) {
				ll tmp = (H[y] - mid * B);
				k -= (tmp + A - 1) / A;
				//at = mid- k;
			}
		}

		if (k>=0) {
			right = mid;
		}
		else {
			left = mid;
		}
	}

			ce(right)

    return 0;
}



Measured memory_bytes: 1400
H, W, K = map(int, input().split())
mod = 1000000007
K -= 1

Hikikata = [1] * (W + 10)
Hikikata[0] = 1
Hikikata[1] = 2
for i in range(2, W+1):
    Hikikata[i] = Hikikata[i-1] + Hikikata[i-2]
    Hikikata[i] %= mod

DP = [[0] * (W + 10) for _ in range(H+1)]

DP[0][K] = 1
for i in range(1, H + 1):
    for j in range(W):
        DP[i][j] = DP[i-1][j] * (Hikikata[j-1] * Hikikata[W-j-2]) % mod + DP[i-1][j-1] * (Hikikata[j-2] * Hikikata[W-j-2]) % mod + DP[i-1][j+1] * (Hikikata[j-1] * Hikikata[W-j-3]) % mod
        DP[i][j] %= mod

print(DP[H][0])


Measured memory_bytes: 38256
n = int(input())
ws = [list(input()) for _ in range(n)]
 
def sort_l(l):
    l.sort()
    return l
ws = list(map(sort_l, ws))
ws.sort()
 
i = 0
j = 0
r = 0
ans = 0
while(i<n-1):
    i += 1
    if ws[i] == ws[j]:
        r += 1
    else:
        ans += r * (r+1) // 2
        r = 0
        j = i
ans += r * (r+1) // 2
 
print(ans)

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

int A, B, C, X, Y;

int main()
{
	std::cin >> A >> B >> C >> X >> Y;

	if (A + B < 2 * C) {
		std::cout << (A*X + B*Y) << std::endl;
	} else if (X < Y) {
		if (B < 2 * C) {
			std::cout << (2 * C * X + B * (Y - X)) << std::endl;
		} else {
			std::cout << (2 * C * Y) << std::endl;
		}
	} else {
		if (A < 2 * C) {
			std::cout << (2 * C * Y + A * (X - Y)) << std::endl;
		} else {
			std::cout << (2 * C * X) << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int solve(vector<string> grid, int sy, int sx, int k)
{
    int h = grid.size();
    int w = grid[0].size();
    grid[sy][sx] = ' ';

    int base = 1;
    int ans = 0;
    for(;;){
        for(int x=0; x<w; ++x){
            int y2 = h-1;
            for(int y=h-1; y>=0; --y){
                if(grid[y][x] != ' '){
                    swap(grid[y][x], grid[y2][x]);
                    -- y2;
                }
            }
        }

        bool isChange = false;
        for(int y=0; y<h; ++y){
            int cnt = 1;
            for(int x=1; x<=w; ++x){
                if(x < w && grid[y][x] == grid[y][x-1]){
                    ++ cnt;
                }
                else{
                    if(cnt >= k && grid[y][x-1] != ' '){
                        for(int i=0; i<cnt; ++i){
                            ans += base * (grid[y][x-1-i] - '0');
                            grid[y][x-1-i] = ' ';
                        }
                        isChange = true;
                    }
                    cnt = 1;
                }
            }
        }
        base *= 2;

        if(!isChange)
            return ans;
    }
}

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> grid(h);
    for(int y=0; y<h; ++y)
        cin >> grid[y];

    int ans = 0;
    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            ans = max(ans, solve(grid, y, x, k));
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
S = int(input())

X = 0
Y = 0

MAX = 10**9

x1, y1, x2, y2, x3, y3 = (0, 0, MAX, 1, 0, 0)

# S = x2 * y3 - x3 * y2
# S = 10**9 * y3 - x3 * 1

x3 = (MAX - S) % MAX
y3 = (S - 1) // MAX + 1

print("{} {} {} {} {} {}".format(x1, y1, x2, y2, x3, y3))


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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		double x[n],y[n];
		double d;
		cin>>d;
		int ct = 0;
		for(int i=0;i<n;++i)
		{
			cin>>x[i]>>y[i];
			double temp = sqrtl(x[i]*x[i]+y[i]*y[i]);
			if(temp<=d)
			++ct;
		}
		cout<<ct<<"\n";		
    }
    return 0;
}


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

int performanceCheck(int a, int b)
{
    int performance = 0;
    performance = b * 2 - a;
    return performance;
}

int main(int argc, char *argv[])
{
    int R = 0;
    do
    {
        scanf("%d", &R);
    } while (R < 0 || 4500 < R);

    int G = 0;
    do
    {
        scanf("%d", &G);
    } while (G < 0 || 4500 < G);

    printf("%d\n", performanceCheck(R, G));
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y){
    int c[N + 1][N + 1];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X; //X[0]に空白を挿入
    Y = ' ' + Y; //X[0]に空白を挿入
    for(int i = 0; i <= m; i++) c[i][0] = 0;
    for(int j = 0; j <= m; j++) c[0][j] = 0;


    for(int i = 1; i <= m; i++){
        for( int j = 1; j <= n; j++){
            if(X[i] ==  Y[j]){
                c[i][j] = c[i-1][j-1] + 1;
            }else{
                c[i][j] = max(c[i-1][j], c[i][j-1]);
            }
            maxl = max(maxl, c[i][j]);
        }
    }

    return maxl;
}

int main(){
    string s1, s2;
    int n; cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }
    return 0;
}


Measured memory_bytes: 7052
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

int dp[100005];

int main() {
  int n;
  cin >> n;
  vi h(n);
  rep(i, n) cin >> h[i];
  rep(i, 100005) dp[i] = INF;
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 3984
#include<iostream>
#include<limits>

using namespace std;

int main()
{
  // space: 3n
  // time:  3 traversals
  ios::sync_with_stdio(false);
  int n; cin>>n;
  int R[n]; for (int i = 0; i < n; ++i) cin >> R[i];

  // m[i] stores min_j<=i R[j]
  // M[i] stores max_j>=i R[j]
  int m[n], M[n];
  int lowest=R[0], largest=R[n-1];

  for (int i=0; i<n; ++i) {
    if (R[i] < lowest) lowest = R[i];
    m[i] = lowest;
  }
  for (int i=n-1; i>=0; --i) {
    if (R[i] > largest) largest = R[i];
    M[i] = largest;
  }

  int diff = numeric_limits<int>::min();
  for (int i = 0; i<n-1; ++i) {
    if (M[i+1] - m[i] > diff) diff = M[i+1] - m[i];
  }

  cout << diff << endl;
}


Measured memory_bytes: 5548
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())


aa = (a-1) % 10
bb = (b-1) % 10
cc = (c-1) % 10
dd = (d-1) % 10
ee = (e-1) % 10

i = min([aa,bb,cc,dd,ee]) + 1

t = 0
if a % 10 == 0:
  t += a
else:
  t += a + 10 - (a % 10)
if b % 10 == 0:
  t += b
else:
  t += b + 10 - (b % 10)
if c % 10 == 0:
  t += c
else:
  t += c + 10 - (c % 10)
if d % 10 == 0:
  t += d
else:
  t += d + 10 - (d % 10)
if e % 10 == 0:
  t += e
else:
  t += e + 10 - (e % 10)
t -= 10
t += i
print(t)

Measured memory_bytes: 3064
H, M = map(int,input().split())
l = [H, M]

max = max(l)
min = min(l)

if min == 1:
  N = 1
  
else:
  if max == min:
    if max % 2 == 0:
      N = (H * M) / 2
    else:
      N = (((H * M) - 1)/2)+1

  else:
    r = max - min
    r2 = max - r
    r3 = r * min
    if r2 % 2 == 0:
      n1 = (r2 * r2) / 2
    else:
      n1 = (((r2 * r2) - 1)/2)+1
 
    if r3 % 2 == 0:
      n2 = r3 / 2
    else:
      n2 = (r3 - 1) / 2

    N = n1 + n2
    
print(int(N))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int main(){
    int h,w;
    cin>>h>>w;
    char s[55][55];
    rep(i,0,h){
        scanf("%s",&s[i]);
    }
    int num[55][55]={0};
    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j]=='#')
            cout<<"#";
            else{
                int x[8]={-1,-1,-1,0,0,1,1,1};
                int y[8]={-1,0,1,-1,1,-1,0,1};
                int t=0;
                rep(k,0,8){
                    if(i+x[k]<h&&i+x[k]>=0&&j+y[k]>=0&&j+y[k]<w)
                    if(s[i+x[k]][j+y[k]]=='#') t++;
                }
                cout<<t;
            }
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll x, a, b;
  cin >> x >> a >> b;
  ll ans = x;
  ans -= a;
  while(ans - b >= 0) ans -= b;
  cout << ans << endl;
  return 0;
}


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

namespace cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var pg = new Program();
            pg.Execute();

        }

        private void Execute()
        {
            var N = ReadLineLong;
            var input = ReadLinesLongList;
            var sequence = Enumerable.Repeat(0, (int)N).ToList();
            foreach (var i in input)
            {
                sequence[(int)i-1]++;
            }
            foreach (var i in sequence)
            {
                Console.WriteLine(i);
            }
        }

        private void OutputResult<Type>(Type result)
        {
            Console.WriteLine(result);
        }

        static long ReadLineLong => long.Parse(Console.ReadLine());
        static string ReadLineString => Console.ReadLine();
        static IEnumerable<long> ReadLinesLongList => Console.ReadLine().Split(' ').Select(i => long.Parse(i));
        static IEnumerable<string> ReadLinesStringList => Console.ReadLine().Split(' ');

        public static int Gcd(int a, int b) {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }

    }
}


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

int main(){
  	int N, ave, res=0;
  	double sum=0;
  	cin >> N;
  	vector<double> X(N);
  	
  	for(int i=0; i<N; i++){
    	cin >> X[i];
      	sum+=X[i];
    }
  	
  	ave = (int)round(sum/N);
  	
  	for(int i=0; i<N; i++){
    	res+=(X[i]-ave)*(X[i]-ave);
    }
  	cout << res << endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  long long int n,W,w[110],v[110],i,j,dp[110][100010],ans;
  const int INF=(1<<30);
  scanf("%d %d\n",&n,&W);
  for(i=1;i<=n;i++){
    scanf("%d %d\n",&w[i],&v[i]);
  }
  for(i=0;i<=100005;i++){
    dp[0][i]=INF;
  }
  dp[0][0]=0;
  for(i=1;i<=n;i++){
    for(j=0;j<=100005;j++){
      if(j-v[i]>=0){
        if(dp[i-1][j]>dp[i-1][j-v[i]]+w[i]){
          dp[i][j]=dp[i-1][j-v[i]]+w[i];
        }
        else{
          dp[i][j]=dp[i-1][j];
        }
      }
      else{
        dp[i][j]=dp[i-1][j];
      }
    }
  }
  for(i=0;i<=100005;i++){
    if(dp[n][i]<=W){
      ans=i;
    }
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 81024
#include <bits/stdc++.h>
using namespace std;
#define ll              long long int
#define vi              vector< int >
#define vll             vector< ll >
#define vc              vector< char >
#define vs              vector< string >
#define pb              push_back
#define all(v)          v.begin(), v.end()
#define PI              acos(-1.0)  // 3.1415926535897932
#define yes             cout << "yes" << endl
#define no              cout << "no" << endl
#define YES             cout << "YES" << endl
#define NO              cout << "NO" << endl
#define EPS             1e-9
#define INF             (1<<30)
#define MOD             10007
#define SIZ             1005

int main()
{
    ll a, b, h;
    cin >> a;
    cin >> b;
    cin >> h;
    cout << (h*(a+b)*1/2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int num[20020020];

int main(){
    fast_io
    
    int n, m;
    cin>>n>>m;
    int A[m];
    int sum=0;
    rep(i,m) {
        cin>>A[i];
        sum+=A[i];
    }
    if(n<sum){
        cout<<-1<<endl;
        return 0;
    }
    cout<<n-sum<<endl;



    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int pre[104];
int main()
{
       string s;
       cin>>s;
       int t=0;
       for(int i=0;i<s.size();i++){
        if(s[i]=='o')
            t++;
       }
       cout<<(700+t*100);
    return 0;
   }

Measured memory_bytes: 3580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var line = Console.ReadLine().Trim().Split(' ');
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < N; i++)
            {
                sb.Append(line[0][i]);
                sb.Append(line[1][i]);
            }
            Console.WriteLine(sb.ToString());
        }
    }
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    ll cnt=1;
    ll shift=1;
    while(n>=shift){
        cnt++;
        shift*=k;
    }
    cout << cnt-1 << endl;
}

Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define en '\n'
#define rep(i,n)    for(ll i=0; i<n; i++)
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(1);
#define yes cout<<"YES"<<'\n'
#define no cout<<"NO"<<'\n'
using namespace std;

int main()
{
    godspeed
    string s;
    cin>>s;
    if(s.length()==3)
        swap(s[0],s[2]);
         return cout<<s<<endl,0;

    return 0;
}





Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int h, n;
    cin >> h >> n;
    int a = 0;
    rep(i, n)
    {
        int t;
        cin >> t;
        a += t;
    }
    if (a >= h)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        private Vertex[] g;
        private int n;
        private boolean[] used;
        private long[] values;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            int q = in.nextInt();
            g = new Vertex[n];
            used = new boolean[n];
            values = new long[n];
            for (int i = 0; i < n; i++)
                g[i] = new Vertex(0);
            for (int i = 1; i < n; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;
                g[a].s.add(b);
                g[b].s.add(a);
            }
            for (; q > 0; q--) {
                int p = in.nextInt() - 1;
                long inc = in.nextInt();
                g[p].val += inc;
            }
            dfs(0, 0);
            for (long v : values)
                out.print(v + " ");
        }

        private void dfs(int v, long inc) {
            used[v] = true;
            values[v] = g[v].val + inc;
            for (int to : g[v].s) {
                if (!used[to]) {
                    inc += g[v].val;
                    dfs(to, inc);
                    inc -= g[v].val;
                }
            }
        }

        private class Vertex {
            private ArrayList<Integer> s;
            private long val;

            public Vertex(long val) {
                s = new ArrayList<>();
                this.val = val;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 166900
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    b = in_nl()

    ans = []
    while True:
        ind = -1
        for i in range(len(b)):
            if i+1 == b[i]:
                ind = i
        if ind != -1:
            b.pop(ind)
            ans.append(ind+1)
            if len(b) == 0:
                break
        else:
            break

    if len(b) == 0:    
        print('\n'.join(map(str, (ans[::-1]))))
    else:
        print(-1)





if __name__ == '__main__':
    main()


Measured memory_bytes: 9220
#include<stdio.h>
int main(){
	int d[1002]={0};
	int n,m,i,j,k,max;
	for(;scanf("%d %d",&n,&m)&&(n||m);){
		for(i=0;i<1002;i++)d[i]=0;
		max=n;
		for(i=1,j=0,k=1;1;i++){
			if(i>n)i=1;
			if(d[i]==0)j++;
			if(j==m){
				d[i]=-1;
				j=0;
				max--;
			}
			if(max==1)break;
		}
		for(i=1;i<=n;i++){
			if(!d[i])printf("%d\n",i,d[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 0