akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, ans = 0;
   cin >> n;
   vector<int> a(n, 0);
   for (int i = 0; i < n; i++)
   {
      cin >> a[i];
      int tmp = a[i];
      int l = 0, r = 32;
      while (l + 1 < r)
      {
         int mid = (l + r) / 2;
         if (tmp % (int)pow(2, mid) == 0)
            l = mid;
         else
            r = mid;
      }
      ans += l;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 512
import math

A, B, H, M = map(int, input().split())
long_rad = math.radians(M * 6)
short_rad = math.radians(H * 30 + M / 60 * 30)
A_x, A_y = math.cos(short_rad) * A, math.sin(short_rad) * A
B_x, B_y = math.cos(long_rad) * B, math.sin(long_rad) * B
print(math.sqrt((A_x - B_x) ** 2 + (A_y - B_y) ** 2))

Measured memory_bytes: 62552
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
int a,b=0;
cin>>a;
string s;
for(int i=0;i<a;i++)
{
cin>>s;
if(s[0]=='Y')
b=1;}
if(b==1)
cout<<"Four";
else
cout<<"Three";
system("pause");
return 0;
}

Measured memory_bytes: 504
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string>
using namespace std;
typedef pair<int, int> P;
#define _CRT_SECURE_NO_WARNINGS
int N,M;
int a[200010],b[200010];
int main() {

	scanf("%d",&N);
	
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	sort(a, &a[N]);
	scanf("%d",&M);
	for (int i = 0; i<M; i++) {
		scanf("%d", &b[i]);
	}
	sort(b, &b[M]);
	int now = 0;
	for (int i = 0; i < M; i++) {
		while (1) {
			
			if (b[i]==a[now]) {
				now++;
				break;
			}
			else {
				now++;
			}
			if (now>=N) {
				printf("NO\n");
				return 0;
			}
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>

int parent(int);
int left(int);
int right(int);

int main(){
  int num,i,array[100001];
  scanf("%d",&num);

  for(i = 1;i <= num;i++){
    scanf("%d",&array[i]);
  }
  for(i = 1;i <= num;i++){
    printf("node %d: key = %d, ",i,array[i]);
    if(parent(i) >= 1){
      printf("parent key = %d, ",array[parent(i)]);
    }
    if(left(i) <= num){
      printf("left key = %d, ",array[left(i)]);
    }
    if(right(i) <= num){
      printf("right key = %d, ",array[right(i)]);
    }
    printf("\n");
}
return 0;
}

int parent(int i){
  return i / 2;
}
int left(int i){
  return 2 * i;
}
int right(int i){
  return 2 * i + 1;
}



Measured memory_bytes: 2112
#include<stdio.h>
int main ()
{
    int H,N,i,sum=0;
    int a;

    scanf("%d %d",&H,&N);

    for(i=0; i<N; i++)
    {
        scanf("%d",&a);
        sum = sum + a;
    }

    if(sum>=H)
    {
        printf("Yes\n");
    }

    else
    {
        printf("No\n");
    }

}

Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[][] points = new int[n+1][3];
		for(int i=1;i<=n;i++){
		    points[i][0] =scn.nextInt();
		    points[i][1] =scn.nextInt();
		    points[i][2] =scn.nextInt();
		}
		// System.out.println(maxHappiness(1,points,-1));
		int[][] memo = new int[n+1][3];
		System.out.println(maxHappiness_memoized(1,points,-1,memo));

	}


    public static int maxHappiness_memoized(int day, int[][] points , int activityOnPrevDay,int[][] memo) {
    		if(day==points.length)return 0;
      		if(activityOnPrevDay!=-1 && memo[day][activityOnPrevDay]!=0)return memo[day][activityOnPrevDay];
    		int ans = Integer.MIN_VALUE;
    		for (int i = 0; i < 3; i++) {
    			if (i != activityOnPrevDay) {
    				int ca = points[day][i] + maxHappiness_memoized(day + 1, points, i,memo);
    				ans = Math.max(ans, ca);
    			}
    		}
    		if(activityOnPrevDay!=-1)
    		    memo[day][activityOnPrevDay]=ans;
    		return ans;
    }
}


Measured memory_bytes: 69620
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

s = ins()
k = inn()
n = len(s)
cnt = 0
u = set([])
for i in range(26):
    c = chr(ord('a')+i)
    t = s
    while len(t)>0:
        j = t.find(c)
        if j<0:
            break
        for m in range(j+1,min(j+6,n+1)):
            #ddprint(f"j {j} m {m} tjm {t[j:m]}")
            u.add(t[j:m])
            cnt += 1
        t = t[j+1:]
    #if cnt>=k:
    if len(u)>=k:
        break
#print(u)
u = list(u)
u.sort()
print(u[k-1])


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

long long in(){
  long long i;
  cin >> i;
  return i;
}

int main(void){
  long long n;
  long long output = 1;
  cin >> n;

  long long min = in();
  
  for( long long i=0 ; i<n-1;i++){
    long long tmp = in();
    if(min>tmp){
      min = tmp;
      output++;
    } else {
    }
  }
  cout << output << endl;
  return 0;
  
}

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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()

typedef pair<int, int> P;

template<class T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T>
bool chmin(T &a, const T &b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

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

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	int w;
	cin >> w;
	
	string ans = "";
	REP(i, s.length()) {
		if (i % w == 0) {
			ans += s[i];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
def get_quad(n, p):
    if n < 19:
        return 13
    n = (n + 1) // 10 * 10 - 1
    for ni in range(n,0,-10):
        if p[ni] and p[ni - 2] and p[ni - 6] and p[ni - 8]:
            return ni
        
def sieve():
    n = 10000001
    p = [1] * n
    p[0] = p[1] = 0
    
    for i in range(int(n ** 0.5)):
        if p[i]:
            for j in range(2 * i, len(p), i):
                p[j] = 0
    return p

import sys
f = sys.stdin

prime = sieve()
while True:
    n = f.readline().strip()
    if not n.isdigit():
        continue
    n = int(n)
    if n == 0:
        break
    print(get_quad(n, prime))

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

const int N = 100;

void bubbleSort(int [], int);

void print(int [], int, int);

int main(){
	int n, a[N];
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	bubbleSort(a, n);
	return 0;
}

void bubbleSort(int a[], int n){
	int count = 0;
	bool flag = true;
	while(flag){
		flag = false;
		for(int j = n-1; j > 0; j--){
			if(a[j] < a[j-1]){
				swap(a[j], a[j-1]);
				++count;
				flag = true;
			}
		}
	}
	print(a, n, count);
}

void print(int a[], int n, int count){
	cout << a[0];
	for(int i = 1; i < n; i++)
		cout << ' ' << a[i];
	cout << endl << count << endl;
}


Measured memory_bytes: 3092
A,B = map(int, input().split())

A = A - 1
tmpA = 0
tmpB = 0

if A < 0:
    tmpA = 0
else:
    if A%4 == 0:
        tmpA = A
    elif A%4 == 1:
        tmpA = 1
    elif A%4 == 2:
        tmpA = A + 1
    else:
        tmpA = 0

if B < 0:
    tmpB = 0
else:
    if B%4 == 0:
        tmpB = B
    elif B%4 == 1:
        tmpB = 1
    elif B%4 == 2:
        tmpB = B + 1
    else:
        tmpB = 0


ans = tmpA ^ tmpB
print(ans)


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

int main()
{
    int N, a[200000], b[200000], max, cnt = 0, second;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a, a + N);
    max = a[N - 1];
    for(int i = N - 1; i >= 0; i--){
        if(a[i] == max){
            cnt++;
        }
        else if(a[i] != max){
            second = a[i];
            break;
        }
    }
    if(cnt >= 2){
        for(int i = 0; i < N; i++){
            cout << max << endl;
        }
    }
    else{
        for(int i = 0; i < N; i++){
            if(b[i] == max){
                cout << second << endl;
            }
            else{
                cout << max << endl;
            }
        }
    }
}

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

/*

there is at most k hole in the seq

and we can build all seq with the number of holes <= k

we have 1 seq with 0 holes

for a seq with i holes
we need select i holes from seq : C(n,i)
we need find all seq for n-i elements which sum is n
and every element is positive
it is C(n-1,n-i-1)

*/

const int MO=1e9+7;
const int M=2e5+5;

inline int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
inline int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=MO;
	return x;
}
inline int mul(int x,int y)
{
	return 1LL*x*y%MO;
}
inline void addv(int &x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
}
inline void subv(int &x,int y)
{
	x-=y;
	if(x<0) x+=MO;
}
inline void mulv(int &x,int y)
{
	x=1LL*x*y%MO;
}

int qp(int a,int n)
{
	int ans=1;
	while(n)
	{
		if(n&1) mulv(ans,a);
		mulv(a,a);
		n>>=1;
	}
	return ans;
}

int C(int n,int m)
{
	int ans=1,d=1;
	for(int i=n,j=1;j<=m;i--,j++)
	{
		mulv(ans,i);
		mulv(d,j);
	}
	return mul(ans,qp(d,MO-2));
}

int main()
{
	int n,a,b; 
	scanf("%d%d%d",&n,&a,&b);
	int ans=qp(2,n);
	subv(ans,1);
	subv(ans,C(n,a));
	subv(ans,C(n,b));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

//#define int long long
#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long


signed main() {
	int N, a;
	
	int no = 0, ne = 0;

	cin >> N;
	REP(i, N) {
		cin >> a;

		if (a % 2 == 0) ne++;
		else no++;
		
	}

	bool ans;

	if (no % 2 == 1) ans = 0;
	else ans = 1;
	//else if (ne % 2 == 1) ans = 0;
	//else {
	//	if ((no / 2 + ne / 2) % 2 == 1) ans = 0;
	//	else ans = 1;
	//}

	cout << (ans?"YES":"NO") << endl;
	return 0;
}

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

using LL = long long;
using LD = long double;
 
LL mod = 1e9+7;

int main()
{
	LL n;
	cin >> n;

	set<string> sset;

	for (LL i = 0; i < n; ++i) {
		string e;
		cin >> e;
		sset.insert(e);
	}

	cout << sset.size() << "\n";
}



Measured memory_bytes: 19260
s = input()
l = []
i = 0
n = len(s)
while i < n:
    j = 0
    while i < n and s[i] == 'B':
        j += 1
        i += 1
    l.append(j)

    j = 0
    while i < n and s[i] == 'W':
        j += 1
        i += 1
    l.append(j)
# print(l)
res = 0
for i in range(0, len(l), 2):
    if l[i] > 0:
        res += l[i] * l[i + 1]
    if i + 2 < len(l):
        l[i + 2] += l[i]
print(res)

Measured memory_bytes: 5852
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int K;
int A[200011];
int main(){
	cin>>K>>N;
	REP(i,N){
		cin>>A[i];
	}
	A[N]=A[0]+K;
	int ans=1e9;
	REP(i,N){
		ans=min(ans,K-(A[i+1]-A[i]));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

void insert(int);
void inorder(Node);
void preorder(Node);

Node root;

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL) {
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u != NIL) {
    inorder(u->left);
    printf(" %d",u->key);   
    inorder(u->right);
  }
}

void preorder(Node u){
  if(u != NIL) {
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}



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

//Author: Ashish

//dp[i][0] -> ways when the parent of i was black
//dp[i][1] -> ways when the parent of i was white

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;

	vector<vector<int>> graph(n,vector<int>());
	for(int i=1;i<n;i++) {
		int x,y;
		cin>>x>>y;
		--x;
		--y;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	const int mod = 1e9+7;

	function<pair<int,int>(int,int)> dp = [&](int node,int parent) {
		// {black,white}
		int black=1,white=1;
		for(auto&itr:graph[node]) {
			if(itr==parent) continue;
			pair<int,int> child = dp(itr,node);
			black*=child.second;
			white*=(child.first+child.second)%mod;
			black%=mod;
			white%=mod;
		}
		return make_pair(black,white);
	};
	pair<int,int> answer=dp(0,-1);
	cout<<(answer.first+answer.second)%mod;
	return 0;
}

Measured memory_bytes: 18488
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toInt() }

    var result = 0
    a.forEachIndexed { index, i ->
        if ((index + 1) % 2 == 1 && i % 2 == 1) {
            result++
        }
    }
    
    println(result)
}



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


int main()
{
	int N;
	cin>>N;
	vector<int> T(N);
	int sum=0;
	rep(i,N)
	{	
		cin>>T[i];
		sum+=T[i];
	}
	int M;
	cin>>M;
	rep(i,M)
	{
		int p,x;
		cin>>p>>x;
		p--;
		cout<<sum-T[p]+x<<endl;
	}
	return 0;
}


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

int main(){
  int A,B,K;
  cin>>A>>B>>K;
  vector<int> s;
  for(int i=100; i>0; --i){
    if(A%i==0 && B%i==0) s.push_back(i);
  }
  cout<<s.at(K-1)<<endl;
}


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

int main()
{
  int A;
  cin >> A;
  if (A==25) cout << "Christmas" << endl;
  else if (A==24) cout << "Christmas Eve" << endl;
  else if (A==23) cout << "Christmas Eve Eve" << endl;
  else if (A==22) cout << "Christmas Eve Eve Eve" << endl;
}


Measured memory_bytes: 256
#include <map>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	map<int, int> d;
	long long ans = 0;
	for (int i = 0; i < N; ++i) {
		int x;
		cin >> x;
		ans += d[i - x];
		++d[x + i];
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{

    vector<vector<int>> A(3, vector<int>(3));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> A.at(i).at(j);
            //           cout << i << j << A.at(i).at(j) << endl;
            //           cout << i << endl;
            //            cout << j << endl;
        }
    }
    int N;
    cin >> N;
    //    cout << N << endl;
    int tmp;
    for (int k = 0; k < N; k++)
    {
        cin >> tmp;
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                //              cout << i << endl;
                //            cout << j << endl;
                if (A.at(i).at(j) == tmp)
                {
                    A.at(i).at(j) = -1;
                }
            }
        }
    }
    for (int i = 0; i < 3; i++)
    {
        tmp = 0;

        for (int j = 0; j < 3; j++)
        {
            tmp = tmp + A.at(i).at(j);
        }
        if (tmp == -3)
        {
            cout << "Yes" << endl;
            exit(0);
        }
    }
    for (int j = 0; j < 3; j++)
    {
        tmp = 0;
        for (int i = 0; i < 3; i++)
        {
            tmp = tmp + A.at(i).at(j);
        }
        if (tmp == -3)
        {
            cout << "Yes" << endl;
            exit(0);
        }
    }
    tmp = A.at(0).at(0) + A.at(1).at(1) + A.at(2).at(2);
    if (tmp == -3)
    {
        cout << "Yes" << endl;
        exit(0);
    }
    tmp = A.at(0).at(2) + A.at(1).at(1) + A.at(2).at(0);
    if (tmp == -3)
    {
        cout << "Yes" << endl;
        exit(0);
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int a[501][501];
struct ans { int x, y, z, w; };
void out(ans t) {
	cout << t.x << " " << t.y << " " << t.z << " " << t.w << endl;
}
int main() {
	int h, w; cin >> h >> w;
	rep1(i, h) {
		rep1(j, w) {
			cin >> a[i][j];
		}
	}
	queue<ans> q;
	rep1(i, h) {
		if (i % 2) {
			rep1(j, w) {
				if (a[i][j] % 2) {
					if (j < w) {
						a[i][j + 1]++;
						q.push({ i,j,i,j + 1 });
					}
					else {
						if (i < h) {
							a[i + 1][j]++;
							q.push({ i,j,i + 1,j });
						}
					}
				}
			}
		}
		else {
			per1(j, w) {
				if (a[i][j] % 2) {
					if (j > 1) {
						a[i][j - 1]++;
						q.push({ i,j,i,j - 1 });
					}
					else {
						if (i < h) {
							a[i + 1][j]++;
							q.push({ i,j,i + 1,j });
						}
					}
				}
			}
		}
	}
	cout << q.size() << endl;
	while (!q.empty()) {
		ans nex = q.front(); q.pop(); out(nex);
	}
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k, s;
    cin >> k >> s;
    int ans=0;
    for(int i=0; i<=k; i++){
        for(int j=0; j<=k; j++){
            int z = s-i-j;
            if(0<=z && z<=k){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(LL i=(l);i<(r);i+=(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//1000000009,998244353 
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a, LL n, int m) { LL x = 1; for (a %= m; n; n /= 2)n & 1 ? x = x * a % m : 0, a = a * a % m; return x; }
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
typedef struct fac { LL n, exp; }F;
int fact(LL n,F*a){LL x,i,j,c=0;x=n;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c].exp=j-1;c++;}}if(x-1){a[c].n=x;a[c].exp=1;c++;}return (int)c;}
//snippet
#define N 1009

int main(){
  LL a,b; F c[N];
  scanf("%lld%lld",&a,&b);
  printf("%d",fact(gcd(a,b),c)+1);
}

Measured memory_bytes: 1744
import java.util.Scanner;


class Main {

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
     
        int W = scanner.nextInt();
        int H = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int r = scanner.nextInt();

        if (x - r < 0 || x + r > W || y - r < 0 || y + r > H) {
          System.out.println("No");
        } else {
          System.out.println("Yes");
        }
        
     
        scanner.close();
      }
    
}


Measured memory_bytes: 26412
import math as m
A,B,C=(float(x) for x in input().split())

a=m.ceil(C/A)

s=7*A+B
t=C//s
#sは1週間にもらえるコインの枚数
u=C-s*t
#uは端数
v=m.ceil(u/A)

if v<=7:
    b=7*t+v
    
else:
    b=7*t+7
    
if a>b:
    print(int(b))
else:
    print(int(a))


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

const int MOD = 1000000007;

int N, M;
map<int, int> exponent; // <Mの素因数, その個数>

void Factorize(int M) {
  int p = 2;
  while (p * p <= M) {
    if (M % p == 0) {
      exponent[p]++;
      M /= p;
    } else {
      p++;
    }
  }
  exponent[M]++;
}

int combination(int n, int r) {
  vector<vector<int>> v(n+1, vector<int>(r+1));
  for (int i = 0; i <= n; i++) {
    v[i][0] = 1;
    if (i <= r) v[i][i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= r; j++) {
      v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD;
    }
  }
  return v[n][r];
}

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

  if (M == 1) {
    cout << "1" << endl;
    return 0;
  }

  long long ans = 1;

  for (auto i = exponent.begin(); i != exponent.end(); i++) {
    int K = i->second;
    ans *= combination(N + K - 1, K);
    ans %= MOD;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using Graph = vector<vector<pair<int, int>>>;
vector<int> color;

void dfs(const Graph& G, pair<int, int> v, int col) {
  color[v.first] = 1 + ((v.second % 2) ^ (col - 1));
  for (auto& next_v : G[v.first]) {
    if (color[next_v.first]) continue;
    dfs(G, next_v, color[v.first]);
  }
}

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

  Graph G(n);
  rep(i, n - 1) {
    int u, v, w;
    cin >> u >> v >> w;
    G[u - 1].push_back(make_pair(v - 1, w));
    G[v - 1].push_back(make_pair(u - 1, w));
  }

  color.assign(n, 0);
  dfs(G, make_pair(0, 0), 1);
  rep(i, n) { cout << color[i] - 1 << endl; }
  return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    int X[104];
    int mX=INF,MX=-INF;
    cin >> N;
    REP(i,N){
        cin >> X[i];
        mX=min(mX,X[i]);
        MX=max(MX,X[i]);
    }
    int Ans=INF;
    for(int i=mX;i<=MX;i++){
        int num=0;
        REP(j,N){
            num+=(X[j]-i)*(X[j]-i);
        }
        Ans=min(Ans,num);
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
template<class T> bool chmin(T& a, const T& b){ if(a > b){ a = b; return 1; } return 0; }

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w, k, x1, y1, x2, y2;
    cin >> h >> w >> k >> x1 >> y1 >> x2 >> y2;
    x1--; y1--; x2--; y2--;
    vector<string> s(h);
    for(auto& i : s) cin >> i;
    auto cost = vector(h, vector(w, INF));
    queue<pair<int, int>> q;
    cost[x1][y1] = 0;
    q.emplace(x1, y1);
    while(q.size()){
        auto [x, y] = q.front();
        q.pop();
        const int c = cost[x][y];
        for(int d = 0; d < 4; d++){
            int x2 = x, y2 = y;
            for(int i = 0; i < k; i++){
                x2 += dx[d];
                y2 += dy[d];
                if(x2 < 0 || h <= x2 || y2 < 0 || w <= y2 || s[x2][y2] == '@' || cost[x2][y2] <= c) break;
                if(chmin(cost[x2][y2], c + 1)) q.emplace(x2, y2);
            }
        }
    }
    if(cost[x2][y2] == INF) cost[x2][y2] = -1;
    cout << cost[x2][y2] << endl;
}

Measured memory_bytes: 12188
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  int arr[n];
  fi(0, n) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  int max_smaller = 0;
  fi(0, n - 1) {
    int smaller = min(arr[i], arr[n - 1] - arr[i]);
    if(smaller > max_smaller) {
      max_smaller = smaller;
      ans = arr[i];
    }
  }

  cout << arr[n - 1] << " " << ans << endl;
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <functional>
#include <iostream>
#include <numeric>
#include <ctype.h>
#define SIZE 10005
 
using namespace std;
typedef long long int ll;
// typedef pair <int,int> P;
 
int pair[SIZE];
 
int main()
{
    char a,b,c,d;
    bool abMM,cdMM,check00;
    cin >> a >> b >> c >> d;
    abMM = (a=='0'&&b!='0')||(a=='1'&&(b=='1'||b=='2'));
    cdMM = (c=='0'&&d!='0')||(c=='1'&&(d=='1'||d=='2'));
    check00 = (a=='0'&&b=='0')||(c=='0'&&'d'==0);
    if (abMM && cdMM){
        cout << "AMBIGUOUS";
    }else if(abMM && !cdMM){
        cout << "MMYY";
    }else if(!abMM && cdMM){
        cout << "YYMM";
    }else{
        cout << "NA";
    }
    cout << '\n';
    return 0;
    
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  ll n, cnt[5] = {0};
  ll ans = 0;
  cin >> n;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s[0] == 'M') cnt[0]++;
    if (s[0] == 'A') cnt[1]++;
    if (s[0] == 'R') cnt[2]++;
    if (s[0] == 'C') cnt[3]++;
    if (s[0] == 'H') cnt[4]++;
  }
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 4; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += cnt[i] * cnt[j] * cnt[k];
      }
    }
  }

  cout << ans << endl;
}


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

