akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)

int main() {
  ll k,n;
  cin >> k >> n;
  
  vector<ll> ad(n);
  rep(i, n)
    cin >> ad.at(i);
  
  vector<ll> dist(n);
  rep(i, n-1)
    dist.at(i) = ad.at(i+1) - ad.at(i);
  dist.at(n-1) = ad.at(0) + (k - ad.at(n-1));
    
  sort(dist.begin(),dist.end());
  
  ll sum = 0;
  rep(i, n-1)
    sum += dist.at(i);
  
  cout << sum << endl;
}

Measured memory_bytes: 6416
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000  // スタックの最大値

typedef struct{
  int top;         // スタックポインタ(一番上の位置)
  int S[MAX];
}Stack;


// スタック st の初期化
void initialize(Stack *st)
{
  st->top = 0;
  st->S[st->top] = 0;
}

// スタック st が空かどうかを確認
int isEmpty(Stack *st)
{
  return st->top == 0;
}

// スタック st が一杯かどうかを確認
int isFull(Stack *st)
{  
  return st->top >= MAX - 1;
}

// スタック st に要素 x をプッシュ(一番上に要素を追加)
void push(int x, Stack *st)
{
  if (isFull(st)) 
    exit(1);

  st->top++;
  st->S[st->top] = x;
}

// スタック st から要素をポップ(一番上の要素を取り出す)
int pop(Stack *st) {
  if (isEmpty(st)) 
    exit(1);

  st->top--;
  return st->S[st->top+1];
}


int main(void)
{
  Stack st1;     // '\' の開始位置を格納するスタック
  Stack st2_j;   // 各水たまりの最も左の'\' の位置を格納するスタック
  Stack st2_a;   // 各水たまりの水量を格納するスタック

  // スタック初期化
  initialize(&st1);
  initialize(&st2_j);
  initialize(&st2_a);

  char c;
  int sum = 0;  // 水たまりの総水量

  // 地形を読み込み，各水たまりの水量を計算
  for (int i = 0; (c = getchar()) != EOF; i++) {
    if (c == '\\') {                                 // '\' が出た時の処理
      // 位置 i を st1 にプッシュ(write your code)
    	
    	push(i,&st1);
    	
    }else if (!isEmpty(&st1) && c == '/') {          // '/' が出た時の処理
      // 水たまりの総水量 sum を更新(write your code)
      
    	int j=pop(&st1);
    	sum+=i-j;	
    	
      // st2_j と st2_a を用いて水たまりの水量を更新 
      int a = i - j;   // 更新する水たまりの水量を a に格納していく
      while (!isEmpty(&st2_j) && st2_j.S[st2_j.top] > j) {  // 最も左の '\' の位置が j よりも大きい場合，以下を繰り返す
        // 水たまりの水量を求めていく (write your code)
      	
      	a+=pop(&st2_a);
      	int t=pop(&st2_j);
      	
      }
      // 更新した水たまりの「最も左の'\' の位置」および「水量」を更新 (write your code)
    	
    	push(j,&st2_j);
    	push(a,&st2_a);
    	
    }
  }

  printf("%d\n", sum);       // 水たまりの総水量を出力
  printf("%d", st2_a.top);   // 水たまりの個数を出力

  // 各水たまりの水量を断面図の左から出力(スタックの底から出力)
  for (int i = 1; i <= st2_a.top; i++) 
    printf(" %d", st2_a.S[i]);  
  printf("\n");

  return 0;
}



Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] colorInfo = new int[8];
		int freeColor = 0;
		for(int i=0;i <n;i++) {
			int rate = sc.nextInt();
			if(rate >= 3200) {
				freeColor++;
				continue;
			}
			if(rate <=399) {
				colorInfo[0]++;
				continue;
			}
			if(rate <=799) {
				colorInfo[1]++;
				continue;
			}
			if(rate <=1199) {
				colorInfo[2]++;
				continue;
			}
			if(rate <=1599) {
				colorInfo[3]++;
				continue;
			}
			if(rate <=1999) {
				colorInfo[4]++;
				continue;
			}
			if(rate <=2399) {
				colorInfo[5]++;
				continue;
			}
			if(rate <=2799) {
				colorInfo[6]++;
				continue;
			}
			if(rate <=3199) {
				colorInfo[7]++;
				continue;
			}
		}

		int min =0;
		for(int i =0;i <=7;i++) {
			if(colorInfo[i] >0) {
				min++;
			}
		}
		if(min ==0) {
			min =1;
			freeColor--;
		}
		int max = min + freeColor;
		System.out.println(min + " " + max);
	}
}

Measured memory_bytes: 21972
from itertools import permutations

def fact(n):
    if n == 0:
        return 1
    return n * fact(n-1)

N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]
s = 0
for p in permutations(list(range(N))):
    for i in range(N-1):
        dx = xy[p[i+1]][0] - xy[p[i]][0]
        dy = xy[p[i+1]][1] - xy[p[i]][1]
        s += (dx**2+dy**2)**.5
print(s/fact(N))

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

int top, S[1000];

void push(int x){
	S[++top]=x;
}

int pop(){
 top--;
	return S[top+1];


}


int main(){
	int a,b;
	top = 0;
	char s[100];
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			push(atoi(s));
		
		}
	}

	printf("%d\n",pop());
	return 0;
	
}



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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

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

int n;
char s, t, b;
double p[2][3][3];

int getX(char c) { return (c - 'A') % 3; }
int getY(char c) { return (c - 'A') / 3; }

