akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
using namespace std;
char map[101][101];
int t[101][101];
void work(int x,int y)
{
    if(map[x+1][y]=='#') t[x][y]++;
    if(map[x-1][y]=='#') t[x][y]++;
    if(map[x][y+1]=='#') t[x][y]++;
    if(map[x][y-1]=='#') t[x][y]++;
    if(map[x+1][y+1]=='#') t[x][y]++;
    if(map[x+1][y-1]=='#') t[x][y]++;
    if(map[x-1][y+1]=='#') t[x][y]++;
    if(map[x-1][y-1]=='#') t[x][y]++;
}
int main()
{
    int n,m,i,j,k=0;
    cin>>n>>m;
        ++k;
        for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
        cin>>map[i][j];
        for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
        {
            if(map[i][j]=='.') work(i,j);
            if(map[i][j]=='#') t[i][j]=-1;
        }
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=m;j++)
            {
                if(t[i][j]==-1) cout<<"#";
                else cout<<t[i][j];
            }
            cout<<endl;
        }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
import math

k=0
for a in range(1,n+1):
    for b in range(1,n+1):
        a_b=math.gcd(a,b)
        for c in range(1,n+1):
            g=math.gcd(c,a_b)
            k=k+g

print(k)
    

Measured memory_bytes: 9176
//
//  main.c
//  Triangle
//
//  Created by x17090xx on 2019/05/31.
//  Copyright © 2019 AIT. All rights reserved.
//

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    
    double a=0, b=0, c=0, s=0, l=0, h=0;
    int deg=0;
    double rad=0;
    double PI = acos(-1);//円周率
    
    scanf("%lf %lf %d", &a, &b, &deg);
    
    rad = deg * PI / 180;
    
    //面積
    s =  a * b * sin(rad) / 2;
    
    //周の長さ
    c = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(rad));
    l = a + b + c;
    
    //高さ
    h = 2 * s / a;
        
    printf("%f\n", s);
    printf("%f\n", l);
    printf("%f\n", h);
    
    return 0;
}



Measured memory_bytes: 2076
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int L = sc.nextInt();
		//a=b=c=L/3のとき最大なので、その時の体積はLの3乗/27となる
		System.out.println((double)L*L*L/27);
	}		
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(void){

	int a,b,c,d,x,y,z;

	scanf("%d%d%d%d",&a,&b,&c,&d);

	x=a-c>0?a-c:c-a;
	y=a-b>0?a-b:b-a;
	z=c-b>0?c-b:c-b;

	if(x<=d||(y<=d&&z<=d))
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int x;
  cin >> x;
  if(30<=x) cout << "Yes" << endl;
  else cout << "No" << endl; 


  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int a,b;
  cin>>a>>b;
  for(int i=b-a+1;i<=a+b-1;i++){
    cout<<i<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 3620
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first.first
#define yy first.second
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifdef LOCALc
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
template<typename T, typename l>
void getv(T& a, int n, l f) {
	a.resize(n);
	for (auto& i : a)
		cin >> i, f(i);
}
template<typename T>
void getv(T& a, int n) {
	a.resize(n);
	for (auto& i : a)
		cin >> i;
}
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, a[1000000], p[1000000], g = 0, ans = 0;
int main() {
	doin();
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	p[0] = 0;
	p[1] = a[1];
	for(int i = 2; i <= n; i++) p[i] = __gcd(p[i-1], a[i]);
	for(int i = n; i > 0; i--) ans = max(ans, __gcd(p[i-1], g)), g = __gcd(g, a[i]);
	cout << ans;
}


Measured memory_bytes: 4736
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define mp make_pair
#define ff first
#define ss second
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%lld",&a)
#define pf printf
#define sz(a) (ll)(a.size())
#define psf push_front
#define ppf pop_front
#define ppb pop_back
#define pb push_back
#define pq priority_queue
#define all(s) s.begin(),s.end()
#define sp(a) setprecision(a)
#define rz resize

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	int a[n];
	f(i,0,n)
		cin>>a[i];
	vector<bool> dp(k+1);
	f(i,0,k+1)
	{
		f(j,0,n)
		{
			if(a[j]<=i && !dp[i-a[j]])
				dp[i]=true;
		}
	}
	if(dp[k])
		cout<<"First";
	else
		cout<<"Second";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
int main(){
  lint N,M;
  lint ans1=0,ans2=0;
  string s;
  cin>>N>>M;
  if(N==1&&M==1){cout<<1000000;
return 0;
  }
  if(N==1)ans1=300000;
  if(N==2)ans1=200000;
  if(N==3)ans1=100000;
  if(M==1)ans2=300000;
  if(M==2)ans2=200000;
  if(M==3)ans2=100000;

  cout<<ans1+ans2;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1e9+7;
const int INF=1001001001;

int main() {
  string s;
  cin>>s;
  sort(s.begin(),s.end());
  if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]){
    cout<<"Yes"<<endl;
  }
  else{cout<<"No"<<endl;}
  return 0;  
}

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

using namespace std;
int n,v[100],c;
int main(){
    cin >> n;
    for(int i = 1;i <= n; ++i) cin >> v[i];
        int ans = 0;
    for(int j = 1;j <= n; ++j){
        cin >> c;
        ans += max(0,v[j]-c);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  int a, b, c ,d;
  cin >> a >> b>>c>>d;
  
  //vector<int> a(n);  rep(i, 0, n) cin >> a[i];
  
  //cout << n << "\n";
  
  cout << ( (abs(a-b)<=d and abs(b-c)<=d) or abs(a-c)<=d ?"Yes" :"No") << "\n";
  
  //cout << fixed << setprecision(15) << n << "\n";

}

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



signed main() {
    int n, m;
    cin >> n >> m;
    if (n > m) {
        cout << 0 << "\n";
        return 0;
    }
    vector<int> v(m);
    for (int i = 0; i < m; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    vector<int> diff;
    diff.push_back(0);
    for(int i = 1; i < m; ++i) {
        diff.push_back(v[i] - v[i - 1]);
    }
    sort(diff.begin(), diff.end(), greater<int>());
    int x = v[m - 1] - v[0];
    for(int i = 0; i < n - 1; ++i) {
        x -= diff[i];
    }
    cout << x << "\n";
}

Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int m = sc.nextInt();
		double ans = 0, ms = 1900;
		
		ans = ((n - m) * 100 + ms * m) * Math.pow(2, m);
		
		System.out.println(String.format("%.0f", ans));

		sc.close();
	}
}


Measured memory_bytes: 21972
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
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;
}

