akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

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

// value
int A, B;

void solve() {

	cin >> A >> B;

	if (A <= 8 && B <= 8) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

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

int main(){
  int N,T,A,H,ansh=1000000000,i,temp,ansl=0;
  cin>>N>>T>>A;
  T=T*1000; A=A*1000;//-60000
  for(i=0;i<N;i++){
  	cin>>H;
    temp=T-H*6-A;
    if(temp<0)temp=-temp;
    if(ansh>temp){
      ansh=temp;
      ansl=i+1;
    }
  }
  cout<<ansl<<endl;
}

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

const int MAX_N = 50;
const int MAX_M = 50;

int main() {
  int N, M;
  char A[MAX_N][MAX_N], B[MAX_M][MAX_M];
  bool ok = false;
  cin >> N >> M;
  for (int i=0; i<N; i++){
    for (int j=0; j<N; j++){
      cin >> A[i][j];
    }
  }
  for (int i=0; i<M; i++){
    for (int j=0; j<M; j++){
      cin >> B[i][j];
    }
  }

  for (int i=0; i<=N-M; i++) {
    for (int j=0; j<=N-M; j++) {
      bool flag = true;
      for (int p=0; p<M; p++) {
        for (int q=0; q<M; q++) {
          if (A[i+p][j+q] != B[p][q]) {
            flag = false;
          }
        }
      }
      if (flag) ok = true;
    }
  }

  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
 
def main():
     n,m=map(int,input().split())
     field=[[] for i in range(3*n)]
     for i in range(m):
          x,y=map(int,input().split())
          x,y=x-1,y-1
          field[3*x].append(3*y+1)
          field[3*x+1].append(3*y+2)
          field[3*x+2].append(3*y)
     
     s,t=map(int,input().split())
     s,t=s-1,t-1
     s,t=3*s,3*t
     
     d=[float('inf') for i in range(3*n)]
     d[s]=0
     
     que=[s]
     cnt=0
     while que!=[]:
          que2=[]
          cnt+=1
          for i in que:
               for j in field[i]:
                    if d[j]>cnt:
                         d[j]=cnt
                         que2.append(j)
          que=que2
     if d[t]==float('inf'):
          print(-1)
     else:
          print(d[t]//3)
     return 
 
if __name__ == '__main__':
    main()

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

long long unsigned int cost(std::vector<int>& A, int p) {
  int res{0};
  for (auto&& v : A) res += std::pow((v - p), 2);
  return res;
}

int main() {
  int N;
  std::cin >> N;
  std::vector<int> X(N);
  for (int i = 0; i < N; i++) std::cin >> X[i];

  long long unsigned int minc{1000000000000000000};
  for (int p = 0; p <= 101; p++) {
    long long unsigned int c{cost(X, p)};
    minc = (c < minc ? c : minc);
  }
  std::cout << minc << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int n,k;
  cin>>n>>k;
  int j = 1;
  for(int i = 0;i < n;i++){
    if(j * 2 < j + k){
      j = j * 2;
      continue;
    }
    j += k;
  }
  cout<<j<<endl;
  }

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

using namespace std;

void Main();
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

void Main(){
    auto& fin = cin;
int64_t n, m;
fin >> n >> m;
vector<int64_t> a(n);
multiset<int64_t> a_set;
for(int64_t i=0; i < a.size(); i++){
    fin >> a[i];
    a_set.insert(a[i]);
}

for(int64_t i=0; i<m; i++){
    auto biggest = *prev(a_set.end());
    a_set.erase(prev(a_set.end()));
    a_set.insert(biggest / 2);
}



int64_t my_sum = 0;
for(const int64_t& val: a_set){
    my_sum += val;
}
cout << my_sum << endl;
}


Measured memory_bytes: 5760
s=input()
ans=[]
last="L"
start=[]
finish=[]
Rlong=[]
Llong=[]#start,finish,x(st),x(fin)

for i in range(len(s)):
    ans.append(0)
    if last==s[i]:
        if(last=="R"):
            Rlong[-1]=Rlong[-1]+1
            start[-1]=start[-1]+1
        else:
            Llong[-1]=Llong[-1]+1
    else:
        last=s[i]
        if(s[i]=="R"):
            start.append(i)
            Rlong.append(1)
        else:
            finish.append(i)
            Llong.append(1)

for i in range(len(Rlong)):
    ans[finish[i]]=(Rlong[i]//2)+(-1*Llong[i]//2)*-1
    ans[start[i]]=(-1*Rlong[i]//2)*-1+(Llong[i]//2)
for i in range(len(ans)):
    print(str(ans[i]),end="")
    if(i <len(ans)):
        print(" ",end="")

Measured memory_bytes: 10228
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string n;
    cin >> n;
    for (char &i : n)
    {
        if (i == '1')
            i = 9;
        else if (i == '9')
            i = 1;
    }
    int ans = n[0] * 100 + n[1] * 10 + n[2];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

int f(int b, int n){
  if(n<b)return n;
  else return f(b,n/b) + n%b;
}


signed main(void) {
  int i,j;
  int n,s;
  cin>>n>>s;
  if(n==s){
    cout<<n+1<<endl;
    return 0;
  }
  for(int b=2;b<=sqrt(n);b++){
    if(f(b,n)==s){
      cout<<b<<endl;
      return 0;
    }
  }
  int ans=(ll)INF*INF,t;
  for(int q=1;q*q<n-s+q;q++) if((n-s)%q==0) {
      int b=(n-s)/q+1;
      int p=s-q;
      if(0<=p && p<b && q<b && n==p+b*q && s==p+q) ans=min(ans,b);
    }
  if(ans==(ll)INF*INF)
    cout<<-1<<endl;
  else
    cout<<ans<<endl;
}


Measured memory_bytes: 256
long M=1e9+7,D[1<<20],P[1<<20],s=5e8+4;
i,x,p;c[1<<20];
main(a){
	scanf("%*d");
	for(;i<1<<20;)D[i++]=1;
	for(;~scanf("%d",&a);){
		if(x^=a){
			D[x]=(D[x]+P[x]*(p-c[x]))%M;
			P[x]=(P[x]+D[x])%M;
			c[x]=p;
		}
		else p++,s=s*2%M;
	}
	for(;i--;)s+=P[i];
	printf("%d",x?D[x]:s%M);
}

Measured memory_bytes: 20608
program j01;
var t:array[0..100086]of longint;
    n,x,k,r,l,i,ans,tmp,c:longint;

procedure qsort(l,r:longint);
var i,j,x,y:longint;
begin
  i:=l;j:=r;x:=t[(i+j)div 2];
  repeat
    while t[i]<x do inc(i);
    while x<t[j] do dec(j);
    if i<=j then
    begin
      y:=t[i];t[i]:=t[j];t[j]:=y;
      inc(i);dec(j);
    end;
  until i>j;
  if i<r then qsort(i,r);
  if l<j then qsort(l,j);
end;

begin
  readln(n,c,k);
  for i:=1 to n do readln(t[i]);
  qsort(1,n);l:=1;
  inc(n);t[n]:=maxlongint;
  for i:=2 to n do
  begin
    while t[i]-t[l]>k do
    begin
      inc(ans);tmp:=c;
      while (l<=i-1)and(tmp>0) do
      begin
        inc(l);dec(tmp);
      end;
    end;
  end;
  writeln(ans);
end.


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var m = p[1];
		var k = new int[n];
		for(int i = 0; i < n; i++)
			k[i] = -1;
			
		for(int i = 0; i < m; i++)
		{
			p = Input().ToInt();
			if(k[p[0]-1] !=-1 && p[1] != k[p[0]-1])
			{
				Console.WriteLine(-1);
				return;
			}
			k[p[0]-1] = p[1];
		}
		
		if(n == 1)
		{
			int min = 99;
			for(int i = 0; i <= 9; i++)
			{
				min = Math.Min(min, i);
			}
			if(k[0] != -1)
				min = k[0];
			Console.WriteLine(min);
			return;
		}
		if(n == 2)
		{
			if(k[0]==0)
			{
				Console.WriteLine(-1);
				return;
				
			}
			if(k[0] == -1)
				k[0]=1;
			if(k[1] == -1)
				k[1]=0;
			Console.WriteLine("{0}{1}", k[0], k[1]);
			return;
		}
		if(n==3)
		{
			if(k[0]==0)
			{
				Console.WriteLine(-1);
				return;
			}
			if(k[0] == -1)
				k[0]=1;
			if(k[1] == -1)
				k[1]=0;
			if(k[2] == -1)
				k[2]=0;
			Console.WriteLine("{0}{1}{2}", k[0], k[1], k[2]);
			return;
		}
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


Measured memory_bytes: 13140
N, M, Q = map(int, input().split())

L = []
for i in range(1, 11):
    for j in range(i, 11):
        for k in range(j, 11):
            for l in range(k, 11):
                for m in range(l, 11):
                    for n in range(m, 11):
                        for p in range(n, 11):
                            for q in range(p, 11):
                                for r in range(q, 11):
                                    for s in range(r, 11):
                                        L.append([i, j, k, l, m, n, p, q, r, s])
mm = 0
X = [list(map(int, input().split())) for _ in range(Q)]
for i in L:
    if i[N-1] <= M:
        S = i[:]
        SS = 0
        for j in X:
            if S[j[1]-1] - S[j[0]-1] == j[2]:
                SS += j[3]
        if mm < SS:
            mm = SS
print(mm)

Measured memory_bytes: 23060
n,x = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(2*a[i]+3)
  p.append(2*p[i]+1)

def f(N,X):
  if N==0:
    return 0 if X<=0 else 1
  elif X <= 1+a[N-1]:
    return f(N-1,X-1)
  else:
    return p[N-1]+1+f(N-1,X-2-a[N-1])
print(f(n,x))

  

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>

#define DEBUG 0
#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define SIZE 510

using namespace std;


int main(){

	int *a;
	int n;
	cin>>n;
	a = new int [n];

	REP(i,n)cin>>a[i];
	int cnt = 0;

	while(1){
		//まず始点を決定する。
		int start = -1;
		for(int i=0;i<n;i++){
			if(a[i] != 0){
				start = i;
				break;
			}
		}
		if(start == -1)break;
		int end = -1;
		int min = a[start];
		for(end = start+1;end<n;end++){
			if(a[end] == 0){
				break;
			}
			else
			{
				if(min >=a[end])min = a[end];
			}
		}
		for(int i=start;i<end;i++){
			a[i] -= min;
		}
		if(DEBUG)REP(i,n)cout<<a[i]<<" ";
		if(DEBUG)cout<<endl;
		cnt += min;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		if (N > 999) {
			System.out.println("ABD");
		} else {
			System.out.println("ABC");
		}
	}
	
}

Measured memory_bytes: 20436
N = int(input().strip())
A = list(map(int, input().strip().split()))
B = [0] * N
M = []

for i in range(N, 0, -1):
  tmp = 0
  for j in range(N // i - 1):
    tmp += B[i * (j + 2) - 1]

  mod = tmp % 2
  if A[i - 1] == 0:
    if mod == 0:
      pass
    else:
      B[i - 1] = 1
      M.append(str(i))
  else:
    if mod == 0:
      B[i - 1] = 1
      M.append(str(i))
    else:
      pass

print(len(M))
if len(M) > 0:
  print(' '.join(M))

Measured memory_bytes: 17204
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define f first
#define s second
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define fast 
#define f first
#define s second
#define endl "\n"
#define pie 3.1415926535

int main(){
    long long n,k;
    cin >> n >> k;
    
    n= n+1;
    long long ans = 0;
   long long a[n+1];
    a[0] = n-1;
    ll j=1;
    ll i=n-2;
     while(j<n){
         a[j] = ((i + a[j-1])); 
         j++;
         i--;
     }   
        
    
    while(k<=n){
          ll mm = (a[k-1] + 1) - (k*(k-1)/2);
          ans = (ans + mm)%mod;
        k++;
    }
   cout << ans <<endl; 
}


Measured memory_bytes: 5188
import java.util.*;
public class Main {
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	// 整数の入力
	int n = sc.nextInt();
	int k = sc.nextInt();
	int p[] = new int[n];
	int p2[] = new int[n];
	for (int i = 0; i < n; i++) {
	  p[i] = sc.nextInt() + 1;
	}
	int max=p[0];
	p2[0]=p[0];
    for (int i = 1; i < n; i++) {
      if (i < k) {
      	p2[i]=p[i]+p2[i-1];
      }	else {
      	p2[i]=p[i]+p2[i-1]-p[i-k];
      }
      if (p2[i]>max) {
      	max=p2[i];
      }
    }
	System.out.println(max/2.0);
  }
}



Measured memory_bytes: 73332
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
   int a,b;
   cin >> a >> b;
   
   if (((a==0)&&(b>0))||((a>0)&&(b==0))){
       cout << a+b <<endl;
   }else if((a==0)&&(b<=0)){
       cout << a-b <<endl;
   }
   else if ((a==1||b==1)&&(a>0&&b>0)){
       cout << a+b <<endl;
   }else if(a<0&&b<0){
       cout << a*b <<endl;
   }else if (a>0&&b<0){
       cout << a-b << endl;
   }else if (a<0&&b>0){
       cout << b+a <<endl;
   }else{
       cout << a*b <<endl;
   }

   
}


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

int aa[100005];
int bb[100005];
#define INF 0x7fffffff;

int main() {
  int a,b,m,ans;
  int ma=INF;
  int mb=INF;
  cin >> a >> b >> m;
  for(int i=0; i<a; i++) {
    cin >> aa[i];
    ma = min(ma,aa[i]);
  }
  for(int i=0; i<b; i++) {
    cin >> bb[i];
    mb = min(mb,bb[i]);
  }
  ans = ma + mb;

  for(int i=0; i<m; i++) {
    int x , y , c;
    cin >> x >> y >> c;
    ans = min(ans , aa[x-1]+bb[y-1]-c);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
constexpr ll MOD = ll(1e9) + 7;

int main(void) {
	int h, a;
	cin >> h >> a;
	
	cout << (h + a - 1) / a << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using ll = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;};

const Int MAX = 202;
Int dp[5][MAX]={};
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n,m;
  cin>>n>>m;

  const Int MOD = 1e6;
  
  if(m==1){
    Int res=1;
    for(Int i=0;i<n;i++) res=res*2%MOD;
    cout<<res<<endl;
    return 0;
  }
  assert(m==2);
  
  auto add=[&](Int &a,Int b){a+=b;a%=MOD;};                             
  dp[2][0]=1;
  for(Int i=0;i<n;i++){
    add(dp[4][i+1],dp[0][i]);
    add(dp[0][i+1],dp[0][i]);

    add(dp[2][i+1],dp[1][i]);
    add(dp[1][i+1],dp[1][i]);

    add(dp[0][i+1],dp[2][i]);
    add(dp[2][i+1],dp[2][i]);
    add(dp[3][i+1],dp[2][i]);
    add(dp[4][i+1],dp[2][i]);

    add(dp[2][i+1],dp[3][i]);
    add(dp[3][i+1],dp[3][i]);
    add(dp[4][i+1],dp[3][i]);

    add(dp[1][i+1],dp[4][i]);
    add(dp[2][i+1],dp[4][i]);
    add(dp[3][i+1],dp[4][i]);
    add(dp[4][i+1],dp[4][i]);
  }
  
  Int ans=0;
  add(ans,dp[0][n]);
  add(ans,dp[2][n]);
  add(ans,dp[3][n]);
  add(ans,dp[4][n]);
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 3212
# B.py

S = str(input())
a_point = []
z_point = []

for i in range(len(S)):
    if S[i] == "A":
        a_point.append(i)
    if S[i] == "Z":
        z_point.append(i)

print(max(z_point)-min(a_point)+1)


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

int main() {
  int n, k, q, s;
  cin >> n >> k >> q;
  int a = k - q;
  vector<int> vec(n, a);
  for (int i = 0; i < q; i++) {
    cin >> s;
    vec.at(s - 1) ++;
  }
  for (int i = 0; i < n; i++) {
    if (vec.at(i) > 0)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int n=0;
    int a=0;
    int b=0;
    int c=0;
    int d=0;
    int allx=0;
    int amax=0;
    int ally=0;
    int amay=0;
    int x=0;
    int y=0;
    cin>>n>>a>>b>>c>>d;
    allx=n/a;
    amax=n%a;
    if(amax==0){
        x=allx*b;
    }else{
        x=(allx+1)*b;
    }
    ally=n/c;
    amay=n%c;
    if(amay==0){
        y=ally*d;
    }else{
        y=(ally+1)*d;
    }
    if(x<y){
        cout<<x<<endl;
    }else{
        cout<<y<<endl;
    }
        
}



Measured memory_bytes: 3120
// C - Reconciled?
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007

ll factorial_mod(ll n){//階乗％MOD
	ll ans = n;
	while(n>1) ans = ans * --n % MOD;
	return ans;
}

ll calc(ll N, ll M){
	if(abs(N - M) > 1) return 0;
	ll ans =  factorial_mod(N);
	if(N == M) ans = ans * ans % MOD * 2 % MOD;
	else ans = ans * factorial_mod(M) % MOD;
	return ans;
}

int main(){
	ll N,M; cin>>N>>M;
	cout<< calc(N, M) <<endl;
}

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

bool judge(vector<vector<bool>> &check){
  for(int i = 0; i < 3; i++){
    if(check.at(i).at(0) && check.at(i).at(1) && check.at(i).at(2)) return true;
    if(check.at(0).at(i) && check.at(1).at(i) && check.at(2).at(i)) return true;
  }
  if(check.at(0).at(0) && check.at(1).at(1) && check.at(2).at(2)) return true;
  if(check.at(2).at(0) && check.at(1).at(1) && check.at(0).at(2)) return true;
  return false;
}

int main(){
  vector<vector<int>> card(3,vector<int>(3));
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> card.at(i).at(j);
    }
  }
  
  vector<vector<bool>> check(3,vector<bool>(3));
  int N;
  cin >> N;
  for(int k = 0; k < N; k++){
    int b;
    cin >> b;
    for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){
        if(card.at(i).at(j) == b){
          check.at(i).at(j) = true;
        }
      }
    }
  }
  
  if(judge(check)){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
}

    
    

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    bool flg = true;
    REP(i, n)
    {
        int a;
        cin >> a;
        if (a % 2 == 0)
        {
            if (not(a % 3 == 0 or a % 5 == 0))
            {
                flg = false;
            }
        }
    }
    if (flg)
    {
        cout << "APPROVED" << endl;
    }
    else
    {
        cout << "DENIED" << endl;
    }
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <assert.h>

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define trace(x) cerr << #x << " = " << x << endl;



/////////////////////////////////////////////
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

///////////////////////////////////////////////////////////////////////
#define int long long
const int N = 5002;
vector<int> v[N];
bool vis[N];
int score[N];
int k;
int mx;
vector<int>tmp;
void dfs(int s , int cur, int k){

	if(k==0)
		return ;
	if(vis[s])
		return ;
	cur += score[s];
	tmp.push_back(score[s]);
	mx = max(mx , cur);
	--k;
	vis[s] = true;
	for(int it : v[s]){

		if(!vis[it])
			dfs(it , cur , k);
		else{

			int size = tmp.size();
			int can = k/size;
			if(can > 0){

				k -= can*size;
				k += size;
				--can;
			}
			cur*=(can+1);
			mx = max(mx , cur);
			int i = 0;
			while(k--){

				cur += tmp[i++];
				i%=size;
				mx = max(mx , cur);
			}
			k = 0;
			return ;
		}
	}
}
void solve(){

	int n;
	cin>>n>>k;
	mx = -1e15;
	for(int i = 1 ; i <= n ; ++i){

		int val;
		cin>>val;
		v[i].push_back(val);
	}
	for(int i = 1 ; i <= n ; ++i)
		cin>>score[i];

	for(int i = 1 ; i <= n ; ++i){

		memset(vis , false , sizeof vis);
		tmp.clear();
		dfs(i , 0 , k);
	}

	cout<<mx<<endl;

}
signed main(){
 
    fast;
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t ; ++i)
        solve();
}


Measured memory_bytes: 4228
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define psvi pair<string,vi>
#define psi pair<string,int>
#define pss pair<string,string>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
#define vvi vector<vi>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd 
/****************************/
int a[3][3];
bool b[3][3];
int main()
{
	rep(i,3)
	{
		rep(j,3)
		{
			cin>>a[i][j];
		}
	}
	int n;
	cin>>n;
	memset(b,false,sizeof(b));
	rep(i,n)
	{
		int m;
		cin>>m;
		rep(j,3)
		{
			rep(k,3)
			{
				if(a[j][k]==m)
				{
					b[j][k]=true;
				}
			}
		}
	}
	rep(i,3)
	{
		bool is=true;
		rep(j,3)
		{
			is=is&&b[i][j];
		}
		if(is)
		{
			cout<<"Yes";
			return 0;
		}
	}
	rep(i,3)
	{
		bool is=true;
		rep(j,3)
		{
			is=is&&b[j][i];
		}
		if(is)
		{
			cout<<"Yes";
			return 0;
		}
	}
	if(1&&b[0][0]&&b[1][1]&&b[2][2]||1&&b[2][0]&&b[1][1]&&b[2][0])
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

const int mod = 1e9 + 7;

int sum(long long left, long long right){
  long long ret = (right+left) * (right-left+1) / 2;
  return ret;
}

int N;
int H, W;

void print_table(vector<int> vect){

  int h = 0;
  int w = 0;

  int field[H][W];

  // insert
  rep(i, N){
    int grid = vect[i];
    rep(j, grid){
      // insert
      field[h][w] = i+1;
      // move
      if(w==0 && h%2==1){
        h++;
      }else if(w==W-1 && h%2==0){
        h++;
      }else if(h%2==0){
        w++;
      }else if(h%2==1){
        w--;
      }
    }
  }

  // draw
  rep(i, H){
    rep(j, W){
      if(j!=0) cout << " ";
      cout << field[i][j];
    }
    cout << endl;
  }
}

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

  cin >> H >> W;
  cin >> N;

  vector<int> vect;

  rep(i, N){
    int tmp;
    cin >> tmp;
    vect.push_back(tmp);
  }

  print_table(vect);
}


Measured memory_bytes: 640
template<bool r>class Range{struct It{int it;explicit constexpr It(int it_):it(it_){}int operator*(){return it;}bool operator!=(It& a){return it!=a.it;}void operator++(){r?--it:++it;}};const It i,n;public:explicit constexpr Range(int i,int n):i(i),n(n){}Range<true> rev(){return Range<true>(n.it-1, i.it-1);};const It&begin(){return i;}const It&end(){return n;}};
inline Range<false> in(int n) { return Range<false>(0, n);}
inline Range<false> in(int i, int n) { return Range<false>(i, n);}
#include <bits/stdc++.h>
using namespace std;
template<class T> T num_in() { T x; cin >> x; return x;}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n = num_in<int>();
    vector<vector<int>> adj(n);
    for (int _ : in(n - 1)) {
        int a = num_in<int>() - 1, b = num_in<int>() - 1;
        adj[a].emplace_back(b);
        adj[b].emplace_back(a);
    }
    const int LOGN = 18;
    function<int(int, int)> dfs = [&](int cur, int par)-> int {
        vector<int> count(LOGN);
        for (int nxt : adj[cur]) {
            if (nxt == par) continue;
            int ret = dfs(nxt, cur);
            for (int i : in(LOGN))
                if ((ret & (1 << i)) != 0)
                    count[i] += 1;
        }
        int lower = [&]()-> int {
            for (int i : in(LOGN).rev()) {
                if (count[i] >= 2) {
                    for (int j : in(i, LOGN)) 
                        if (count[j] == 0)
                            return j;
                }
            }
            for (int i : in(LOGN))
                if (count[i] == 0)
                    return i;
            assert(0);
        }();
        int res = 1 << lower;
        for (int i : in(lower + 1, LOGN))
            if (count[i] == 1)
                res |= 1 << i;
        return res;
    };
    int val = dfs(0, -1);
    cout << 31 - __builtin_clz(val) << endl;
}


Measured memory_bytes: 17152
//
//  main.cpp
//  ABC162F
#include <iostream>
#include <vector>
#include <algorithm>
//#include<cassert> // combinationを使う時
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
ll a[200005]={};
ll dp[100005][2]={};
ll dp2[100005][2][2]={};
int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    rep(i,n) cin>>a[i];
    dp[0][0]=a[0]; // i:グループ番号 j:0:左 1:右
    dp[0][1]=a[1];
    dp2[0][0][0]=a[0];
    dp2[0][1][0]=a[1];
    dp2[1][0][1]=a[2];
    dp2[1][1][1]=a[3];
    // 偶数個のとき　各グループからひとつずつ取る
    ll ans=0; // 偶数個のときの答え
    ll ans2=0; // 奇数個のときの答え候補
    if(n%2==0){
        for(int i=1;i<n/2;i++){
            dp[i][0]=dp[i-1][0]+a[2*i];
            dp[i][1]=max(dp[i-1][0],dp[i-1][1])+a[i*2+1];
        }
        ans=max(dp[n/2-1][0],dp[n/2-1][1]);
    } else{
        // 奇数個のとき　一番最後の数を使うなら、ひとつのグループを使わない
        // 一番最後の数を使わないなら、最後のグループまでで答えを作る
        for(int i=1;i<n/2;i++){
            dp2[i][0][0]=dp2[i-1][0][0]+a[2*i];
            dp2[i][1][0]=max(dp2[i-1][0][0],dp2[i-1][1][0])+a[i*2+1];
            if(i==1){
                dp2[1][0][1]=a[2];
                dp2[1][1][1]=a[3];
            }else{
                dp2[i][0][1]=max(max(dp2[i-2][0][0],dp2[i-2][1][0]),dp2[i-1][0][1])+a[i*2];
                dp2[i][1][1]=max(max(dp2[i-2][0][0],dp2[i-2][1][0]),
                                 max(dp2[i-1][0][1],dp2[i-1][1][1]))+a[i*2+1];
            }
        }
        if(n>=5){
            ans2=max(max(dp2[n/2-1][0][0],dp2[n/2-1][1][0]),dp2[n/2-1][0][1]+a[n-1]);
        }else{
            ans2=max(max(a[0],a[1]),a[2]);
        }
    }
    if(n%2==0){
        cout<<ans<<endl;
    } else{
        cout<<ans2<<endl;
    }
    //rep(i,n/2)rep(j,2)rep(k,2) cout<<"dp2["<<i<<"]["<<j<<"]["<<k<<"]="<<dp2[i][j][k]<<endl;
    return 0;
}


Measured memory_bytes: 7884
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect
from collections import defaultdict

def solve(data):
    is_unique = defaultdict(lambda: 0)
    times = [False] * (data[-1] + 3)
    for d in data:
        is_unique[d] += 1
        v = d * 2
        #print('v') # debug
        #print(v) # debug
        while v < len(times):
            times[v] = True
            v += d
    #print('times') # debug
    #print(times) # debug
    #print('is_unique') # debug
    #print(is_unique) # debug
    ans = 0
    for d in data:
        if is_unique[d] > 1:
            continue
        if times[d] == False:
            ans += 1
    return ans

if __name__ == '__main__':
    n = int(input())
    data = list(map(int, input().split()))
    data.sort()
    #print('data') # debug
    #print(data) # debug
    ans = solve(data)
    #print('ans') # debug
    print(ans)

    #print('\33[32m' + 'end' + '\033[0m') # debug


Measured memory_bytes: 123784
# ABC 123: B – Five Dishes
import math

dishes = [int(input()) for _ in range(5)]

last_dish_index = 0
from10 = 0

for i in range(len(dishes)):
    tmp = dishes[i] % 10
    if tmp != 0 and 10 - tmp > from10:
        last_dish_index = i
        from10 = 10 - tmp % 10

last_dish = dishes.pop(last_dish_index)
print(sum([math.ceil(t / 10) * 10 for t in dishes]) + last_dish)

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

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> h(n);
    rep(i, 0, n){
        cin >> h[i];
    }
    map<ll, vector<ll>> bridge;
    ll a, b;
    rep(i, 0, m){
        cin >> a >> b;
        bridge[b-1].push_back(a-1);
        bridge[a-1].push_back(b-1);
    } 
    ll good = 0;
    rep(i, 0, n){
        bool check = 1;
        if (bridge[i].size() == 0) check = 1;
        else{
            for (auto b:bridge[i]){
                if (h[i] <= h[b]) check = 0;
            }
        }
        if (check == 1) good ++;
    }
    cout << good << endl;
    return 0;
}