void solve() {
	for_(y,0,3) for_(x,0,3) p[0][y][x] = 0.;
	p[0][getY(s)][getX(s)] = 1.0;
	
	for_(i,0,n) {
		for_(y,0,3) for_(x,0,3) p[1][y][x] = 0.;
		for_(y,0,3) for_(x,0,3) {
			for_(d,0,4) {
				int nx = x + dx[d], ny = y + dy[d];
				if ((nx < 0 || nx >= 3 || ny < 0 || ny >= 3) ||
					(ny == getY(b) && nx == getX(b))) {
					nx = x;
					ny = y;
				}
				p[1][ny][nx] += p[0][y][x] * 0.25;
			}
		}
		swap(p[0], p[1]);
	}
	
	cout << setprecision(12) << setiosflags(ios::fixed) << p[0][getY(t)][getX(t)] << endl;
}

int main() {
	while (cin >> n, n) {
		cin >> s >> t >> b;
		solve();
	}
}


Measured memory_bytes: 3152
#include <stdio.h>

#define N 100
#define A 0
#define B 1
#define C 2

int D[N][N],E[N],a[N],b[N];
int c,n;

void X(int z);
void Y();

int main(){
  
  int z,v,w,i,j;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    
    for(j=0;j<n;j++)
      
      D[i][j]=0;
    
  }

  for(i=0;i<n;i++){
    
    scanf("%d %d",&z,&w);
    
    z--;
    
    for(j=0;j<w;j++){
      
      scanf("%d",&v);

      v--;
      
      D[z][v]=1;
    }
  }

  Y();

  return 0;
}

void X(int z){
  
  int i;
  
  E[z]=B;
  
  a[z]=++c;
  
  for(i=0;i<n;i++){
    
    if(D[z][i]==0)
      continue;
    
    if(E[i]==A){
      
      X(i);
    }
  }
  E[z]=C;
  b[z]=++c;
}

void Y(){
  
  int z;
  
  for(z=0;z<n;z++)
    
    E[z]=A;
  
  c=0;

  for(z=0;z<n;z++){
    
    if(E[z]==A)
      
      X(z);
  }
  for(z=0;z<n;z++){
    
    printf("%d %d %d\n",z+1,a[z],b[z]);
    
  }
}




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

int main() {
  int I,S;
  cin>>I>>S;
  int64_t Z=1,Q=1000000007;
  
  if(I==S){
     for(int i=1;i<=I;i++){
       Z*=i;
       Z=Z%Q;
     }
    Z*=Z;
    Z=(Z*2)%Q;
  }
  else if(I==S+1||I+1==S){
    for(int i=1;i<=min(I,S);i++){
      Z*=i;
      Z=Z%Q;
    }
    Z*=Z;
    Z=Z%Q;
    Z*=max(I,S);
    Z=Z%Q;
  }
  else{
    Z=0;
  }
  cout<<Z<<endl;
    
}