int main(){
    int x;
    cin >> x;
    cout << 1- x << endl;
    return 0;
}

Measured memory_bytes: 3620
package main

import (
	"fmt"
)

func abs(n int) int {
	if n < 0 {
		return -n
	}

	return n
}

func solve(N int, as []int) int {
	dp := map[int]int{}

	broken := map[int]bool{}

	for i := 0; i < len(as); i++ {
		broken[as[i]] = true
	}

	dp[0] = 1
	if broken[1] {
		dp[1] = 0
	} else {
		dp[1] = 1
	}

	for i := 2; i <= N; i++ {
		if broken[i] {
			dp[i] = 0
		} else {
			dp[i] = (dp[i-1] + dp[i-2]) % 1000000007
		}
	}

	return dp[N]
}

func main() {
	var N, M int

	fmt.Scan(&N)
	fmt.Scan(&M)

	as := make([]int, M)

	for i := 0; i < M; i++ {
		fmt.Scan(&as[i])
	}

	output := solve(N, as)

	fmt.Println(output)
}


Measured memory_bytes: 9344
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        ++$this->pointer;

        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int) $this->next();
    }

    public function nextDouble()
    {
        return (float) $this->next();
    }
}

$sc = new Scanner();
$l = $sc->nextInt();
$r = $sc->next();
$min_mod = 2018;

if($r-$l>=2018){
    $min_mod = 0;
} else {
    for($i=$l;$i<$r;$i++){
        for($j=$i+1;$j<$r+1;$j++){
            $mod = ($i*$j)%2019;
            if($mod < $min_mod){
                $min_mod = $mod;
            }
        }
    }
}

echo $min_mod.PHP_EOL;


