akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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

        long n = sc.nextLong();
        long m = 1;
        while(m * m <= n) m++;
        Set<Long> set = new HashSet<>();
        m--;
        if(n == 2) {
            System.out.println(1);
            return;
        }
        int res = 2;
        set.add(n);
        set.add(n-1);
        long p = n - 1;
        for(long i=2; i<=m; i++) {
            if(i * i == p) {
                set.add(i);
                res += 1;
            } else if (p % i == 0 && i < (p/i)) {
                set.add(i);
                set.add(p/i);
                res += 2;
            }
        }
        for(long i=2; i<=m; i++) {
            long num = n;
            while(num % i == 0) num /= i;
            if(num % i == 1) {
                res++;
                set.add(i);
            }
        }

        System.out.println(set.size());
    }

}

Measured memory_bytes: 24404
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	for i := 1; i < 10; i++ {
		for j := 1; j < 10; j++ {
			num := i * j
			if num == n {
				fmt.Println("Yes")
				return
			}
		}
	}

	fmt.Println("No")
}


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

using namespace std;

typedef long long ll;
const ll mx = 1000006;
ll sam[mx], pic[mx];

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

    vector<bool>s(200010, false);
    vector<bool>t(200010, false);

    for (ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;

        if(a == 1) {
            s[b] = true;
        }

        if(b == n) {
            t[a] = true;
        }
    }

    for (ll i = 0; i < 200010; i++) {
        if(s[i] && t[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

int main(void) {
    char str[5];
    gets(str);
    if(!strcmp(str,"Sunny")){
        printf("Cloudy");
    }
    if(!strcmp(str,"Cloudy")){
        printf("Rainy");
    }
    if(!strcmp(str,"Rainy")){
        printf("Sunny");
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<ll,int> P;

const ll MAX_N=131072;
int bit[MAX_N*2-1];
ll n;
int main(){
  string s;
  ll A,B;
  cin >>A>>s>>B;
  if(s=="+") cout <<A+B<<endl;
  else cout <<A-B<<endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <math.h>
using namespace std;
int main(){
    std::set<int> s;
    for(auto i=1;i<=9;i++){
        for(auto j=1;j<=9;j++){
            s.insert(i*j);
        }
    }
    int a;
    cin>>a;
    if(s.count(a)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
     int n,a[10001],i,j=0,count=0,e[10001];;
     cin>>n;
     for(i=0;i<n;i++){
         cin>>a[i];
     }
     for( i=0; i < n; i++){
         if(a[i] % 2 == 0 && a[i]%3 != 0 &&a[i] % 5 != 0){
             cout<<"DENIED"<<endl;
             return 0;
         }
     }
     cout<<"APPROVED"<<endl;
    return  0;
}


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


 
int main() 
{ 






int n ,x ,mx= -1;
scanf("%d",&n);
char s;
for(int i=0;i<=n;i++){
	scanf("%c",&s);
	if(s=='I'){
	x++;
	}
mx= max(x,mx);
	 if(s=='D'){
	x--;
	} }
printf("%d",mx);







}

Measured memory_bytes: 256
import math

def is_prime(x):
    if x == 2:
        return True

    if (x == 1) or (x % 2 == 0):
        return False

    for i in range(3, math.ceil(math.sqrt(x))+1, 2):
        if x % i == 0:
            return False

    return True
    
if __name__ == '__main__':
    element_number = int(input())
    input_array = [int(input()) for i in range(element_number)]

    output = 0
    for x in input_array:
        if(is_prime(x)):
            output += 1

    print(output)

Measured memory_bytes: 7884
#include<bits/stdc++.h>
using namespace std;
int i;
int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int j=0;j<n;j++) cin>>v[j];

    int ans=0;
    while(1){
        for(i=0;i<n;i++){
            if(v[i]%2 == 0) v[i] = v[i]/2;
            else break;
        }if(i != n) break;
        ans++;
    }
    cout<<ans<<endl; 
    }

    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,A[40001],B[40001];
 
int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++) cin>>A[i];
    for(int i=0;i<n;i++) cin>>B[i];
    sort(A,A+n,greater<int>());
    sort(B,B+n,greater<int>());
    int ans=0,idx=0,win=0;
    for(int i=0;i<n;i++){
      if(B[idx]>=A[i])idx++;
      else win++;
      ans=i+1;
      if((i+1)/2<win)break;
    }
    if(ans<n)cout<<ans<<endl;
    else cout<<"NA"<<endl;
     
  }
  return 0;
}

Measured memory_bytes: 3392
#include <iostream>
#include <string>
using namespace std;
int main(){
    string a;
    cin>>a;
    int c =0;
    
    if(a[0] == '1'){c++;}
    if(a[1] == '1'){c++;}
    if(a[2] == '1'){c++;}
   

    cout<< c <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define N 2000000

typedef long int lint;

int size;

void maxHeap(lint H[], int i, int n){
  lint left,right;
  lint largeVal;
  lint temp;
  
  left = i*2;
  right = i*2+1;

  if(left <= n && H[left] > H[i]){
    largeVal = left;
  }
  else{
    largeVal = i;
  }

  if(right <= n && H[right] > H[largeVal]){
    largeVal = right;
  }

  if(largeVal != i){
    temp = H[i];
    H[i] = H[largeVal];
    H[largeVal] = temp;

    maxHeap(H, largeVal, n);
  }
}

void buildMaxHeap(lint H[], int n){
  int i;
  for(i = n/2;i > 0;i--){
    maxHeap(H, i, n);
  }
}

void insert(lint H[], lint key){
  
  H[++size] = key;

  int i = size;
  int temp;
  
  while(i > 1 && H[i] > H[i/2]){
    temp = H[i];
    H[i] = H[i/2];
    H[i/2] = temp;
    i /= 2;
  }
}

void extractMax(lint H[]){
  if(size < 1){
    fprintf(stderr,"cannot extract.\n");
    return;
  }
  
  printf("%ld\n", H[1]);

  H[1] = H[size--];

  maxHeap(H, 1, size);
}

int main()
{
  int key;
  char order[10];

  lint H[N+1]={};
  
  while(1){
    scanf("%s",order);

    if(strcmp(order,"insert") == 0){
      scanf("%d",&key);
      insert(H, key);
    }
    else if(strcmp(order, "extract") == 0) extractMax(H);
    else if(strcmp(order, "end") == 0) break;
  }
  return 0;
}



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

int main(){
  int N,K;
  cin >> N >> K;
  unsigned long long ans=1;
  for(int i=0;i<N;i++){
    if(i==0){
      ans*=K;
    }
    else{
      ans*=K-1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

int n;

LL gcd(LL a, LL b) { return b == 0 ? a : gcd(b, a % b);}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	int a, x;
	cin >> n >> a;
	n--;
	while(n--) {
		cin >> x;
		a = gcd(a, x);
	}
	printf("%d\n", a);
	return 0;
}
/**/

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))
ans = []

for i in range(1, max(x)+1):
    p = 0
    for j in x:
        p += (j - i) ** 2
    ans.append(p)

if len(ans) == 0:
    print(0)
    exit()
print(min(ans))

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

int N,T[55];
bool dp[2][1050][1050];

signed main(){
    cin>>N;
    rep(i,N)cin>>T[i];

    dp[0][0][0]=true;
    int sum=0;
    rep(i,N){
        rep(j,1000)rep(k,1000){
            if(!dp[i&1][j][k])continue;
            int l=sum-j-k;
            dp[(i+1)&1][j+T[i]][k]=true;
            dp[(i+1)&1][j][k+T[i]]=true;
            dp[(i+1)&1][j][k]=true;
            dp[i&1][j][k]=false;
        }
        sum+=T[i];
    }


    int mi=1<<25;
    rep(i,1000)rep(j,1000)if(dp[N&1][i][j]){
        int k=sum-i-j;
        chmin(mi,max(max(i,j),k));
    }
    cout<<mi<<endl;

    return 0;
}

Measured memory_bytes: 3308
#include<iostream>
#include<tuple>
#include<string>
using namespace std;
#define MAX_V 1010
#define rep(i, n) for(int i = 1; i <= n; i++)

int main(){
	while(1){
		int N, Q, EraBasedYear, WesternYear, Query;
		string EraName;
		tuple<string, int, int> temp[MAX_V];
		
		cin>>N>>Q;
		
		if(!N&&!Q) break;
		
		rep(i, N){
			cin>>EraName>>EraBasedYear>>WesternYear;
			
			temp[i] = make_tuple(EraName,EraBasedYear,WesternYear);
		}
		
		rep(i,Q){
			cin>>Query;
			bool flag = false;
			rep(j,N){
				if(get<2>(temp[j]) -  get<1>(temp[j]) < Query && Query <= get<2>(temp[j])){
					cout<<get<0>(temp[j])<<" "<<Query + get<1>(temp[j]) - get<2>(temp[j])<<endl;
					flag = true;
					break;
				}
			}
			if(!flag)cout<<"Unknown"<<endl;
		}
		
	}
}


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

#define int long long
#define MAX_N (200005)
#define INF (1LL<<60)
#define EPS (1e-7)
#define DEBUG(x) cerr << #x <<":"<< x << endl;
#define DEBUGVC(x) cerr << #x <<": "; for(auto p:(x)) cerr << p <<" "; cerr << endl;
#define DEBUGVCP(x) for(auto p:(x)) cerr << #x <<": "<< p.first <<", "<< p.second << endl;
#define DEBUG2(x, y) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y << endl;
#define DEBUG3(x, y, z) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y <<", "<< #z <<" : "<< z << endl;
const int MOD = (int)1e9+7;
#define P pair<int,int>


signed main() {
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    for(int i=0; i<N; i++) cin >> L[i];

    int ans=1, D=0;
    for(int i=0; i<N; i++){
        if(D+L[i] <= X) {
            ans++;
            D += L[i];
        }
        else break;
    }

    cout << ans << endl;
    
}

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


int main(){
    string n;
    cin >> n;
    ll a = n.size();
    ll sum = 0;
    for(ll i=0;i<a;i++){
        sum +=(n[i] - '0');
    }
    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <queue>
using namespace std;
struct node
{
    int x,y;
    int bu;
};
int n,m;
char mp[55][55];
int vis[55][55];///标记数组
int fx[4][2] = {1,0,0,1,-1,0,0,-1};///记录方向
int bfs(int qx,int qy)///起始 x; 起始 y
{
    memset(vis,0,sizeof(vis));
    vis[qx][qy] = 1;///走过标记为1；
    node kai,xia,xian;
    kai.x = qx;
    kai.y = qy;
    kai.bu = 1;
    queue<node>q;
    q.push(kai);
    while(!q.empty())
    {
        xian = q.front();
        q.pop();
        if(xian.x == (n-1)&&xian.y == (m-1))///到达目标点
            return xian.bu;
        for(int i=0; i<4; i++)
        {
            xia.x = xian.x + fx[i][0];///更新点的坐标
            xia.y = xian.y + fx[i][1];
            if(xia.x<0||xia.y<0||xia.x>=n||xia.y>=m||vis[xia.x][xia.y]||mp[xia.x][xia.y]=='#')
                continue;///判断越界，是否被标记过，是否为'#'
            vis[xia.x][xia.y] = 1;///标记走过
            xia.bu = xian.bu +1;///更新步数
            q.push(xia);
        }
    }
    return -1;
}
int main()
{
    scanf("%d %d",&n,&m);///n行m列
    int lz=0;
    for(int i=0; i<n; i++)
    {
        scanf("%s",mp[i]);///存地图
        for(int j=0; j<m; j++)
        {
            if(mp[i][j]=='.')
                lz++;///记录起始白色方块数
        }
    }
    int x = bfs(0,0);///x为通过游戏所走最少的白色方块数
    if(x==-1)///游戏无法完成
        puts("-1");
    else
    {
        printf("%d\n",lz-x);
    }

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
//#include "debug.cpp"


int32_t main() 
{ 
    boost;
    
    string s;
    cin>>s;
    int a[2]={0};
    for(int i=0;i<3;i++)
        a[s[i]-'A']++;
    if(a[0]>0 && a[1]>0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<n;i++)
#define ll long long
ll now=0,ans=0;
ll a[200005];
int main()
{
	int n;
	cin>>n;
	forn(i,n)
		cin>>a[i];
	forn(i,n)
	{
		now=max(a[i],now);
		ans+=(now-a[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
 
int z[15][15];
 
int main(){
    int n;
    cin >> n;
    rep(i,n) rep(j,n) z[i][j] = -1;
    rep(i,n){
        int a;
        cin >> a;
        rep(j,a){
            int x, y;
            cin >> x >> y;
            x--;
            z[i][x] = y;
        }
    }
    int ans = 0;
    rep(i,1<<n){
        vector<int> d(n);
        rep(j,n) if(i>>j&1){
            d[j] = 1;
        }
        bool flag = true;
        rep(j,n){
            if(d[j]){
                rep(k,n){
                    if(z[j][k] == -1) continue;
                    if(z[j][k] != d[k]) flag = false;
                }
            }
        }
        if(flag) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	long long n, m;
	std::cin >> n >> m;
	if (n == 1 && m == 1)
	{
		std::cout << 1;
		return 0;
	}
	if (n == 1 || m == 1)
	{
		if (n == 1)
		{
			std::cout << m - 2;
			return 0;
		}
		if (m == 1) 
		{
			std::cout << n - 2;
			return 0;
		}

	}
	std::cout << (n - 2) * (m - 2);
	return 0;
}

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long n;
  cin >> n;
  set <long> s;
  long v;
  while(cin >> v)
	s.insert(v);
  if(n == s.size())
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int aa = max(A, C);
    int bb = min(B, D);
    auto diff = bb - aa;

    cout << max(0, diff) << endl;

    return 0;
}


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

#include <fstream>
using namespace std;


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int H, W, M;
  cin >> H >> W >> M;
  vector<pair<int, int>> bomb;
  vector<int> bombY(H), bombX(W);
  vector<unordered_set<int>> YtoX(H);
  unordered_set<int> Ykouho, Xkouho;
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    YtoX[a].insert(b);
    bombY[a]++;
    bombX[b]++;
    bomb.emplace_back(a, b);
  }
  int maxY = 0;
  for(int i = 0; i < H; i++){
    //cout << bombY[i] <<endl;
    if(bombY[i] > maxY){
      maxY = bombY[i];
    }
  }
  //cout << maxY <<endl;
  for(int i = 0; i < H; i++){
    if(bombY[i] == maxY){
      Ykouho.insert(i);
    }
  }
  int maxX = 0;
  for(int i = 0; i < W; i++){
    if(bombX[i] > maxX){
      maxX = bombX[i];
    }
  }
  for(int i = 0; i < W; i++){
    if(bombX[i] == maxX){
      Xkouho.insert(i);
    }
  }
  //cout <<endl;
  for(auto y: Ykouho){
    for(auto x: Xkouho){
      //cout << y << " " << x <<endl;
      //*
      if(!YtoX[y].count(x)){
        cout << maxY + maxX <<endl;    
        return 0;
      }
      //*/
    }
  }
  cout << maxY + maxX - 1 <<endl;
}


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

int main() {
  vector<int> a(9);
  for (int i = 0; i < 9; ++i) {
    cin >> a[i];
  }
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  vector<pair<int, bool>> v;
  for (int i = 0; i < n; ++i) {
    v.push_back(make_pair(b[i], false));
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 9; ++j) {
      if (a[j] == v[i].first) {
        v[j].second = true;
      }
    }
  }
  if (v[0].second == true && v[1].second == true && v[2].second == true) {
    cout << "Yes" << endl;
  } else if (v[3].second == true && v[4].second == true &&
             v[5].second == true) {
    cout << "Yes" << endl;
  } else if (v[6].second == true && v[7].second == true &&
             v[8].second == true) {
    cout << "Yes" << endl;
  } else if (v[0].second == true && v[3].second == true &&
             v[6].second == true) {
    cout << "Yes" << endl;
  } else if (v[1].second == true && v[4].second == true &&
             v[7].second == true) {
    cout << "Yes" << endl;
  } else if (v[2].second == true && v[5].second == true &&
             v[8].second == true) {
    cout << "Yes" << endl;
  } else if (v[0].second == true && v[4].second == true &&
             v[8].second == true) {
    cout << "Yes" << endl;
  } else if (v[2].second == true && v[4].second == true &&
             v[6].second == true) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

using namespace std;

int main(void)
{
  int N;
  cin >> N;
  vector<int> vi(N);
  for(int i = 0; i < N; i++){
    cin >> vi[i];
  }
  while(1){
    int min = *min_element(vi.begin(), vi.end());
    int ans = min;
    for(int i = 0; i < N; i++){
      int mod = vi[i] % min;
      if(mod == 0){
        mod = min;
      }
      if(mod < ans){
        ans = mod;
      }
      vi[i] = mod;
    }
    //cout << min << endl;
    if(ans == min){
      cout << min << endl;
      break;
    }
  }

  return 0;
}


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

int main(int argc, const char * argv[]) {
    
    int n,i,min,max,x;
    
    scanf("%d",&n);
    
    scanf("%d",&min);
    scanf("%d",&x);
    
    max = x - min;
    min = fmin(min, x);
    
    for (i=2; i<n; i++) {
        scanf("%d",&x);
        
        max = fmax(max, x - min);
        
        min = fmin(min, x);
        
    }
    
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, d[502][502] = {}, b = 1;
    cin >> n;
    for (int i = 1; b < n; i++) {
        int c[502] = {};
        for (int j = 1; j <= n; j++) {
            if ((j - 1) % (b + b) >= b) c[j] = 1;
        }
        for (int j = 1; j <= n; j++) for (int k = j; k <= n; k++) if (!d[j][k] && c[j] != c[k]) d[j][k] = i;
        b += b;
    }
    for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) cout << d[i][j] << " \n"[j == n];
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int n, K;
vector<int> to[2048];
int sz[2048], dp[2048][2048];
 
int prep(int at, int pre) {
    sz[at] = 1;
    rep (i, to[at].size()) if (to[at][i] != pre) {
        int u = to[at][i];
        sz[at] += prep(u, at);
    }
    return sz[at];
}
 
void rec(int at, int pre) {
    rep (i, to[at].size()) if (to[at][i] != pre) {
        int u = to[at][i];
        rec(u, at);
        for (int k = K - 1; k >= 0; k--) {
//            printf("%d[%d]: %d\n", u+1, k, dp[u][k]);
//            printf("%d, %d\n", dp[at][min(k, K - k - 1)], dp[u][k]);
            int t = min(k, K-k-2);
            int b = dp[at][k+1] + (t >= 0 ? dp[u][t] : sz[u]);
//            printf("min(%d, %d)\n", dp[at][min(k+1, K-k-1)] + dp[u][k], b);
            dp[at][k+1] = min(dp[at][min(k+1, K-k-1)] + dp[u][k], b);
//            printf("%d[%d] / %d: %d\n", at+1, k+1, u+1, dp[at][k+1]);
        }
        dp[at][0] += sz[u];
        rep (i, K) dp[at][i+1] = min(dp[at][i+1], dp[at][i]);
//        rep (i, K+1) printf("%d[%d] / %d: %d\n", at+1, i, u+1, dp[at][i]);
    }
}
 
int main() {
    scanf("%d%d", &n, &K);
    rep (i, n-1) {
        int a, b;
        scanf("%d%d", &a, &b);
        to[a-1].push_back(b-1);
        to[b-1].push_back(a-1);
    }
    prep(0, -1);
    rec(0, -1);
    int ans = 50000;
    rep (i, n) ans = min(ans, dp[i][K] + (n - sz[i]));
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 16512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  VS A(N);
  rep(i,N) cin>>A[i];
  VI B(N),C(N),D(N),E(N);
  rep(i,N) rep(j,N) B[i]+=(A[i][j]=='#');
  rep(i,N){
    C[i]=1;
    rep(j,N) C[i]&=(A[i][j]=='#');
  }
  rep(i,N){
    D[i]=1;
    rep(j,N) D[i]&=(A[j][i]=='#');
  }
  rep(i,N) rep(j,N) E[i]+=(A[j][i]=='#');
  int G=0;
  rep(i,N) G+=D[i];
  int F=0;
  rep(i,N) F+=B[i];
  int ans=N*2;
  rep(i,N){
    if(C[i]){
      ans=min(ans,N-G);
      continue;
    }
    if(E[i]) ans=min(ans,N-B[i]+N-G);
    else ans=min(ans,N-B[i]+1+N-G);
  }
  cout<<(F?ans:-1)<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll read()
{
	ll out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		{
			fh=-1;
			jp=getchar();
		}
	while (jp>='0'&&jp<='9')
		{
			out=out*10+jp-'0';
			jp=getchar();
		}
	return out*fh;
}
const int MAXN=1e5+10;
const ll P=1e9+7;
ll n,a[MAXN];
ll add(ll a,ll b)
{
	return (a+b) % P;
}
ll mul(ll a,ll b)
{
	return a * b % P;
}
ll fpow(ll a,ll b)
{
	ll res=1;
	while(b)
		{
			if(b&1)
				res=mul(res,a);
			a=mul(a,a);
			b>>=1;
		}
	return res;
}
ll getinv(ll x)
{
	return fpow(x,P-2);
}
ll inv[MAXN],pre[MAXN];
ll fac[MAXN];
int main()
{
  	//freopen(".in","r",stdin);
  	//freopen(".out","w",stdout);
  	n=read();
  	for(int i=1;i<=n;++i)
  		a[i]=read();
  	for(int i=1;i<=n;++i)
  		inv[i]=getinv(i),pre[i]=add(pre[i-1],inv[i]);
  	ll ans=0;
  	for(int i=1;i<=n;++i)
  		ans=add(ans,mul(a[i],pre[i]-1)),ans=add(ans,mul(a[i],pre[n-i+1]));
  	fac[0]=1;
  	for(int i=1;i<=n;++i)
  		fac[i]=mul(fac[i-1],i);
  	ans=mul(ans,fac[n]);
  	cout<<ans;
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  string s;
  cin >> s;
  ll ans = 9 * (s.size() - 1);
  ans += s[0] - '0' - 1;
  for (ll i = 1; i < s.size(); i++) {
    if (s[i] != '9') break;
    if (i == s.size() - 1) ans++;
  }
  if (s.size() == 1) ans ++;
  cout << ans << endl;
}

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

int canmaketriangle(int a, int b, int c);

int main()
{
  int n;
  int* l;
  int c = 0;
  scanf("%d", &n);
  l = (int*)malloc(n);
  if (l == NULL)
    return -1;
  for (int i = 0; i < n; i++)
    scanf("%d", &l[i]);
  for (int i = 0; i < n - 2; i++)
    for (int j = i + 1; j < n - 1; j++)
      for (int k = j + 1; k < n; k++)
        if (canmaketriangle(l[i], l[j], l[k]))
          c++;
  printf("%d", c);
  return 0;
}

int canmaketriangle(int a, int b, int c)
{
  if (a < b + c && b < a + c && c < a + b)
    return 1;
  else
    return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (r, g, b, n) = readLine()!!.split(' ').map(String::toLong)
    var sum = 0
    for (i in 0..3000) {
        if (i * r > n) break
        for (j in 0..3000) {
            if (i * r + j * g> n) break
            if ((n - i * r - j * g) % b == 0L) {
//                println("${i*r} ${j*g} ${(n - i * r - j * g) % b}")
                sum++
            }
        }
    }
    println(sum)
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#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--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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


int main(){
	int N;
	cin>>N;
	RREP(i,8){
		if(N>=pow(2,i)){
			cout<<pow(2,i)<<endl;
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
	int a, b, x;
	cin >> a >> b >> x;
	int w = 1000;
	if(a > b * 2) swap(a, b), w = 500;
	int sum = 0;
	while(x > 500) x -= w, sum += a;
	if(x > 0) sum += min(a, b);
	cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;

int main() {
	int H,W;
	cin >> H >> W;
	vector<string> input;
	int cnt = 0;
	for(int i=0; i<H; i++) {
		string s;
		cin >> s;
		input.push_back(s);
		for(int j=0; j<W; j++)
			if(s[j] == '#')
				cnt++;
	}
	
	bool ok = true;
	if(cnt != H+W-1) ok = false;
	if(input[0][0] != '#') ok = false;
	
	for(int i=0; i<H; i++) {
		for(int j=0; j<W; j++) {
			if(i==0 && j ==0) continue;
			int p = 0;
			//cout << ok << endl;
			if(input[i][j] == '#') {
				if(i>0 && input[i-1][j] == '#' ) p++; 
				if(j>0 && input[i][j-1] == '#' ) p++; 
				if(p!=1) ok = false;
			}
		}
	}
	if(ok) cout << "Possible" << endl;
	
	else cout << "Impossible" << endl;
	
	return 0;
}



Measured memory_bytes: 256
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

def countNewZ(count, countZ):
  current = (countZ * (countZ + 1)) / 2
  if(current <= count):
    countZ += 1
    return countNewZ(count, countZ)
  else:
    return countZ - 1

n = int(input())
primeFactors = prime_factors(n)
unique = set(primeFactors)
z = 0
for prime in unique:
  count = primeFactors.count(prime)
  z += countNewZ(count, 0)
print(z)

Measured memory_bytes: 62812
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;

int main(const int args, const char* argv[])
{
    double side1, side2, angle;
    cin >> side1 >> side2 >> angle;
    double area = side1 * side2 * sin(angle / 180 * M_PI) / 2;
    cout << setprecision(8) << fixed << side1 * side2 * sin(angle / 180 * M_PI) / 2 << endl;
    cout << setprecision(8) << fixed << (side1 + side2) + sqrt(pow(side1, 2) + pow(side2, 2) - 2 * side1 * side2 * cos(angle / 180 * M_PI)) << endl;
    cout << setprecision(8) << fixed << area * 2 / side1 << endl;

    return 0;
}


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

int main(){

	int n;
	long long m, a[5001];

	a[0] = 0;
	while(cin >> n, n != 0){
		for(int i=1; i<=n; i++){
			cin >> a[i];
			a[i] += a[i-1];
		}

		m = -100000;
		for(int i=0; i<=n; i++){
			for(int j=i+1; j<=n; j++){
				m = max(m, a[j] - a[i]);
			}
		}
		cout << m << endl;
	}

	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n, m, k;
ll P[100000], C[100000], J[100000];
vector<pl> e[100000];
ll dist[2][100000];
ll ans[100000];
priority_queue<pl, vector<pl>, greater<pl>> que, que2;

int main() {
    cin >> n >> m >> k;
    rep(i,k) ans[i] = -linf;
    rep(i,n) cin >> P[i];
    rep(i,n) cin >> C[i];
    rep(i,n) C[i]--;
    rep(i,n) cin >> J[i];
    rep(i,m) {
        int u, v, t;
        cin >> u >> v >> t; u--; v--;
        e[u].push_back(pl(v, t));
        e[v].push_back(pl(u,t));
    }
    rep(i,2) rep(j,n) dist[i][j] = linf;
    dist[0][0] = 0; dist[1][0] = -P[0];
    que.push(pl(0, 0));
    que2.push(pl(-P[0], n));
    while (!que.empty()) {
        pl q = que.top(); que.pop();
        ll f = q.second/n, pos = q.second%n;
        if (dist[f][pos] < q.first) continue;
        rep(i,e[pos].size()) {
            pl to = e[pos][i];
            if (f == 1) {
                /*
                if (dist[1][to.first] > to.second + dist[f][pos]) {
                    dist[1][to.first] = to.second + dist[f][pos];
                    que.push(pl(dist[1][to.first], n+to.first));
                }
                */
            } else {
                if (dist[0][to.first] > to.second + dist[f][pos]) {
                    dist[0][to.first] = to.second + dist[f][pos];
                    que.push(pl(dist[0][to.first], to.first));
                }
                if (dist[1][to.first] > to.second + dist[f][pos] - P[to.first]) {
                    dist[1][to.first] = to.second + dist[f][pos] - P[to.first];
                    que2.push(pl(dist[1][to.first], n+to.first));
                }
            }
        }
    }
    while (!que2.empty()) {
        pl q = que2.top(); que2.pop();
        ll f = q.second/n, pos = q.second%n;
        if (dist[f][pos] < q.first) continue;
        rep(i,e[pos].size()) {
            pl to = e[pos][i];
            if (f == 1) {
                if (dist[1][to.first] > to.second + dist[f][pos]) {
                    dist[1][to.first] = to.second + dist[f][pos];
                    que2.push(pl(dist[1][to.first], n+to.first));
                }
            }
        }
    }
    rep(i,n) {
        //cerr << dist[0][i] << " " << dist[1][i] << " " << dist[2][i] << endl;
        //ans[C[i]] = max(ans[C[i]], -1 * (dist[1][i] +dist[2][i]));
        ans[C[i]] = max(ans[C[i]], -1 * (dist[1][i] +dist[0][i] -J[i]));
    }
    rep(i,k) {
        cout << ans[i] << endl;
    }
}



Measured memory_bytes: 24764
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
    s=input()
    d=[]
    d.append(s)
    for i in range(len(d)):
        if d[i]=="AC":
            ac=ac+1
        if d[i]=="WA":
            wa=wa+1
        if d[i]=="TLE":
            tle=tle+1
        if d[i]=="RE":
            re=re+1
print("AC x ",ac)
print("WA x ",wa)
print("TLE x ",tle)
print("RE x ",re)
            


Measured memory_bytes: 9136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		int[] arrayHomework = new int[M];

		for (int i = 0; i < M; i++) {
			arrayHomework[i] = Integer.parseInt(sc.next());
			N -= arrayHomework[i];
		}
		sc.close();

		System.out.println(N >= 0 ? N : -1);

	}

}


Measured memory_bytes: 41568
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[warn(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[warn(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[warn(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    let n: usize = read();
    println! {"{}",n/3}
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {

    int n, m, x;
    cin>>n>>m>>x;
    int ans=0;
    rep(i,m){
        int a;
        cin >> a;
        if(a<x) ans++;
    }
    cout << min(ans, m-ans) << endl;
    
    return 0;
}


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

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

#define FOR(i,n,m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i,n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll a[100005];

int main()
{

    int N;
    cin>>N;
    REP(i,N)
    {
        cin>>a[i];
    }
    string ans ="second";
    REP(i,N)
    {
        if(a[i]%2==1)
        {
            ans="first";
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<ctype.h>
#include<cmath>
using namespace std;
inline int read(){
    int x=0,f=0;char ch=getchar();
    while(!isdigit(ch))f|=ch=='-',ch=getchar();
    while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
    return f?-x:x;
}
int main(){
    int n=read(),ans=0,last=0;
    for(int i=1;i<=n;++i){
    	int x=read(),a=log2(x);
        if((1<<a)<x && last<=a)a++;
        if(a>last)ans+=a-last;
        last=a;
    }
    printf("%d", ans);
    return 0;
}
 

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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<pair<long long, long long>> v(n);
  for(int i = 0; i < n; i++){
    long long x, y;
    cin >> x >> y;
    v[i] = make_pair(x, y);
  }
  
  vector<vector<pair<long long, long long>>> e(n, vector<pair<long long, long long>>(n));
  for(int i = 0; i < n - 1; i++){
    e[i][i] = make_pair(0, 0);
    for(int j = i + 1; j < n; j++){
      long long dx = v[i].first - v[j].first;
      long long dy = v[i].second - v[j].second;
      if(dx < 0){
        dx = -dx;
        dy = -dy;
      }if(dx == 0 && dy < 0){
        dy = -dy;
      }
      e[i][j] = make_pair(dx, dy);
      e[j][i] = make_pair(dx, dy);
    }
  }
  unordered_map<string, int> counter;
  int max = 0;
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      string s = to_string(e[i][j].first) + "_" + to_string(e[i][j].second);
      int c;
      if(counter.count(s)){
        c = counter[s];
        counter.erase(s);
        c++;
      }else{
        c = 1;
      }
      counter.emplace(s, c);
      if(c > max) max = c;
    }
  }
  
  cout << n - max << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  double pi = acos(-1.0);
  double S = x/a;
  
  if( a*b/2 < S ){
    printf( "%.10lf", atan2( (a*b-S)*2, (a*a) )*180.0/pi );
    }else{
    printf( "%.10lf", atan2( b*b, S*2 )*180.0/pi );
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <complex>
#include <iomanip>
#include <random>

using namespace std;

typedef long long ll;
#define int ll

int M = (int)1e9 + 7;
#define msum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define msub(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define mmult(a, b) (((a) * (b)) % M)

typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;
typedef complex<int> point;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>


#define cerr cout
#define watch(x) cerr << (#x) << " = " << (x)    << endl;

const double PI = 2 * acos(0.0);

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
	return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
	return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
	return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " << get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
	out << "[";
	fori(i, a.size())
		out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
	return out;
}

void smain();

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);


	cout << setprecision(12) << fixed;
	smain();
}

#define N 400000
const int oo = (int)1e9;


void smain()
{

	int n, w, h;
	cin >> n >> w >> h;

	if (w > n || h > n)
		cout << 0;
	else
		cout << (n - w + 1) * (n - h + 1);







}

//m1.codeforces.com, m2.codeforces.com или m3.codeforces.com

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

  

int main() {
  int a;
  cin >> a;
  cout << a+a*a+a*a*a << endl;
}

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

using namespace std;

void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

int main(void)
{
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> a(Q);
    vector<int> b(Q);
    vector<int> c(Q);
    vector<int> d(Q);

    for(int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    vector<int> v;
    if(M == 1){
        int sum = 0;
        for(int i = 0; i < Q; i++) {
            if(0 == c[i]) {
                sum += d[i];
            }
        }
        cout << sum << endl;
        return 0;
    }
    else {
        for(int i = 0;i < M - 1;i++) {
            v.push_back(0);
        } 
    }
    for(int i = 0;i < N;i++) {
        v.push_back(1);
    }

    vector<int> result;

    while(next_permutation(v.begin(),v.end())) {
        int count = 1;
        vector<int> A;
        for(int i = 0;i < (int)v.size();i++) {
            if(v[i] == 1) {
                A.push_back(count);
            }
            else{
                count++;
            }
        }
        long long sum = 0;
        for(int i = 0; i < Q; i++) {
            if(A[b[i]-1] - A[a[i]-1] == c[i]) {
                sum += d[i];
            }
        }
        result.push_back(sum);
    }

    cout << *max_element(result.begin(),result.end()) << endl;

    return 0;

    
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}


int main(int argc,char* argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG=1;}
  dprint("start");

  int N,W; cin>>N>>W;
  ll w[N+1],v[N+1];
  for(int i=1;i<=N;++i){
    cin >> w[i] >> v[i];
  }
  ll dp[N+1][W+1];
  FILL2(dp,N+1,W+1,0LL);
  for(int i=1;i<=N;++i){
    for(int x=0;x<=W;++x){
      dp[i][x] = dp[i-1][x];
      if(x-w[i]>=0){
        chmax(dp[i][x],dp[i-1][x-w[i]]+v[i]);
      }
    }
  }
  cout << dp[N][W] << "\n";
}

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

#define int long long

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

int N;
int A[100000];

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int ans = 1;
    bool unset = true;
    bool bef = true;
    for (int i = 1; i < N; i++) {
        if (A[i] == A[i - 1]) {
            continue;
        }
        bool cur = A[i] > A[i - 1];
        if (unset) {
            unset = false;
        } else {
            if (bef != cur) {
                unset = true;
                ans++;
            }
        }
        bef = cur;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
int N,K;
int a = 1;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    if(a>=K){
    a += K;
    }
    else{
    a *=2;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256