Measured memory_bytes: 15352
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int size = S.size();
    if (size % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    if (S.substr(0, size / 2) == S.substr(size / 2, size / 2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
n = int(input())
if 400 <= n <= 599:
    print(8)
elif 600 <= n <= 799:
    print(7)
elif 800 <= n <= 999:
    print(6)
elif 1000 <= n <= 1199:
    print(5)
elif 1200 <= n <= 1399:
    print(4)
elif 1400 <= n <= 1599:
    print(3)
elif 1600 <= n <= 1799:
    print(2)
elif 1800 <= n <= 1999:
    print(1)

Measured memory_bytes: 9184
def calc(a, n, k):
	if n == 1:
		return min(a*2, a+k)
	t = calc(a, n-1, k)
	return min(t*2, t+k)

def resolve():
	n, k = [int(input()) for _ in range(2)]
	print(calc(1, n, k))
resolve()

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

LL dp[3010][3010][4];
LL value[3010][3010];

int main(){
	int R, C, K;
	cin >> R >> C >> K;
	vector<int> r(K), c(K);
	vector<LL> v(K);
	rep(i,K) cin >> r[i] >> c[i] >> v[i];
	rep(i,K) r[i]--, c[i]--;
	rep(i,K) value[r[i]][c[i]]=v[i];
	dp[0][0][1]=value[0][0];
	rep(i,R){
		rep(j,C){
			rep(k,4){
				dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
				dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
				if(value[i+1][j]>0){
					dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][k]+value[i+1][j]);
				}
				if(value[i][j+1]>0 and k<3){
					dp[i][j+1][k+1]=max(dp[i][j+1][k+1],dp[i][j][k]+value[i][j+1]);
				}
			}
		}
	}
	LL ans=0;
	rep(i,4) ans=max(ans,dp[R-1][C-1][i]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 359140
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
string s="aeiou";

int main(){
	char c;
	cin>>c;
	bool f=false;
	REP(i,s.size()){
		if(c==s[i])f=true;
	}
	if(f){
		cout<<"vowel"<<endl;
	}else{
		cout<<"consonant"<<endl;
	}
}



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

const int N = (int)1e5 + 228;

using namespace std;

int n, a[N];

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	int mx = 0;
	for (int i = 1; i <= n; i++)
		mx = max(mx, a[i]);
	int cnt = 0;
	for (int i = 1; i <= n; i++)
	{
		if (a[i] != mx && a[i] != mx - 1)
		{
			cout << "No" << endl;
			return 0;
		}
		if (a[i] == mx - 1)
			cnt++;		
	}
	if (cnt == 0)
	{
		if (mx == n - 1)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	if (cnt == n - 1)
	{
		cout << "No" << endl;
		return 0;
	}
	if (cnt >= mx)
	{
		cout << "No" << endl;
		return 0;
	}
	mx -= cnt;
	if (n - cnt < mx * 2)
	{
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}



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

int m,n,field[90][90],ma = 0;
int dx[] = {0,1,0,-1},dy[] = {1,0,-1,0};

void dfs(int x,int y,int num){
	field[x][y] = 0;
	for(int i = 0;i < 4;i++){
		int nx = x + dx[i],ny = y + dy[i];
		if(nx >= 0 && nx < n && ny >= 0 && ny < m && field[nx][ny]) dfs(nx,ny,num + 1);
	}
	ma = max(ma,num);
	field[x][y] = 1;
}

int main(){
	while(1){
		cin >> m >> n;
		if(!m) break;
		ma = 0;
		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++){
				cin >> field[i][j];
			}
		}
		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++){
				if(field[i][j]) dfs(i,j,1);
			}
		}
		cout << ma << endl;
	}
	return 0;
}

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