Measured memory_bytes: 16072
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
string test[345678];
signed main() {
	int n; string s, t; cin >> n;
	int mi = n + 1, ma = 1;
	for (int h = 0; h < n; h++) {
		cin >> test[h];
	}
	cin >> t;
	//miの場合
	for (int h = 0; h < n; h++) {
		for (int i = 0; i <= min(test[h].size(), t.size()); i++) {
			if (i == t.size()) { mi--; break; }
			if (i == test[h].size()) { break; }
			if (test[h][i] == '?') { 
				if (t[i] != 'z') { mi--; break; }
			}
			else if (test[h][i] > t[i]) { mi--; break; }
			else if (test[h][i] != t[i]) { break; }
		}
	}
	//maの場合
	for (int h = 0; h < n; h++) {
		for (int i = 0; i <= min(test[h].size(), t.size()); i++) {
			if (i == test[h].size()) { ma++; break; }
			if (i == t.size()) { break; }
			if (test[h][i] == '?') {
				if (t[i] != 'a') { ma++; break; }
			}
			else if (test[h][i] < t[i]) { ma++; break; }
			else if (test[h][i] != t[i]) { break; }
		}
	}
	for (int h = mi; h <= ma; h++) {
		if (h == mi) { cout << h; }
		else { cout << ' ' << h; }
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3584
function main(arg) {
  var N = parseInt(arg[0]);
  var sum = 0;
  for (var i = 1; i <= N; i++) {
    if (i % 3 == 0 && i % 5 == 0) {
    } else {
      if (!(i % 3 == 0) && !(i % 5 == 0)){
        sum += i;
      }
    }
  }
  console.log(sum);

}

main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));


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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, h, a, b[114514];
	cin>>n>>h;
	int m=0;
	REP(i, n){
		cin>>a>>b[i];
		m=max(m, a);
	}
	sort(b, b+n);
	int cnt=n-1;
	while(h>0){
		if(cnt>=0 && b[cnt]>m){
			h-=b[cnt];
			--cnt;
		}
		else{
			break;
		}
	}
	cout<<n-1-cnt+(h>0 ? (h-1)/m+1 : 0)<<'\n';
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll int a,b,c,d;

    cin>>a>>b>>c>>d;

    ll int k = max(a*c, a*d);
    ll int l = max(b*c,b*d);
    cout<<max(k,l)<<endl;
}


Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	int n,count=0;
	cin >> n;
	vector<int>p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 1; i < n-1; i++) {
		if (p[i] > min(p[i + 1], p[i-1])&&p[i]<max(p[i+1],p[i-1])) {
			count++;
			//cout << p[i] << endl;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

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

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

int N, M, ans;
Pii P[int(1e5 + 5)];
priority_queue <int> que;

int main(){
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; i++){
    int A, B; scanf("%d%d", &A, &B);
    P[i] = {A, B};
  }
  sort(P, P + N);

  int now = 0;
  que.push(0);
  for (int i = 1; i <= M; i++){
    for (int j = now; j < N; j++){
      if (P[j].fi <= i){
        que.push(P[j].se); now++;
      }else break;
    }
    ans += que.top();
    if (que.top() > 0) que.pop();
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4612
import java.io.*;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = "";
		while(!(str=sc.next()).equals("#")){
			Check c = new Check();
			for(int i = 0 ; i < str.length(); i ++){
				c.check(str.charAt(i),i);
			}
			c.print();
		}
	}
}
class Check{
	private String f = "yuiophjklnm";
	private boolean rflag = false;
	private int count = 0;
	void check(char word,int i){
		Pattern p = Pattern.compile(String.valueOf(word));
	    Matcher m = p.matcher(f);
	    if(m.find()){
	    	if(i==0){
	    		rflag=true;
	    	}
	    	else if(rflag==false){
				count++;
				rflag=true;
			}
		}
	    else if(rflag==true){
			count++;
			rflag=false;
		}
	}
	void print(){
		System.out.println(count);
		count=0;
	}
}

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

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

int main(){
	while(true){
		int n; cin >> n;
		if(n == 0)break;
		vector<pair<int ,int> > a(n);
		a[0] = make_pair(0,0);
		for(int i = 1; i < n; i++){
			int m, d; cin >> m >> d;
			a[i] = make_pair(a[m].first + dx[d], a[m].second + dy[d]);
		}
		int xmin = (int)1e9,xmax = -(int)1e9,ymin = (int)1e9,ymax = -(int)1e9;
		for(int i = 0; i < n; i++){
			xmin = min(xmin, a[i].first);
			xmax = max(xmax, a[i].first);
			ymin = min(ymin, a[i].second);
			ymax = max(ymax, a[i].second);
		}
		xmax -= xmin; ymax -= ymin;
		xmax++; ymax++;
		cout << xmax << " " << ymax << endl;
	}

	return 0;
}




Measured memory_bytes: 2992
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (b / a < c) {
            System.out.println(b / a);
        } else {
            System.out.println(c);
        }
    }
}

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