using namespace std;

typedef complex<double> P;

P projection(P a,P b,P c)
{
    b-=a;c-=a;
    return a+b*real(c/b);
}

int main()
{
    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;

    int q;
    cin>>q;
    while(q--)
    {
        double x,y;
        cin>>x>>y;
        P p=projection(P(x1,y1),P(x2,y2),P(x,y));
        cout<<fixed<<setprecision(10)<<p.real()<<" "<<p.imag()<<endl;
    }

    return 0;
}



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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

#ifdef LOCAL
#define i64 "%lld"
#else
#define i64 "%I64d"
#endif

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

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

    ll a,b,c,res; cin >> a >> b >> c;
    if (a%2 == 0 || b%2 == 0 || c%2 == 0) res = 0;
    else res = min(min(a*b,b*c),c*a);
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

void solve(int p, int csum, vector<int> ns, int res=0LL) {
    if(p == 32) {
        cout << hex << res << endl;
    }
    else {
        int sum = accumulate(ns.begin(), ns.end(), 0LL) % (1LL << 32);
        if((sum >> p & 1) == (csum >> p & 1)) {
            solve(p+1, csum, ns, res);
        }
        else {
            res += (1LL << p);
            rep(i,0,8) ns[i] ^= (1LL << p);
            solve(p+1, csum, ns, res);
        }
    }
}