using namespace std;

long long int n;

int main(){
    cin>>n;
    for(int i=sqrt(n);i>=1;i--)
    {
        if(n%i==0){
            int t=i,l=n/i;
            int s=1;
            while(l>=10){
                s++;
                l/=10;
            }
        cout<<s;
        return 0;
        }
    }
}

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

using namespace std;

// DP時の道具
template<class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		// aよりbの方が小さかったら、aの値をbの値に置き換える
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		// aよりbの方が大きかったら、aの値をbの値に置き換える
		a = b;
		return true;
	}
	return false;
}


int main() {
	const int INF = (1 << 30);
	int N;
	cin >> N;
	vector<vector<int>> h(N, vector<int>(3));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> h.at(i).at(j);
		}
	}

	// 初期化
	vector<vector<long>> dp(N+1, vector<long>(3, 0));
	
	// 更新
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) {
					continue;
				}
				chmax(dp.at(i+1).at(k), dp.at(i).at(j) + h.at(i).at(k));
			}
		}
	}

	//出力
	long res = 0;
	for (auto e : dp.at(N)) {
		chmax(res, e);
	}
	cout << res << endl;
}


Measured memory_bytes: 11136
#include<stdio.h>
#define MAX 100000
#define NOT -1


struct Node {int p, l, r;};
struct Node T[MAX];
int n,H[MAX],D[MAX];