int main() {
    int64_t N, A, B;
    cin >> N >> A >> B;
    int64_t blue = 0;
    if(N % (A + B) < A) 
    blue = (N / (A + B)) * A + N % (A + B);
    else
    blue = (N / (A + B)) * A + A;
    cout << blue << endl;
    
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        int sum = a + b;
        int minus = a - b;
        int kake = a * b;

        int ans = Math.max(kake, Math.max(sum, minus));

        System.out.println(ans);
    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 21076
import java.util.*;

//文字操作
class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		while(true){
			int n=sc.nextInt();
			if(n==0)break;

			int c=0;
			for(int i=5;i<=n;i*=5){
				c+=n/i;
			}
			ln(c);
		}
	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

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

int main() {
	int s,s1,s2,s3,s4;
	cin >> s;
	s1 = s / 1000;
	s2 = s / 100 % 10;
	s3 = s / 10 % 10;
	s4 = s % 10;
	if ( s1 == s2 || s2 == s3 || s3 == s4 )
		cout << "Bad" << endl;
	else
		cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
L=[]
for _ in range(N):
  L.append(int(input()))
sL=sorted(L)
sL.reverse()
m=max(L)
m2=sL[1]

for i in range(N):
  if L[i]==m:
    print(m2)
  else:
    print(m)

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

typedef struct JOB{
  long long a;
  long long b;
}tagjob;

int cmp(const tagjob *x,const tagjob *y){
  return x->b > y->b ? 1 : x->b < y->b ? -1 :0 ;
}

int main(void){
  int n;
  int i;
  long long ttl=0;
  scanf("%d",&n);


tagjob job[n],tmp;

for(i=0;i<n;i++){
    scanf("%ld%ld",&job[i].a,&job[i].b);
  }

  qsort(job,n,sizeof(tagjob),(int (*)(const void *,const void *))cmp);
  for(i=0;i<n;i++){
    ttl=ttl+job[i].a;
    if(ttl>job[i].b){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  bool dp[30001][4][1000] = {};
  dp[0][0][0] = 1;
  rep(i,n){
    rep(j,4){
      rep(k,1000){
        if(dp[i][j][k]){
          dp[i+1][j][k] = 1;
          if(j < 3){
          	dp[i+1][j+1][10*k+s[i]-'0'] = 1;
          }
        }
      }
    }
  }
  int ans = 0;
  rep(i,1000) if(dp[n][3][i]) ans ++;
  cout << ans << endl;
}


Measured memory_bytes: 120856
use std::io;
fn main() {
    let mut num = String::new();
    io::stdin().read_line(&mut num)
        .expect("Failed to read line");
    let num:i32 =  num.trim().parse()
        .expect("failed to comvert to int32");
    
    if num <= 999{
        println!("ABC");
    }else{
        println!("ABD");
    }

}


Measured memory_bytes: 4352
while s = gets
  na = s.split.map(&:to_i)
  nb = gets.split.map(&:to_i)

  h, b = 0, 0
  c = Array.new

  (0..na.size - 1).each { |i| 
    if na[i] == nb[i]
      h += 1
    else
      c.push(nb[i])
    end 
  }
  c.each { |x| b += 1 if na.include?(x) }

  puts "#{h} #{b}"
end

Measured memory_bytes: 5224
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line cout<<"----------------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll mx=400009;
int a[mx],b[mx],c[mx]; 
int  main()
{
    int n ;
    cin>>n; 
    int sum=0; 
    for(int i=1;i<=n;i++) cin>>a[i]; 
    for(int i=1;i<=n;i++) cin>>b[i]; 
    for(int i=1;i<=n-1;i++) cin>>c[i]; 
    for(int i=1;i<=n;i++)
    {
        sum+=b[i]; 
        if(a[i]==a[i-1]+1) sum+=c[a[i]-1]; 
    }
    cout<<sum<<endl; 
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT
 
using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;
 
template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

const int mod = 1000*1000*1000+7;

const int N = 1000100;
 
int n;
int m;
int f[N + 1];
int rf[N + 1];

int power (int a, int b) {
    int c = 1;
    while (b) {
        if (b & 1) c = ((ll)c * a) % mod;
        a = ((ll)a * a) % mod;
        b /= 2;
    }
    re c;
}

int cnk (int n, int k) {
    if (n < 0 || k < 0 || k > n) re 0;
    re ((ll)f[n] * rf[k] % mod * rf[n - k]) % mod;
}

int fab (int a, int b) {
    if (b == 0) re f[a];
    if (a < b + 1) re 0;
    a -= b + 1;
    re ((ll)cnk (a + b, b) * f[a + b + 1] % mod * f[b]) % mod;
}

int calc (int n) {
    int ans = 0;
    int cur = 0;
    for (int i = 0; i < n; i++) {
        int tmp = fab (i, n - i - 1);
        ans = (ans + (ll)(tmp - cur + mod) % mod * i) % mod;
        cur = tmp;
    }
    re ans;
}
 
int main () {
    f[0] = rf[0] = 1;
    for (int i = 1; i <= N; i++) {
        f[i] = ((ll)f[i - 1] * i) % mod;
        rf[i] = power (f[i], mod - 2);
    } 
    cin >> n;
    cout << calc (n) << endl;
	return 0;
}

Measured memory_bytes: 8064
n = input()
a = [int(i) for i in raw_input().split(" ")]
a.sort()
i = n - 1
x, y = 0, 0
k = 0
while i >= 0:
  if k == 0: x += a[i]
  else: y += a[i]
  i -= 1
  k = 1 - k
print x - y

Measured memory_bytes: 2568
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <math.h>
 
using namespace std;
 
int main(){
 
	int n;
  	int input;
  	vector<int> a;
  
  	cin >> n;
  	while(cin >> input){
    	a.push_back(input);
    }
  
  	for(int i =n-1;i >=0; i--){
    	cout << a.at(i);
      
      	if(i>0)
          cout << " ";
      	else
          cout << endl;
    }
  return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    string S, T;
    cin >> S >> T;
    sort(ALL(S));
    sort(ALL(T));
    reverse(ALL(T));
    cout << (S < T ? "Yes": "No") << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, t;
    cin >> n >> t;
    vector<ll> h(n);
    REP(i, n) cin >> h[i];

    ll sum = 0, ma = 0;
    vector<ll> ans(n);
    REP(i, n) {
        sum += h[i];
        chmax(ma, h[i]);
        if(t < sum) ans[i] = 1;
        else ans[i] = (t - sum) / ma + 2;
        dump(t, sum, ma, ans[i]);
    } 

    REP(i, n) cout << ans[i] << endl;

    return 0;
}


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

using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> H(N+1),dp(N+1);
    for(int i=1;i<N+1;i++){
        int h;
        cin>>H[i];
    }
    H[0] = H[1];
    for(int i=2;i<N+1;i++){
        dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]));
    }
    cout<<dp[N]<<endl;;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
 
int main() {
  int N; cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  map<int,int> data;
  for (int i = 0; i < N; i++) data[a[i]]++;
  
  bool can = false;
  
  if (data.size() == 1) {
    if (data.count(0)) can = true;
  } else if (data.size() == 2) {
    if (data.count(0)) {
      int a0,a1;
      for (auto i : data) {
        if (i.first == 0) a0 = i.second;
        else a1 = i.second;
      }
      if (2*a0 == a1) can = true;
    }
  } else if (data.size() == 3) {
    vector<int> b(3),c(3);
    int j = 0;
    for (auto i : data) {
      b[j] = i.first;
      c[j] = i.second;
      j++;
    }
    bitset<30> p(b[0]);
    bitset<30> q(b[1]);
    bitset<30> r(b[2]);
    auto s = p ^ q;
    if (s == r && c[0] == c[1] && c[1] == c[2]) can = true;
  }
  
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 4224
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    int r;
    cin>>r;
    cout<<r*r<<endl;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static int[] tree;
	public static int[] dep;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] p = new int[n];
		tree = new int[n];
		dep = new int[n];
		for(int i = 0; i < n; i++) {
			p[i] = sc.nextInt() - 1;
			tree[i] = i;
			dep[i] = 0;
		}
		for(int i = 0; i < m; i++) {
			union(sc.nextInt() - 1, sc.nextInt() - 1);
		}
		int ans = 0;
		for(int i = 0; i < n; i++) {
			if(root(p[i]) == root(i)) {
				ans++;
			}
		}
		System.out.println(ans);
	}

	public static int root(int i) {
		if(tree[i] == i) {
			return i;
		} else {
			return root(tree[i]);
		}
	}

	public static void union(int i, int j) {
		int iroot = root(i);
		int jroot = root(j);
		if(dep[iroot] <= dep[jroot]) {
			tree[iroot] = jroot;
			dep[jroot]++;
		} else {
			tree[jroot] = iroot;
			dep[iroot]++;
		}
	}

}