signed main() {
    int D; cin >> D;
    while(D--) {
        vector<int> ns(8);
        rep(i,0,8) scanf("%llx", &ns[i]);
        int csum; scanf("%llx", &csum);
        solve(0, csum, ns);
    }
    return 0;
}

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

int main(){
  int n, m, c, ans = 0;
  std::cin >> n >> m >> c;
  vector<int> A(m), B(m);
  for (int i = 0; i < m; i++) std::cin >> B[i];
  for (int i = 0; i < n; i++) {
    int val = c;
    for (int j = 0; j < m; j++) std::cin >> A[j];
    for (int j = 0; j < m; j++) val += A[j]*B[j];
    ans += (val > 0);

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


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

struct Edge {
    int to;
    int cost;
};

int n;
vector<Edge> es[10000];
vector<int> dp[10000];

int dfs(int i, int j) {
    if (dp[i][j] >= 0) return dp[i][j];
    dp[i][j] = es[i][j].cost;
    int u = es[i][j].to;
    for (int k=0; k<es[u].size(); k++) {
        if (es[u][k].to == i) continue;
        dp[i][j] = max(dp[i][j], dfs(u, k) + es[i][j].cost);
    }
    return dp[i][j];
}

int main() {
    scanf("%d", &n);
    for (int i=0; i<n-1; i++) {
        Edge e;
        int a, b;
        scanf("%d%d%d", &a, &b, &e.cost);
        e.to = b;
        es[a].push_back(e);
        dp[a].push_back(-1);
        e.to = a;
        es[b].push_back(e);
        dp[b].push_back(-1);
    }

    for (int i=0; i<n; i++) {
        for (int j=0; j<es[i].size(); j++) {
            if (dp[i][j] < 0) {
                dp[i][j] = dfs(i, j);
            }
        }
    }

    for (int i=0; i<n; i++) {
        int ans = 0;
        for (int j=0; j<dp[i].size(); j++) {
            ans = max(ans, dp[i][j]);
        }
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 3240
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner=new Scanner(System.in);
        int num=1;
        int x=1;
        while((x=scanner.nextInt()) != 0){
            System.out.println("Case "+num+": "+x);
            num++;
        }
    }
}


Measured memory_bytes: 41360
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    int i=1,ct=0;
    vector<int> ans{1};
    if(a==1 || b==1){
        cout << 1 << endl;
        return 0;
    }
    do{
        i++;
        if(a%i==0 && b%i==0){
            ct++;
            ans.push_back(i);
        }
    }while(i!=a && i!=b);
    cout <<  ans[ct-k+1] << 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 k = sc.nextInt();
		String s = sc.next();
		
		if(s.length() <= k) {
			System.out.println(s);
		}else {
			System.out.println(s.substring(0, k) + "...");
		}
		sc.close();
	}

}