void setDepth(int u,int d){
  if(u==NOT)return;
  D[u]=d;
  setDepth(T[u].l,d+1);
  setDepth(T[u].r,d+1);
}
int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].l!=NOT)h1=setHeight(T[u].l)+1;
  if(T[u].r!=NOT)h2=setHeight(T[u].r)+1;
  
  if(h1>h2){return H[u]=h1;}
  else{ return H[u]=h2;}
}

int getSibling(int u){
  if(T[u].p==NOT)return NOT;
  if(T[T[u].p].l!=u && T[T[u].p].l !=NOT)return T[T[u].p].l;
  if(T[T[u].p].r!=u && T[T[u].p].r !=NOT)return T[T[u].p].r;
  return NOT;
}

void print(int u){
    int deg=0;
  printf("node %d: ",u);  
  printf("parent = %d, ",T[u].p);
  printf("sibling = %d, ",getSibling(u));

  if(T[u].l !=NOT)deg++;
  if(T[u].r !=NOT)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].p==NOT) printf("root\n");//
  else if(T[u].l == NOT && T[u].r==NOT) printf("leaf\n");//
  else printf("internal node\n");//
    

}

int main(){
  int i,v,l,r,root=0;
  
  scanf("%d",&n);

  for(i=0;i<n;i++)T[i].p=NOT;

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NOT)T[l].p=v;
    if(r!=NOT)T[r].p=v;

  }
  for(i=0;i<n;i++)if(T[i].p==NOT)root=i;

  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++)print(i);
  
  return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n,m;
    cin>>n>>m;
    long a[m];

    long sum=0;
    for(int i=0;i<m;i++)
    {
    	cin>>a[i];
    	sum=sum+a[i];
    }

    if(sum<=n)
    	cout<<n-sum;
    else cout<<-1;
    
	return 0;
}

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