Measured memory_bytes: 93616
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/


#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

const int INF = 2147483647;
//const ll LINF = ll();今度書く

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	char a[100], b[100];
	int ab;
	string aa, bb;
	scanf("%s%s", a, b);
	aa = a;
	bb = b;
	ab = stoi(aa + bb);
	printyn(pow(int(sqrt(ab)), 2) == ab);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N=100005;
using namespace std;
struct edge{
	int to,next;
}e[N*2];
int head[N],tot;
int n,f[N][2];
void add(int x,int y){
	e[++tot]=(edge){y,head[x]};
	head[x]=tot;
}
void dfs(int x,int fa){
	f[x][1]=1;
	for (int i=head[x];i;i=e[i].next)
		if (e[i].to!=fa){
			dfs(e[i].to,x);
			f[x][0]=(f[x][0]&f[e[i].to][0])|
					(f[x][1]&f[e[i].to][1]);
			f[x][1]&=f[e[i].to][0];
		}
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	dfs(1,0);
	puts(f[1][0]?"Second":"First");
}

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

int main(){
    int K, X, Y;
    cin >> K >> X >> Y;
    if(abs(X) + abs(Y) == K){
        cout << "1\n" << X << " " << Y << endl;
        return 0;
    }

    int xsign = 1, ysign = 1;
    bool sw = false;
    if(X < 0){
        X *= -1;
        xsign = -1;
    }
    if(Y < 0){
        Y *= -1;
        ysign = -1;
    }
    if(X < Y){
        swap(X, Y);
        sw = true;
    }

    int D = X+Y;
    int A = max(2, (D+K-1)/K);
    int L = A * K;
    if((L-D)%2){
        A++;
        L += K;
        if((L-D)%2){
            cout << -1 << endl;
            return 0;
        }
    }
    int R = (L-D)/2;

    vector<pair<int, int>> ans;

    bool ok = true;
    int px = 0, py = 0;
    for(int i=1; i<=A; i++){
        int l = i*K;
        int x, y;
        if(l <= Y+R){
            x = 0;
            y = l;
        }else if(l <= Y+R+X){
            l -= Y+R;
            x = l;
            y = Y+R;
        }else{
            l -= Y+R+X;
            x = X;
            y = Y + (R - l);
        }
        if(abs(px-x) + abs(py-y) == K){
            ans.emplace_back(x, y);
            px = x;
            py = y;
        }else{
            ok = false;
            ans.clear();
            break;
        }
    }

    if(!ok){
        int a = (K+D)/2;
        int b = R-a;
        for(int i=1; i<=A; i++){
            int l = i*K;
            if(l <= a){
                ans.emplace_back(-l, 0);
            }else if(l <= a+Y+b){
                l -= a;
                ans.emplace_back(-a, l);
            }else if(l <= a+Y+b+a+X){
                l -= a+Y+b;
                ans.emplace_back(l-a, b+Y);
            }else{
                l -= a+Y+b+a+X;
                ans.emplace_back(X, Y + (b-l));
            }
        }
    }

    if(sw) for(int i=0; i<A; i++) swap(ans[i].first, ans[i].second);
    cout << A << endl;
    for(auto& p : ans){
        printf("%d %d\n", p.first*xsign, p.second*ysign);
    }
    
    return 0;
}