Measured memory_bytes: 256
/*
tarun360
IIT Indore
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define forn_s(i,start,lim) for(ll_s i=start;i<lim;i++)
#define forn_d_s(i,start,lim) for(ll_s i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define debug1(a) cout<<a<<endl
#define debug2(a,b) cout<<a<<" "<<b<<endl
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define debug4(a) cout<<"chu "<<a<<endl

ll a[105],amin=1e18,n;
ll memo[100005][2];

bool f(ll k, bool x){
  if(k<amin)
    return !x;
  if(memo[k][x]==0)
    return 0;
  else if(memo[k][x]==1)
    return 1;
  bool ans;
  if(x==1)
    ans=0;
  else
    ans=1;
  forn(i,0,n){
    if(x==1){
      if(k-a[i]>=0)
        ans=(ans||f(k-a[i],!x));
    }else{
      if(k-a[i]>=0)
        ans=(ans&&f(k-a[i],!x));
    }
  }
  if(ans==0) memo[k][x]=0;
  else memo[k][x]=1;
  return ans;
}

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  forn(i,0,1e5+5) memo[i][0]=memo[i][1]=-1;
  ll k;
  cin>>n>>k;
  forn(i,0,n) {
    cin>>a[i];
    amin=min(amin,a[i]);
  }
  bool ans=f(k,0);
  if(ans==0) cout<<"First"<<endl;
  else cout<<"Second"<<endl;
  return 0;
}


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

#define int long long

void solve() {
    bool x;
    cin >> x;
    cout << !x;
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    //cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3564
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static double[][] xy;
    static void Main()
    {
        int N = int.Parse(ReadLine());
        var xy = new double[N][];
        double ans = 0;
        for (int i = 0; i < N; i++)
        {
            xy[i] = ReadLine().Split().Select(double.Parse).ToArray();
        }
        for (int i = 0; i < N; i++)
        {
            for (int j = i; j < N; j++)
            {
                ans += Sqrt(Pow(xy[i][0] - xy[j][0], 2) + Pow(xy[i][1] - xy[j][1],2));
            }
        }
        WriteLine(ans*2/N);
    }
    
}


Measured memory_bytes: 28280
#include <bits/stdc++.h>
using namespace std;
long long i,j,n,m,t,k,ans,x,dp[200001][3],B,a[200001][3],Min1,Min2;
int main () {
    cin>>n;
    for (i=1;i<=n;i++) {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    dp[1][0]=a[1][0];
    dp[1][1]=a[1][1];
    dp[1][2]=a[1][2];
    for (i=2;i<=n;i++) {
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
    return 0;
}

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

#define MAXN    100004

int n, X;
int x[MAXN];

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

int main()
{
    int i;
    scanf("%d%d", &n, &X);
    int g = 0;
    for (i = 0; i < n; ++i) {
        scanf("%d", &x[i]);
        g = gcd(g, abs(x[i] - X));
    }
    printf("%d\n", g);
    return 0;
}


Measured memory_bytes: 512
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,K = map(int,readline().split())
R,S,P = map(int,readline().split())
T = read().rstrip().decode('utf-8')

k_to_word = [[] for _ in range(K)]
for i,x in enumerate(T):
    k = i % K
    k_to_word[k].append(x)

def solve(A):
    # 直前と同じ手は出せない、というルール
    r,s,p = 0,0,0 # 直前に出した手 -> 最大スコア
    for x in A:
        if x == 'r':
            r,s,p = max(s,p),max(r,p),max(r,s)+P
        elif x == 's':
            r,s,p = max(s,p)+R,max(r,p),max(r,s)
        elif x == 'p':
            r,s,p = max(s,p),max(r,p)+S,max(r,s)
    return max(r,s,p)

answer = sum(solve(A) for A in k_to_word)
print(answer)


Measured memory_bytes: 13492
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }

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

	for(int n; cin >> n, n;) {
		vector<int> dp((1 << 16), 0);
		for(int i = 0; i < n; ++i) {
			int m, l;
			cin >> m >> l;

			int schedule = 0;
			for(int j = 0; j < m; ++j) {
				int s, e;
				cin >> s >> e;

				for(int k = s - 6; k < e - 6; ++k)
					schedule |= (1 << k);
			}

			for(int k = 0; k < (1 << 16); ++k)
				if(!(schedule & k))
					chmax(dp[(schedule | k)], dp[k] + l);
		}

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

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1464
# スペース区切りの整数の入力(定数)
list_num = [num for num in input().split()]

#　計算と出力
if list_num[1] == "+" :
    print(int(list_num[0])+int(list_num[2]))
else :
    print(int(list_num[0])-int(list_num[2]))  

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

const int MOD = 998244353;
class mint {
    ll x;
public:
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    
    mint operator -() const {
        return mint(-x);
    }
    
    mint &operator +=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator -=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator *=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator +(const mint &a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator *(const mint &a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(MOD - 2);
    }

    mint &operator /=(const mint &a) {
        return (*this) *= a.inv();
    }

    mint operator /(const mint &a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream &operator<<(ostream& os, const mint &m) {
        os << m.x;
        return os;
    }
};


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

    ll N, S;
    cin >> N >> S;
    vec A(N);
    Rep (i, N) {
        cin >> A[i];
    }

    vector<vector<mint>> dp(N+1, vector<mint>(S+1, 0));
    dp[0][0] = 1;
    Rep (i, N) {
        Rep (j, S+1) {
            if (j+A[i] <= S) dp[i+1][j+A[i]] += dp[i][j];
            dp[i+1][j] += dp[i][j];
        }
        dp[i+1][0] = i+2;
    }

    // Rep (i, N+1) {
    //     Rep (j, S+1) {
    //         cout << dp[i][j] << " \n"[j==S];
    //     }
    // }

    mint ans(0);
    Rep (i, N+1) {
        ans += dp[i][S];
    }

    cout << ans << "\n";
}

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

using namespace __gnu_pbds;
using namespace std;

template <class T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

void usaco(string name = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(name.size())
    {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main()
{
    usaco();
    int n, k;
    cin >> n >> k;
    vector <int> a(n), dp(n, 1e9);
    for (int i = 0; i < n; ++i) cin >> a[i];
    dp[0] = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 1; j <= k; ++j)
        {
            if (i+j >= n) break;
            else dp[i+j] = min(dp[i+j], dp[i]+abs(a[i+j]-a[i]));
        }
    }
    cout << dp[n-1] << '\n';
}



Measured memory_bytes: 3972
from sys import stdin
import itertools
N, M = [int(x) for x in stdin.readline().rstrip().split()]
K = []
S = []
for i in range(M):
    k, *s = map(int, input().split())
    K.append(k)
    S.append(s)
P = [int(x) for x in stdin.readline().rstrip().split()]

ans = 0
for n in list(itertools.product([0,1],repeat=N)):
    flag = True
    for ind,s in enumerate(S):
        fired = 0
        for s_index in s:
            if n[s_index - 1] == 1:
                fired += 1
        if fired % 2 != P[ind]:
            flag = False
    if flag:
        ans += 1
print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			int a = s.nextInt();
			int b = s.nextInt();
			int t = s.nextInt();
			System.out.println(t / a * b);
		}
	}

}


Measured memory_bytes: 21844
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver());
        }
        static long solver()
        {
            var XY = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var X = XY[0]; var Y = XY[1];
            if ((X + Y) % 3 != 0) return 0;
            if (X > 2 * Y || Y > 2 * X) return 0;
            var moveX = 0; var moveY = 0;
            while (X * 2 != Y && Y * 2 != X)
            {
                X -= 3;
                Y -= 3;
                moveX++;
                moveY++;
            }
            moveX += Math.Min(X, Y);
            Combination.combInit(10000000, 1000000007);
            return Combination.combination(moveX + moveY, moveY);

        }
    }
    static class Combination
    {
        static long combMax;
        static long combMOD;

        static long[] factorial;
        static long[] inverse;
        static long[] factInv;

        public static void combInit(long _max, long _mod)
        {
            combMax = _max;
            combMOD = _mod;
            factorial = new long[combMax];
            inverse = new long[combMax];
            factInv = new long[combMax];

            factorial[0] = factorial[1] = 1;
            factInv[0] = factInv[1] = 1;
            inverse[1] = 1;

            for (int i = 2; i < combMax; i++)
            {
                factorial[i] = factorial[i - 1] * i % combMOD;
                inverse[i] = combMOD - inverse[combMOD % i] * (combMOD / i) % combMOD;
                factInv[i] = factInv[i - 1] * inverse[i] % combMOD;
            }
        }

        public static long combination(int n, int k)
        {
            if (n < k) return 0;
            if (n < 0 || k < 0) return 0;
            return factorial[n] * (factInv[k] * factInv[n - k] % combMOD) % combMOD;
        }
    }
}


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

string s, t, pat;
int ans[10000000];

vector <int> build_fail(const string &p) {
	int len = (int)p.size(), j = -1;
	vector <int> fail(len + 1, 0); fail[0] = -1;
	for (int i = 1; i <= len; fail[i++] = ++j)
		while (j >= 0 && p[j] != p[i - 1]) j = fail[j];
	return fail;
}
pair <vector <int>, vector <int> >
kmp_match(const string &t, const string &p, const vector <int> &fail) {
	int n = (int)t.size(), m = (int)p.size();
	vector <int> len(n, 0), chk(n, 0);
	for (int i = 0, j = 0; i < n; ++i) {
		while (j >= 0 && p[j] != t[i]) j = fail[j];
		chk[i] = ((len[i] = ++j) == m);
	}
	return make_pair(len, chk);
}

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> s >> t, pat = s;
	int n = (int)s.size(), m = (int)t.size();
	int exsize = n + m << 1;
	while ((int)s.size() < exsize) s += pat;
	s += pat, n = (int)s.size();
	pair <vector <int>, vector <int> > pr = kmp_match(s, t, build_fail(t));
	vector <int> len = pr.first, chk = pr.second;
	for (int i = n - 1; ~i; --i)
		if (chk[i]) ans[i - m + 1] = max(ans[i - m + 1], ans[i + 1] + 1);
	int res = *max_element(ans, ans + n + 1);
	if (res >= n / m - 2) return puts("-1") & 0;
	cout << res << endl;
	return 0;
}


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

int main(){
  
  string n;
  cin >>n;
  if(n.size()==1) cout <<n[0]-'0' << endl;
  else if(n.size()==2) cout << 9 << endl;
  else if(n.size()==3) cout << 9+((n[0]-'0')*100+(n[1]-'0')*10+(n[2]-'0'))-99 << endl;
  else if(n.size()==4) cout << 909 << endl;
  else if(n.size()==5) cout << 909+((n[0]-'0')*10000+(n[1]-'0')*1000+(n[2]-'0')*100+(n[3]-'0')*10+(n[4]-'0'))-9999 << endl;
  else cout << 90909 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

    std::vector<std::string> s(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> s[i];
    }

    std::sort(s.begin(), s.end());
    for (int i = 0; i < n; i++)
    {
        std::cout << s[i];
    }

    std::cout << "\n";
}

Measured memory_bytes: 3664
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let sv: Vec<String> = read_vec();

    let mut stack: Vec<i32> = Vec::new();

    for s in sv {
        if s == "+" {
            let b = stack.pop().unwrap();
            let a = stack.pop().unwrap();
            stack.push(a + b);
        } else if s == "-" {
            let b = stack.pop().unwrap();
            let a = stack.pop().unwrap();
            stack.push(a - b);
        } else if s == "*" {
            let b = stack.pop().unwrap();
            let a = stack.pop().unwrap();
            stack.push(a * b);
        } else {
            let num: i32 = s.parse().unwrap();
            stack.push(num);
        }
    }

    println!("{}", stack[0]);
}



Measured memory_bytes: 5040
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
int a[100005];
int main(){
	int n,i,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
        scanf("%d",&x);
        a[x]=i;
	}
	for(i=1;i<=n;i++){
        printf("%d ",a[i]);
	}
	return 0;
}


Measured memory_bytes: 2076
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	std::string S;
	in >> S;

	LL cnt = 0;
	rep(i, S.length())
	{
		if (S[i] == 'o') ++cnt;
	}
	cnt += 15 - (LL)S.length();

	out << (cnt >= 8 ? "YES" : "NO") << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
int R,C,s[10000][10],f[10],N,i,j,n,m;void rec(int k){if(k<R){f[k]=0;rec(k+1);f[k]=1;rec(k+1);}else for(n=i=0;i<C;i++,n+=m>R-m?m:R-m,N=N>n?N:n)for(m=j=0;j<R;j++)m+=s[i][j]^f[j];}main(){for(;std::cin>>R>>C,R|C;rec(0),printf("%d\n",N))for(j=R;j-->0;)for(i=C;i-->0;)std::cin>>s[i][j];}

Measured memory_bytes: 1260
import math

a, b, n = map(int, input().split())
def f(x):
    return (a * x) // b - a * (x // b)

left, right = 0, n
# 答えが整数になる場合このrightとleftの幅を3未満にするとバグる
while abs(right - left) > 3:
    mid1 = (right * 2 + left) // 3 + 1
    mid2 = (right + left * 2) // 3
    if f(mid1) <= f(mid2):
        # 上限を下げる（最小値をとるxはもうちょい下めの数だな）
        right = mid1
    else:
        # 下限を上げる（最小値をとるxはもうちょい上めの数だな）
        left = mid2
ans = 0
for i in range(left, right + 1):
    ans = max(ans, f(i))
print(max(ans, f(0), f(n)))

Measured memory_bytes: 62152
from collections import defaultdict
d = defaultdict(list)
n, m = map(int, input().split())
h = list(map(int, input().split()))

for i in range(m):
  a, b = map(int, input().split())
  d[a].append(b)
  d[b].append(a)

ans = 0
for k, v in d.items():
  h_a = h[k - 1]
  k = 1
  for e in v:
    h_b = h[e - 1]
    if h_a > h_b:
      next
    else:
      k = 0
      break
  ans += k
ans += n - len(d)
print(ans)

Measured memory_bytes: 31728
import sys

a = [int(i) for i in input().split()]
x=0
i=0
b=a[1]
while i < a[0]:
  x+=b
  b+=1
  i+=1
if a[1]>=0:
  x-=a[1]
  print(x)
elif a[1]<0 and a[0]+a[1]<=0:
  x=x-b+1
  print(x)
else:
  print(x)
  

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  while(n!=0 || x!=0){
    int cnt=0;
    for(int i=1;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        for(int k=j+1;k<=n;k++){
          if(i+j+k==x) cnt++;
        }
      }
    }
    cout << cnt << endl;
    cin >> n >> x;
  }
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
int fact(int n){
  int m;
  if (n == 0)
      return 1;
  m = fact(n - 1);    
  return n * m;       
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
   int n;
   string s;
   cin>>n>>s;
   int si=s.size();
   rep(i,si){
     rep(j,n){
       if(s[i]=='Z'){
         s[i]='A';
       }
       else{
         s[i]++;
       }
   }
   }
   cout<<s<<'\n';
    return(0);
}

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

typedef long long ll;
#define MAX_N 10000
#define INF 0x3f3f3f3f

using namespace std;

int N;
int solve(int n);

int main()
{
	while (~scanf("%d", &N)) {
		cout << (!(N % solve(N)) ? ("Yes") : ("No")) << endl;
	}
    return 0;
}

int solve(int n) {
	int res = 0;
	while (n) {
		res += n % 10;
		n /= 10;
	}
	return res;
}


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

using namespace std;

vector<int> Z(string s) {
    vector<int> z(s.size() , 0);
    int l = 0 , r = 0;
    for (int i = 1 ;i < s.size() ;i++) {
        if (i <= r)
            z[i] = min(z[i - l] , r - i + 1);

        while (i + z[i] < s.size() && s[i + z[i]] == s[z[i]])
            z[i]++;

        if (i + z[i] - 1 > r)
            l = i , r = i + z[i] - 1;
    }

    return z;
}

const int N = 1e6 + 5;
vector<int> adj[N];
int vis[N];

bool cycle(int node) {
    if (vis[node])
        return vis[node] == 1;

    vis[node] = 1;
    for (int c : adj[node])
        if (cycle(c))
            return 1;
    vis[node] = 2;

    return 0;
}

int memo[N];
int solve (int node) {
    int &ret = memo[node];
    if (~ret)
        return ret;

    ret = 0;
    for (int c : adj[node])
        ret = max(ret , solve(c) + 1);

    return ret;
}

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

    string s , t;
    cin >> s >> t;

    while (s.size() < t.size())
        s += s;

    int n = s.size();
    int m = t.size();

    vector<int> z = Z(t + "$" + s + s);
    int st = m + 1;
    int en = st + n - 1;

    for (int i = st ;i <= en ;i++)
        if (z[i] >= m)
            adj[i - st].push_back((i - st + m) % n);

    for (int i = 0 ;i < s.size() ;i++) {
        if (cycle(i)) {
            cout << -1;
            return 0;
        }
    }

    memset(memo , -1 , sizeof memo);
    int mx = 0;
    for (int i = 0 ;i < s.size() ;i++)
        mx = max(mx , solve(i));

    cout << mx;
}


Measured memory_bytes: 96372
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using ull = unsigned long long;

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  string s;
  cin >> s;

  if ( (s.length() % 2 == 1) ^ s[0] == s[s.length() - 1]) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
  /* */

  return EXIT_SUCCESS;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