string weekday[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main(){
	string S;
	cin >> S;
	for(int i = 0; i<7;i++ ){
		if(S == weekday[i]){
			cout << 7-i << endl;
		}
	}
	return 0;
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


// Binary Indexed Tree
template <typename T>
class BIT {
    private:
        unsigned size_;
        std::vector<T> v;

        T sum(unsigned r) {
            T ret = 0;
            while (r > 0) {
                ret += v[r];
                r -= r & (-r);
            }
            return ret;
        }
    public:
        BIT() { }
        BIT(unsigned n) {
            for (size_=1; size_<n;) size_ <<= 1;
            v.resize(size_+1, 0);
        }
        inline void add(unsigned i, T x) {
            ++i;
            while (i <= size_) {
                v[i] += x;
                i += i & -i;
            }
        }
        inline T sum(unsigned l, unsigned r) { return sum(r) - sum(l); }
        bool operator[](unsigned x) { return sum(x, x+1); }
};

int main()
{
    int n, q;
    cin >> n >>q;
    BIT<int> Q(n);
    while(q--) {
        int c, x, y;
        cin >> c >> x >> y;
        if(c==0) Q.add(x-1, y);
        else cout << Q.sum(x-1, y) << endl;
    }
    return 0;
}

Measured memory_bytes: 3364
#include <iostream>
#include <cstdio>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vec vector
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n,m,ans,buf=0;
	string s = "Yes";

	cin >> n;

	vector<ll> a(n),b(n,0);

	forll(i, 0, n-1)
		cin >> a[i];

	forll(i, 0, n-1)
	{
		b[a[i]-1]++;
	}

	forll(i,0,n)
		cout << b[i] << "\n";
}

Measured memory_bytes: 6428
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int mod = 1000000007;
int binpow(int a, int b) {
	int ans = 1;
	while (b > 0) {
		if (b & 1) ans = 1LL * ans * a % mod;
		a = 1LL * a * a % mod;
		b >>= 1;
	}
	return ans;
}
int solve(int N, int K, vector<int> A) {
	int way = 1, ans = 0;
	for (int i = K - 1; i < N; ++i) {
		int sub = 1LL * way * ((A[i] >= 0 ? A[i] : mod - (-A[i]) % mod)) % mod;
		ans = (ans + sub) % mod;
		way = 1LL * way * (i + 1) % mod;
		way = 1LL * way * binpow(i - K + 2, mod - 2) % mod;
	}
	return ans;
}
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	int res1 = solve(N, K, A);
	reverse(A.begin(), A.end());
	int res2 = solve(N, K, A);
	cout << (res1 - res2 + mod) % mod << endl;
	return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    cin >> skipws;

    for (;;) {
        int n;
        cin >> n;
        if (!n)
            break;
        vector<int> v(n);
        rep(i, 0, n) cin >> v[i];
        sort(all(v));
        int ans = 0x3f3f3f3f;
        rep(i, 0, n - 1) ans = min(ans, v[i + 1] - v[i]);
        cout << ans << endl;
    }
}