Measured memory_bytes: 3952
#入力取得
N = int(input())
W = [int(i) for i in input().split()]


min = sum(W)

for i in range(len(W)):
    tmp_sum1 = sum(W[0:i])
    tmp_sum2 = sum(W[i:N])

    diff = tmp_sum1 - tmp_sum2


    if ( abs(diff) < min ):
        min = abs(diff)


print(min)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a + b >= k) {
        cout << min(a, k) << endl;
    } else {
        cout << a - (k - a - b) << endl;
    }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n, k;
  // int nums[10];
  vector<int> nums(200000);
  cin >> n >> k;
  int tmp;
  // rep_i(i, 10){
  //   cout << nums[i] << endl;
  // }
  // cout << endl;
  rep_i(i, n){
    cin >> tmp;
    nums[tmp - 1] += 1;
  }
  auto result = remove_if(nums.begin(), nums.end(), [](int x) { return x == 0; });
  nums.erase(result, nums.end());
  // rep_i(i, 10){
  //   cout << nums[i] << endl;
  // }
  int count = 0;
  sort_v(nums);
  // debug_vi(nums);
  // cout << endl;
  // cout << endl;
  // cout << nums.size() << endl;
  // cout << endl;
  // cout << (int)nums.size() - k << endl;

  if((int)nums.size() - k <= 0){
    cout << count << endl;
    return 0;
  }
  r_rep_i(i, 0, (int)nums.size() - k){
    count += nums[i];
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
n, m, question_num = gets.chomp.split(" ").map(&:to_i)
train_range = Array.new(n+1).map{Array.new(n+1, 0)}

m.times do
    l, r = gets.chomp.split(" ").map(&:to_i)
    train_range[r][l] += 1
end

1.upto(n) do |i|
    1.upto(n) do |j|
        train_range[i][j] += train_range[i][j-1]
    end
end

1.upto(n) do |i|
    1.upto(n) do |j|
        train_range[i][j] += train_range[i-1][j]
    end
end

question_num.times do
    a, b = gets.chomp.split(" ").map(&:to_i)
    puts train_range[b][b] + train_range[a-1][a-1] - train_range[a-1][b] - train_range[b][a-1]
end

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

A,B = inputIL()

print((A-1)*(B-1))

Measured memory_bytes: 63980
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N,K,S;cin>>N>>K>>S;
  for(int i=0;i<K;i++){
    cout<<S<<" ";
  }
  for(int i=K;i<N;i++){
    if(S<1000000000)cout<<S+1<<" ";
    else cout<<S-1<<" ";
  }
  cout<<"\n";

}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define endl "\n"
#define int ll
#define ll long long
#define pb emplace_back
#define fi first
#define se second
#define pll pair<ll, ll>
#define ull unsigned long long
#define ld long double

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=n-1; i>=0; i--)
#define repa(i,a,b) for(ll i=(a);i<=(b);i++)
#define all(x) (x).begin(), (x).end()
#define ordered_set tree<int , null_type, less<int> , rb_tree_tag, tree_order_statistics_node_update>
/*
 Ordered set docs:
 order_of_key (k) : Number of items strictly smaller than k .
 find_by_order(k) : K-th element in a set (counting from zero).
*/
#define blc boost::lexical_cast<long long>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
const int MOD = 1e9+7;