Measured memory_bytes: 38560
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  set<int> se;
  for(int i = 0; i < n; i += 2){
    se.insert(a.at(i));
  }
  sort(ALL(a));
  int ans = 0;
  for(int i = 0; i < n; i += 2){
    if(se.find(a.at(i)) == se.end()) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5972
#include <bits/stdc++.h>
#define int long long
using namespace std;
using PII = pair<int, int>;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;


template<int Mod>
struct ModInt {
    int v;
    ModInt(): v(0){}
    template<typename T>
    explicit ModInt(T t) {
        v = t % Mod;
        if (v < 0) v += Mod;
    }

    ModInt pow(int k) {
        ModInt res(1), x(v);
        while(k) {
            if (k & 1) res *= x;
            x *= x;
            k >>= 1;
        }
        return res;
    }

    template<typename T>
    ModInt& operator=(T a) { v = a % Mod; if (v < 0) v += Mod; return *this; }
    ModInt inv() { return pow(Mod - 2); }
    ModInt& operator+=(ModInt a) { v += a.v; if (v >= Mod) v -= Mod; return *this; }
    ModInt& operator-=(ModInt a) { v += Mod - a.v; if (v >= Mod) v -= Mod; return *this; }
    ModInt& operator*=(ModInt a) { v = 1LL * v * a.v % Mod; return *this; }
    ModInt& operator/=(ModInt a) {assert(a.v != 0); return (*this) *= a.inv(); }
    ModInt operator+(ModInt a) const { return ModInt(v) += a; }
    ModInt operator-(ModInt a) const { return ModInt(v) -= a; }
    ModInt operator*(ModInt a) const { return ModInt(v) *= a; }
    ModInt operator/(ModInt a) const { return ModInt(v) /= a; }
    ModInt operator-() { return ModInt(-v); }
    bool operator==(const ModInt a) const { return v == a.v; }
    bool operator!=(const ModInt a) const { return v != a.v; }
    bool operator<(const ModInt a) const { return v < a.v; }

    friend std::ostream &operator<<(std::ostream &os, const ModInt &a) { return os << a.v; }
    friend std::istream &operator>>(std::istream &is, ModInt &a) {
        int val;
        is >> val;
        a = ModInt(val);
        return is;
    }
};

template<typename T>
struct Combination {
private:
    vector<T> fac, finv;
public:
    explicit Combination(int size): fac(size + 1), finv(size + 1) {
        fac[0] = 1;
        finv[0] = 1;
        for (int i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * T(i + 1);
            finv[i + 1] = finv[i] * T(i + 1).inv();
        }
    }

    T C(int n, int r) const {
        if (r < 0 || n < r) return T(0);
        return fac[n] * finv[r] * finv[n - r];
    }

    T P(int n, int r) const {
        if (r < 0 || n < r) return T(0);
        return fac[n] * finv[n - r];
    }

    T H(int n, int r) const {
        if (r < 0 || n < r) return T(0);
        return C(n + r - 1, r);
    }
};

using mint = ModInt<MOD>;

signed main() {
    double x, y;
    cin >> x >> y;
    double n = (-1.0 * x + 2.0 * y) / 3.0;
    double m = (2.0 * x - 1.0 * y) / 3.0;
    if (n - floor(n) != 0 || m - floor(m) != 0) {
        cout << 0 << "\n";
        return 0;
    }
    int ni = (int)floor(n);
    int mi = (int)floor(m);
    Combination<mint> c(1000000);
    cout << c.C(ni + mi, ni) << "\n";
}

Measured memory_bytes: 15872
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
using namespace std;

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


int main() {
	int n;
	cin >> n;
	int A[n];
	rep(i, n) cin >> A[i];

	int t = 0;
	rep(i, n) {
		t += A[i] - 1;
	}
	cout << t << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i, N, A[1000];
	int flag = 1;
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}
	for(i = 0; i < N; i++){
		if(A[i] % 2 != 0) A[i] = -1;
	}
	for(i = 0; i < N; i++){
		if(A[i] != -1 && A[i] % 3 != 0 && A[i] % 5 != 0) flag = 0;
	}
	if(flag == 1) printf("APPROVED");
	else printf("DENIED");
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;
ll mpow(ll a,ll b){ll r=1;a%=mod;while(b){r=r*((b%2)?a:1)%mod,a=a*a%mod,b>>=1;}return r;}



int main() {
	int n, k; cin >> n >> k;
	if (k == 1)cout << 0 << endl;
	else cout << n - k << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))