Measured memory_bytes: 3160
tmp = gets.chomp.split.map(&:to_i)
w = tmp[0]
h = tmp[1]
x = tmp[2]
y = tmp[3]
r = tmp[4]

if w>=x+r && h>=y+r && 0<=y-r && 0<=x-r
  puts "Yes"
else
  puts "No"
end

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

int main() {
	// your code goes here
	int H,A,s=0;
	cin>>H>>A;
	vector<int>a(A);
	for(int i=0;i<A;i++){
		cin>>a[i];
		s += a[i];
	}
	if(s<H)cout<<"No";
	else cout<<"Yes";
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;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 llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main(){
	while(1){
		double n;
		cin >> n;
		if(n < 0.0) break;
		if(n >= 256.0){
			cout << "NA\n";
			continue;
		}
		for(int i = 0;i < 4;i++) n *= 2;
		int a = (int)n;
		if(n - a > 0.0){
			cout << "NA\n";
			continue;
		}
		bool ans[12] = {0};
		for(int i = 0;i < 12;i++){
			ans[11 - i] = (a % 2);
			a /= 2;
		}
		for(int i = 0;i < 8;i++) cout << ans[i];
		cout << '.';
		for(int i = 0;i < 4;i++) cout << ans[8 + i];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
  int n,h[101],i,j,max=0,min,sum=0;
  scanf("%d",&n);
  h[0]=0;
  for(i=1;i<n+1;i++){
    scanf("%d",&h[i]);
    sum+=(h[i]-h[i-1])*(h[i]>h[i-1]);
  }
  printf("%d",sum);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
	int ans=1,n,k;
	int i,j;
	
	cin>>n>>k;
	
	for(i=0;i<n;i++)
	{
		ans=min(2*ans,ans+k);
		
	}
	
	cout<<ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

//次の比率を超えるまで

int main(void){
    int N;
    cin >> N;
    ll t, a, sumt = 1, suma = 1;
    FOR(i, 0, N){
        cin>>t>>a;
        ll bai = max((sumt+t-1)/t, (suma+a-1)/a);
        if(bai<=1){
            sumt = t;
            suma = a;
        }
        else{
            sumt = t * bai;
            suma = a * bai;
        }
    }
    cout << sumt + suma << endl;
}

Measured memory_bytes: 256