ll add(ll x, ll y) {ll res=x+y; return(res>=MOD?res-MOD:res);}

ll sub(ll x, ll y) {ll res=x-y; return(res<0?res+MOD:res);}

ll lcm(ll x, ll y) {ll res=(x*y)/__gcd(x,y); return res;}

ll powerLL(ll x, ll n, ll mod) 
{ 
    ll result = 1; 
    while (n) { if (n & 1) result = (result%mod * x%mod) % mod; n = n / 2; x = (x%mod * x%mod) % mod; } return result; 
} 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int fun(vector<int> &A, vector<int> &B, int C) {
    int n = A.size();
    int w = C;
    int dp[n+1][w+1];
    for(int i=0; i<=n; i++)
        dp[i][0] = 0;
    for(int i=0; i<=w; i++)
        dp[0][i] = 0;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=w; j++)
        {
            if(B[i-1]<=j)
                dp[i][j] = max(dp[i-1][j], A[i-1]+dp[i-1][j-B[i-1]]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    return dp[n][w];
}
void solve()
{
    int n, w;
    cin>>n>>w;
    vector<int> wei(n);
    vector<int> val(n);
    rep(i,n)
    	cin>>wei[i]>>val[i];
    	//s+=val[i];
    cout<<fun(val, wei, w)<<endl;
}
int32_t main()
{
    fast;
    int t;
    t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0; 
}

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

int main(void)
{
  string s;
  long long k;
  
  cin >> s >> k;
  long long day = 5000000000000000; //5*10^15
  
  long long count = 0;
  for(auto i : s){
      int n = i - '0';
      if(n==1)
        count++;
      if(n!=1 || count >= k){
          cout << n << endl;
          return 0;
      }
  }
  return 0;
}


Measured memory_bytes: 256