weight1 = w[0]
weight2 = sum(w[1:])
diff = abs(weight1 - weight2)

for i in range(1, n - 1):
    weight1 += w[i]
    weight2 -= w[i]
    diff = min(diff, abs(weight1 - weight2))

print(diff)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

import math

s = list(input())
q = int(input())

for i in range(q):
    n = list(input().split())
    if 'print' in n:
        for j in range(int(n[1]), int(n[2]) + 1):
            print(str(s[j]), end='')
        print()

    elif 'reverse' in n:
        for k in range(math.floor((int(n[2]) - int(n[1]) + 1) / 2)):
            s[int(n[1]) + k], s[int(n[2]) - k] = s[int(n[2]) - k], s[int(n[1]) + k]

    elif 'replace' in n:
        for l in range(int(n[1]), int(n[2]) + 1):
            s.pop(int(n[1]))

        count  = int(n[1])

        for m in list(n[3]):
            s.insert(count, m)
            count += 1



Measured memory_bytes: 5816
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
N,M=MAP()
H=LIST()
L=[[0] for i in range(N)]
for i in range(M):
  a,b=MAP()
  a-=1
  b-=1
  L[a].append(H[b])
  L[b].append(H[a])
ans=0
for i in range(N):
  if max(L[i])<H[i]:
    ans+=1