#define roundup(n,d) (((n) + ((d)-1)) / (d))
#define ll long long

using namespace std;

int main(void){
    string s1,s2;
    cin >> s1 >> s2;
    string s = s1 + s2;
    int n = stoi(s);
    int sq = sqrt(n);
    s = (double)sqrt(n)-sq ? "No" : "Yes";
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int n;
string s;
ll ans = 0;

void solve(ll x,ll y){
    if(x==n+1){
        ans += y;
        return;
    }
    ll cur = 0;
    for(ll i=x;i<=n;i++){
        cur = (10*cur) + (s[i]-'0');
        solve(i+1,y+cur);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int cnt=0;
    for(int i=0;i<n;i++){
        int l,r;
        cin>>l>>r;
        cnt+=(r-l+1);
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3640
a, b, c = gets.chomp.split(" ").map(&:to_i)

number = 0
sum = 0

while number <= a
  mod_10 = number % 10
  mod_100 = (number % 100) / 10
  mod_1000 = (number % 1000) / 100
  mod_10000 = (number % 10000) / 1000
  mod_100000 = (number % 100000) / 10000

  mod_sum = mod_10 + mod_100 + mod_1000 + mod_10000 + mod_100000
  if  mod_sum >= b && mod_sum <= c
    sum += number
  end
  number += 1
end

puts sum

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



signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll s;
  
  cin >> s;
  
  vector<ll> a(1000000);
  a[0] = s;
  
  rep(j, 0, a.size()+1) {
    if(a[j] %2==0) a[j+1] = a[j]/2;
    else a[j+1] = 3*a[j] +1;
    
    rep(i, 0, j+1) {
      rep(k, i+1, j+1) {
        if(a[i] == a[k]) {
          cout << k+1 << "\n";
          return 0;
        }
      }
    }
  }
  
}


Measured memory_bytes: 8064
#include <iostream>
using namespace std;
using Int = int64_t;
static const Int MOD = 1e9 + 7;
Int modfact(Int n) {
    if (n == 1) return 1;
    return (n * modfact(n - 1)) % MOD;
}
int main() {
    Int n;
    cin >> n;
    cout << modfact(n) << endl;
}


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

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();

            if (s.equals("zyxwvutsrqponmlkjihgfedcba")) {
                out.println(-1);
                return;
            }

            if (s.length() < 26) {
                boolean[] b = new boolean[26];
                for (int i = 0; i < s.length(); i++) {
                    b[s.charAt(i) - 'a'] = true;
                }

                for (int i = 0; i < 26; i++) {
                    if (!b[i]) {
                        out.println(s + (char) ('a' + i));
                        return;
                    }
                }
            }

            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(s.length() - 2 - i) < s.charAt(s.length() - 1 - i)) {
                    char c = s.charAt(s.length() - 1 - i);
                    for (int j = s.length() - 1 - i; j < s.length(); j++) {
                        if (s.charAt(j) > s.charAt(s.length() - 2 - i)) {
                            c = s.charAt(j);
                        }
                    }
                    out.println(s.substring(0, s.length() - 2 - i) + c);
                    return;
                }
            }
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

void __reverse(int* a, int b , int e){
    int c[e-b+1];  
    for(int i=e-1, j=0 ; i>=b ; --i , ++j){
        c[j] = a[i]; 
    }
    for(int i = b , j = 0 ; i < e ; ++i , ++j ){
        a[i] = c[j];
    }
    return;
}

int main(){
    int n; cin >> n;
    int a[n];
    rep(i ,n) cin >> a[i];
    int q; cin >> q;
    rep(i , q){
        int b , e;
        cin >> b >> e;
        __reverse(a,b,e);
    }
    for(int i=0;i<n-1;++i){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
}


Measured memory_bytes: 3108
from collections import defaultdict
N,P = map(int,input().split())
factors = defaultdict(int)
i = 2
while i**2<=P:
    while P%i==0:
        P //= i
        factors[i] += 1
    i += 1
if P>1:
    factors[P] += 1
ans = 1
for k,v in factors.items():
    if N<=v:
        ans *= k**(v//N)
print(ans)


Measured memory_bytes: 39408
def main(): 
  n,m=map(int,input().split())
  py=[list(map(int,input().split()))+[i+1] for i in range(m)]
  py.sort(key=lambda x:(x[0],x[1],x[2]))
  py[0].append(1)
  cnt=1
  for i in range(1,m):
    cnt=cnt+1 if py[i][0]==py[i-1][0] else 1
    py[i].append(cnt)
  py.sort(key=lambda x:x[-2])
  for a,b,c,d in py:
    print(str(a).zfill(6)+str(d).zfill(6))
if __name__=='__main__':
  main()

Measured memory_bytes: 36100
h, n = gets.split.map &:to_i
Magic = Struct.new(:damage, :mp)
magics = n.times.map {Magic[*gets.split.map(&:to_i)]}.sort_by(&:damage).reverse!
damage_max = magics.map(&:damage).max

dp = [0] * damage_max
h.times do |hp|
  hp += damage_max
  dp[hp] = magics.map { |magic| dp[hp - magic.damage] + magic.mp }.min
end

p dp[h + damage_max - 1]

Measured memory_bytes: 56036
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;
const int64_t ZER=0LL;

int main() {
  int64_t N,K,ans=-1*INF; cin>>N>>K;
  vector<int64_t> P(N);
  rep(i,N) cin>>P.at(i);
  rep(i,N) P.at(i)--;
  vector<int64_t> C(N);
  rep(i,N) cin>>C.at(i);
  
  rep(i,N){
    vector<bool> seen(N,true);
    vector<int64_t> S,T;
    int64_t k=i,sum=0;
    while(seen.at(k)){
      seen.at(k)=false;
      S.push_back(C.at(k));
      sum+=C.at(k);
      k=P.at(k);
    }
    int64_t t=S.size(),r=K/t,q=K%t,MAX=-1*INF,NMAX=0;
    rep(i,t){
      T.push_back(S.at(i));
      if(i>0) T.at(i)+=T.at(i-1);
      if(T.at(i)>MAX){
        MAX=T.at(i);
        NMAX=i+1;
      }
    }
      if(q<NMAX){
        int64_t MAX2=-1*INF;
        rep(i,q) MAX2=max(MAX2,T.at(i));
        auto temp=max(MAX,max(MAX+sum*(r-1),MAX2+sum*r));
        if(K>=NMAX)ans=max(ans,temp);
        else ans=max(ans,MAX2);
      }
      else ans=max(ans,max(MAX,MAX+sum*r));
  }
  cout<<ans;
}


Measured memory_bytes: 3808
import math
N,H = map(int,input().split())
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
y = sorted(y)
xm = max(x)
d = 0
a = 1
while a:
  if xm > y[-a]: 
    a= a-1
    break
  d += y[-a]
  if d>=H:
    break
  if a == N: break
  a +=1
if d>= H:
  print(a)
else:
  e = math.ceil((H-d)/xm)
  print(a+e)

Measured memory_bytes: 12160
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

int main(void){
	ll N,A[100010],sum=0;
	scanf("%lld",&N);
	A[0]=0;
	A[N+1]=0;
	reg(i,1,N)scanf("%lld",&A[i]);
	reg(i,0,N+1)sum+=abs(A[i]-A[i-1]);
	reg(i,1,N){
		ll a = sum + abs(A[i-1]-A[i+1]) - abs(A[i-1]-A[i]) - abs(A[i]-A[i+1]);
		printf("%lld\n",a-N);
	}
	return 0;
}

Measured memory_bytes: 2048
n = gets.to_i
INF = 10 ** 9
nodes = []
n.times do
  nodes << gets.split.map(&:to_i)
end
from_left_down = nodes.map { |x, y| x + y }.sort.reverse
from_right_down = nodes.map { |x, y| (INF - x) + y }.sort.reverse
from_left_up = nodes.map { |x, y| (INF - x) + (INF - y) }.sort.reverse
from_right_up = nodes.map { |x, y| x + (INF - y) }.sort.reverse
puts [from_left_down.first - from_left_down.last, from_right_down.first - from_right_down.last, from_left_up.first - from_left_up.last, from_right_up.first - from_right_up.last].max


Measured memory_bytes: 47580
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;cin>>s;
  int mini = 100000000;
  for(int i=0;i<(int)s.size()-2;i++){
  	int nos=(s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0';
    mini = min(mini,abs(nos-753));
  }
  cout<<mini;
}

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

int main(){

    string s;
    cin >> s;
    map<char,int> m;
    rep(i,s.size()){
        m[s[i]]++;
    }

    for(auto it=m.begin();it!=m.end();it++){
        if(it->second!=2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

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



int main(){
    
    string s;
    cin>>s;
    if(s[0] == s[2]){
        cout<<"Yes"<<endl;
    }else
    {
        cout<<"No"<<endl;
    }
    
    
    return 0;
    
}


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

int main(int argc, char const *argv[])
{
	int a, b; cin >> a >> b;
	if (a * b % 2 == 0) printf("No\n");
	else printf("Yes\n");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include<cmath>
using namespace std;
int main(){
    int a,b,c,x,y,same;
    long long int mon=0;
	scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
	if(x==0) mon=y*b;
	else if(y==0) mon=x*a;
	else{
		same=max(x,y)-abs(x-y);
		if(2*c>a+b) mon+=(a+b)*same;
		else mon+=2*c*same;
		int k=(x-y>0?x:y)-same;
		if(x>y) mon+=k*a;
		else mon+=k*b;
	}
	long long int m;
	m=2*c*max(x,y);
	printf("%lld",min(mon,m));
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	int n;
	cin >> n;
	int a[200000] = {};
	int t;
	for (int i = 1; i < n; i++) {
		cin >> t;
		a[t - 1]++;
	}

	for (int i = 0; i < n; i++) {
		cout << a[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 4416
while True:
    H, W = map(int, input().split())
    if  H == 0 and W==0: break
    for i in range(H):
         if i % 2 ==0:
             print("#."*(W//2)+"#"*(W%2))
         if i % 2 ==1:
             print(".#"*(W//2)+"."*(W%2))
    print("")



Measured memory_bytes: 5612
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
using namespace std;

const int MOD = pow(10, 9) + 7;

int main()
{
    long long N, M;
    cin >> N >> M;
    if (abs(N - M) > 1) {
        printf("0\n");
    } else {
        long long ans = 1;
        for (int i = 1; i <= N; i++) {
            ans = ans * i % MOD;
        }
        for (int i = 1; i <= M; i++) {
            ans = ans * i % MOD;
        }
        if (N == M) {
            ans = ans * 2 % MOD;
        }
        printf("%lld\n", ans);
    }
    //int wait; cin >> wait;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N, M, C;
int A[30];
int B[30];
int main(){
  cin >> N >> M >> C;
  for(int i=0; i<M; i++){
    cin >> B[i];
  }
  int counter =0;
  for(int i=0; i<N; i++){
    int sum=0;
    for(int j=0; j<M; j++){
      cin >> A[j];
      sum += A[j] *B[j];
    }
    sum += C;
    if (sum >0) counter++;
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct point{
	int v,w;
}a[105];
int dp[105][10005];
int main(){
	int n,w;cin>>n>>w;
	for(int i=1;i<=n;i++)cin>>a[i].v>>a[i].w;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=w;j++)
			dp[i][j]=(j<a[i].w?dp[i-1][j]:max(dp[i-1][j],dp[i][j-a[i].w]+a[i].v));
	cout<<dp[n][w]<<endl;
	return 0;
}


Measured memory_bytes: 7020
// A - Red or Not

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

int main(){
	int a;
	string s;
	cin >> a >> s;

	if (a >= 3200) {
		cout << s << endl;
	} else {
		cout << "red" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
using namespace __gnu_cxx;
using namespace std;
#define mst(a,b) memset(a,b,sizeof(a))
#define ALL(x) x.begin(),x.end()
#define debug(a) cout << #a": " << a << endl;
#define eularMod(a, b) a < b ? a : a % b + b
#define X first
#define Y second
#define lc rt << 1
#define rc rt << 1 | 1
inline int lowbit(int x){ return x & -x; }
typedef long long LL;
typedef pair<int, int> pii;
typedef unsigned long long ULL;
const int N = 1e5 + 10;
const int M = 1e7 + 10;
const int mod = (int) 1000000007;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const double eps = 1e-6;

int prime[N];
bool vis[N];
LL a[N];
int tot;
set<LL> st;
map<LL, int> cnt;
map<LL, LL> has;

void getPrime() {
    for (int i = 2; i < N; i++) {
        if (!vis[i])
            prime[tot++] = i;
        for (int j = 0; j < tot && 1LL * i * prime[j] < N; j++) {
            vis[i * prime[j]] = true;
            if (i % prime[j] == 0)
                break;
        }
    }
}
void getSqu() {
    for (LL i = 1; i * i <= 10000000000LL; i++)
        st.insert(i * i);
}

int main() {
#ifdef LOCAL
    freopen("o.txt", "r", stdin);
//    freopen("out.txt","w",stdout);
#endif
    getPrime();
    getSqu();

    int n;

    scanf("%d", &n);

    for (int i = 1; i <= n; i++)
        scanf("%lld", &a[i]);

    bool one = false;

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

//        debug(a[i]);

        for (int j = 0; j <= 333; j++) {
            int c = 0;
            for (; a[i] % prime[j] == 0; a[i] /= prime[j])
                c++;
            c %= 3;
            if (!c)
                continue;
            for (int k = 0; k < c; k++)
                now *= prime[j];
            for (int k = c; k < 3; k++)
                r *= prime[j];
            if (a[i] == 1)
                break;
        }

        if (a[i] != 1) {
            if (st.count(a[i])) {
                LL t = sqrt(a[i] + 0.5);
                now *= a[i];
                r *= t;
            } else {
                now *= a[i];
                r *= a[i] * a[i];
            }
        }

        if (now == 1) {
            one = true;
            continue;
        }

//        debug(now);

        cnt[now]++;
        has[now] = r;
    }

    LL res = one;

    for (map<LL, int>::iterator it = cnt.begin(); it != cnt.end(); it++) {
        LL u = it -> X;
        int c = it -> Y;
        if (has.find(u) != has.end()) {
            res += max(c, cnt[has[u]]);
            cnt.erase(has[u]);
        } else
            res += c;
    }

    printf("%lld\n", res);

    return 0;
}


Measured memory_bytes: 18304
def paths(r,c):
  return facts[r+c]*ifacts[r]*ifacts[c]

mod=10**9+7
r1,c1,r2,c2=map(int,input().split())
facts=[1]*(r2+c2+10)
ifacts=[1]*(r2+c2+10)
for i in range(1,r2+c2+10):
  facts[i]=(facts[i-1]*i)%mod
  ifacts[i]=pow(facts[i],mod-2,mod)
ans=0
for i in range(r1+1,r2+2):
  ans+=paths(i,c2)-paths(i,c1-1)
  ans%=mod
print(ans)

Measured memory_bytes: 71772
#include<stdio.h>
#define MAX 500000
int count=0;

void merge(int *A,int left,int mid,int right){//leftからrightまでのAを昇順に入れ直す
  int n1 = mid - left;//左大きさ
  int n2 = right - mid;//右大きさ
  int i,j,k;

  int L[n1+1];//左の配列
  int R[n2+1];//右の配列
  //初期化
  for (i = 0;i< n1;i++)L[i] = A[left + i];
  for (i = 0;i< n2;i++)R[i] = A[mid + i];
  
  L[n1] = 1000000001;//番兵
  R[n2] = 1000000001;

  i = 0;
  j = 0;

  for (k = left;k<right;k++){//LとRの要素をうまいこと、昇順にAに入れ直す
      count++;
      
      if (L[i] <= R[j]){
	  A[k] = L[i];
	  i++;
	}
      else{
	  A[k] = R[j];
	  j++;
	}
    }  
}


void mergeSort(int *A,int left,int right){//グループに半分ずつ分けて,mergeにわたす
  int mid;
  if (left+1 < right){    
      mid = (left + right)/2;
      mergeSort(A, left, mid);
      mergeSort(A, mid, right);
      merge(A, left, mid, right);
    }
}

int main()
{
  int i;
  int  n;
  int B;
  int A[MAX];
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  mergeSort(A,0,n);//初めは配列、左、右の番号
 
  for(i=0;i<n;i++){
      if(i)printf(" ");
      printf("%d",A[i]);
    }

  printf("\n%d\n",count);
  return 0;
}



Measured memory_bytes: 5676
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
//ll arr[1000002];
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/

int main()
{
ll r,d,x;
cin>>r>>d>>x;
ll i;
for(i=1;i<=10;i++)
{
    x=r*x-d;
    cout<<x<<endl;
}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>

#include <utility>
#include <vector>
#include <limits>
#include <algorithm>
using namespace std;

#define rep_init(i, init, n) for(int i = (init); i < n; ++i)
#define rep(i, n) rep_init(i, 0, n)

constexpr int INF = numeric_limits<int>::max();

void Main()
{
	int N, M;
	cin >> N >> M;

	vector<int> a(N);
	vector<int> b(N);
	vector<int> c(M);
	vector<int> d(M);
	rep(i, N)
	{
		cin >> a[i] >> b[i];
	}
	rep(i, M)
	{
		cin >> c[i] >> d[i];
	}

	vector<int> m(N, INF);
	vector<int> num(N);
	rep(i, N)
	{
		rep(j, M)
		{
			if (m[i] > abs(a[i] - c[j]) + abs(b[i] - d[j]))
			{
				m[i] = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				num[i] = j+1;
			}
		}
	}

	rep(i, N)
	{
		cout << num[i] << endl;
	}
}

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

	Main();
	return 0;
}

Measured memory_bytes: 256
l, r = map(int, input().split())
# 2019
if r - l >= 2019:
	print(0)

# この数の中に2019が含まれている．
# 2019 * 2019 - 2019 

else:
	ans = 10000
	for i in range(l, r + 1):
		for j in range(i + 1, r + 1):
			ans = min(ans, (i * j) % 2019)
	print(ans)


Measured memory_bytes: 2940