print(ans)

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

long s(long i) {
  int cnt = 0;
  while (i) {
    cnt += i % 10;
    i /= 10;
  }
  return cnt;
}

int main() {
  long a;
  cin >> a;
  if (a % s(a) == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<ll,P> PP;
int main() {
	int n; cin >> n;
	bitset<101> b; b[0] = 1;
	rep(i, 101) {
		b |= b << 4; b |= b << 7;
	}
	if (b[n])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
#毒入りのクッキーを何枚食べられるか（解毒何枚か）＋解毒のうち、おいしいのは何枚か
#cを食べきるかで場合分け　つまり、c3枚のためには、a+b2枚
if a+b+1 >= c: #cを食べきる=a,bにあまりが生じる。ただ、ｂは食べ尽くせる
    ans = b + c
else: #cを食べきれない＝a,bは食べきっている。cはa+b+1枚食べた
    eat_c = a + b + 1
    ans = b +eat_c
print(ans)

Measured memory_bytes: 2940
N = int(input())
s = ((N-1)**2)*3  + (N-1) * 3 + 1
p = 0
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
for i in range (N-1):
    for j in range(N-1):
        k = gcd((i+2), (j+2))
        for l in range (N-1):
            if k != 1:
                m = gcd(k, (l+2))
                p += m
            else:
                p +=1
            
print(p + s)

Measured memory_bytes: 9212
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class AFiveVariables {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      vector<int> a(5);
      rep(i, 5) {
        cin >> a[i];
        if (a[i] == 0) {
          cout << i+1 << '\n';
        }
      }

    }
};

signed main() {
  AFiveVariables solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3608