akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B;
  cin >> A >> B;
  if ((A == 1 && B == 2) || (A == 2 && B == 1))
    cout << 3 << endl;
  else if ((A == 1 && B == 3) || (A == 3 && B == 1))
    cout << 2 << endl;
  else
    cout << 1 << endl;

  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 310;
const ll INF = 1e18-1;

ll N, K, H[MAX];
ll dp[MAX][MAX]; // dp[i][k] : i個目まででk個を使ったときの最小値、ただしi個目は使っている

ll solve() {
    REP (i, MAX) FOR (j, 1, MAX) dp[i][j] = INF;
    REP (i, N) dp[i][1] = H[i];
    FOR (i, 1, N) {
        FOR (k, 2, N-K+1) {
            REP (l, i)
                dp[i][k] = min(dp[i][k], dp[l][k-1]+max(0ll, H[i]-H[l]));
        }
    }
    ll ans = INF;
    REP (i, N) ans = min(ans, dp[i][N-K]);
    return ans;
}

int main() {
    cin >> N >> K;
    REP (i, N) cin >> H[i];
    cout << solve() << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int cards[50];
int N,R;

int swap(int p, int c)
{
    int t_cards[50];
    for(int i=0; i < N; i++)
        t_cards[i] = cards[i];
    for(int i=0; i < c; i++)
        cards[i] = cards[p-1+i];
    for(int i=0; i < p-1; i++)
        cards[i+c] = t_cards[i];
    return 0;
}

int main(void)
{
    while(true)
    {
        scanf("%d%d", &N, &R);
        if(N==0 && R==0) break;

        for(int i=0; i < N; i++)
            cards[i] = N-i;

        for(int i=0; i < R; i++)
        {
            int p,c;
            scanf("%d%d", &p, &c);
            swap(p, c);
        }
        printf("%d\n", cards[0]);
    }

    return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {
			long n = sc.nextLong();
			long a = sc.nextLong();
			long b = sc.nextLong();
			long c = sc.nextLong();
			long d = sc.nextLong();
			long e = sc.nextLong();
			// a,b,c,d,eで一番小さいやつが6回目以降に毎回減っていく
			long[] tmp = {a,b,c,d,e};
			Arrays.sort(tmp);
			long min = tmp[0];
			long ans = (long)Math.ceil((double)n / (double)min) + 4;
			System.out.println(ans);
		}

	}

}


Measured memory_bytes: 35996
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstring>
#include<functional>
#include<cmath>

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

using namespace std;

int main(){
	int ans(0),b(0);
	string a;
	cin >> a;
	rep(i,0,a.length()){
		if(a[i] == 'A' || a[i] == 'T' || a[i] == 'G' || a[i] == 'C'){
			b ++;
		} else b = 0;
		if(ans < b) ans = b;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int s = sc.nextInt();

		if(s == 1){
			System.out.println(4);
		}else if(s ==2){
			System.out.println(4);
		}else
		{
			int count =1;
			do {
				if(s%2 ==0){
					s = s/2;
				}else{
					s = s*3 +1;
				}
			
				count++;
			} while (s!=1);
			System.out.println(count + 1);

		}

	}
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
#define nl '\n' 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pii pair <int,int>
ll m=1000000007;

int main()
{
	fast;
	int n;cin>>n;
	int k;cin>>k;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	ll sum=0;
	for(int i=0;i<k;i++)
		sum+=a[i];
	cout<<sum<<nl;
}

Measured memory_bytes: 3624
import java.math.BigDecimal
import java.math.RoundingMode

fun main(args: Array<String>) {
    val (a, b, c) = readLine()!!.split(" ").map(String::toDouble)
    val decA = BigDecimal(a)
    val decB = BigDecimal(b)
    val decC = BigDecimal(c)
    val decD = decC.subtract(decA).subtract(decB)
    val dec4 = BigDecimal(4)
    if (decD > BigDecimal.ZERO && decD.multiply(decD) > decA.multiply(decB).multiply(dec4)) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 36032
#include <bits/stdc++.h>
#define MAX 100010
using namespace std;

int R, L, U, D;
pair<int, int> Rpoints[MAX];
pair<int, int> Lpoints[MAX];
pair<int, int> Upoints[MAX];
pair<int, int> Dpoints[MAX];
int direction[MAX];

double get(double time)
{
	double xMin = 200000.0 * 200000.0;
	double xMax = -xMin;
	double yMin = xMin;
	double yMax = xMax;
	for (int i = 0; i < R; i++)
	{
		pair<double, double> p = Rpoints[i];
		p.first += time;
		xMin = min(xMin, p.first);
		xMax = max(xMax, p.first);
		yMin = min(yMin, p.second);
		yMax = max(yMax, p.second);
	}
	for (int i = 0; i < L; i++)
	{
		pair<double, double> p = Lpoints[i];
		p.first -= time;
		xMin = min(xMin, p.first);
		xMax = max(xMax, p.first);
		yMin = min(yMin, p.second);
		yMax = max(yMax, p.second);
	}
	for (int i = 0; i < U; i++)
	{
		pair<double, double> p = Upoints[i];
		p.second += time;
		xMin = min(xMin, p.first);
		xMax = max(xMax, p.first);
		yMin = min(yMin, p.second);
		yMax = max(yMax, p.second);
	}
	for (int i = 0; i < D; i++)
	{
		pair<double, double> p = Dpoints[i];
		p.second -= time;
		xMin = min(xMin, p.first);
		xMax = max(xMax, p.first);
		yMin = min(yMin, p.second);
		yMax = max(yMax, p.second);
	}
	return (yMax - yMin) * (xMax - xMin);
}

int main(void)
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		char t;
		pair<int, int> p;
		cin >> p.first >> p.second;
		cin >> t;
		if (t == 'R') Rpoints[R++] = p;
		if (t == 'L') Lpoints[L++] = p;
		if (t == 'U') Upoints[U++] = p;
		if (t == 'D') Dpoints[D++] = p;
	}
	double lo = 0.0;
	double hi = 1e9;
	double loVal = get(lo);
	double hiVal = get(hi);
	for (int t = 0; t < 100; t++)
	{
		double mid1 = (lo + lo + hi) / 3;
		double midVal1 = get(mid1);
		double mid2 = (lo + hi + hi) / 3;
		double midVal2 = get(mid2);
		if (midVal2 < midVal1)
		{
			lo = mid1;
			loVal = midVal1;
		}
		else
		{
			hi = mid2;
			hiVal = midVal2;
		}
	}
	long long ans = (get((lo + hi) / 2) * 4);
	cout << ans / 4;
	if (ans % 4 == 1) cout << ".25";
	if (ans % 4 == 2) cout << ".5";
	if (ans % 4 == 3) cout << ".75";
	cout << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.math.*;
import java.util.*;
  
  

public class Main {

	static HashMap<String, Integer> dp=new HashMap<String, Integer>();
	static int distance[]= {1,-1,4,-4};
	public static void main(String[] args) {
		bfs();
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
        	String s=scan.nextLine();
        	s=s.replace(" ", "");
        	System.out.println(dp.get(s));
        	
        }
        
        
        
        
	}
	public static void bfs() {
		Queue<String> que=new LinkedList<String>();
		que.add("01234567");
		dp.put("01234567",0);
		while(que.size()>0) {
			String now=que.poll();
			int p=0;
			for(int j=0;j<8;j++) {
				if(now.charAt(j)=='0') {
					p=j;
					break;
				}
			}
			for(int i=0;i<4;i++) {
				int n=p+distance[i];
				if(n>=0&&n<8&&!(p==3&&i==0)&&!(p==4&&i==1)) {
					char next[]=now.toCharArray();
					next[p]=now.charAt(n);
					next[n]=now.charAt(p);
					String find=String.valueOf(next);
					if(!dp.containsKey(find)) {
						dp.put(find, dp.get(now)+1);
						que.add(find);
					}
				}
			}
		}
		
	}
	
	
	
	
	
}


Measured memory_bytes: 43520
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n;
int  a, b;
cin >> n >> a >> b;
int ans = 0;

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


        if(i /10000+(i%10000)/1000 + (i%1000) / 100 + (i%100)/ 10 + i %10 >= a && i/10000 + (i%10000)/1000 + (i%1000) / 100 + (i%100)/ 10 + i %10 <= b){
            ans += i;
        }


    }

    cout << ans << endl;


}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int arr[] = new int[n];
        for(int i=0;i<n;i++){
            arr[i] = in.nextInt();
        }
        int dp[] = new int[n];
        Arrays.fill(dp,Integer.MAX_VALUE);
        dp[0] = 0;
        for(int i=0;i<n;i++){
            if((i+1) <n)
            dp[i+1] = Math.min(dp[i+1],dp[i]+Math.abs(arr[i+1]-arr[i]));
            if((i+2)<n)
            dp[i+2] = Math.min(dp[i+2],dp[i]+Math.abs(arr[i+2]-arr[i]));
        }
        System.out.println(dp[n-1]);
    }

}

Measured memory_bytes: 51224
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<int> x(n);
for (int i = 0; i < n; ++i) cin >> x[i];
int distance = 0;
for (int i = 0; i < n; ++i) distance += min(x[i] * 2, (k - x[i]) * 2); 
cout << distance << endl;
}                                                               

Measured memory_bytes: 256
s = input()
ls = len(s)
part_s = set( [s[i:j+1] for i in range(ls) for j in range(ls)  ])
part_s = [ i for i in part_s if set(list(i)) | set(["A","T","C","G"]) == set(["A","T","C","G"])]
if part_s == []:
    print(0)
else:
    print(max(map(len,part_s)))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int n;
	int x=0,y=0,z=0,e=0;
	cin>>n;

	x=n/100;
	z=n%100;
	y=z/10;
	e=n%10;

	if(x<y||x<e){
		cout<<(x+1)*100+(x+1)*10+(x+1)<<endl;
	}else{
		cout<<x*100+x*10+x<<endl;
	}


	return 0;
}


Measured memory_bytes: 256
"""Knapsack"""
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
s = input().rstrip()
gx, gy = map(int, input().split())
rx, ry = 0, 0
head, inst = 0, []
while head < len(s) and s[head] == "F":
    head += 1
    rx += 1

xlist, ylist = [], []
heading_x = True
while head < len(s):
    tcnt = 0
    while head < len(s) and s[head] == "T":
        tcnt += 1
        head += 1
    if head == len(s):
        break
    fcnt = 0
    while head < len(s) and s[head] == "F":
        fcnt += 1
        head += 1
    if ((tcnt % 2) == 1) ^ heading_x:
        heading_x = True
        xlist.append(fcnt)
    else:
        heading_x = False
        ylist.append(fcnt)


def fill(fs, goal_offset):
    f_total = sum(fs)
    if f_total < goal_offset:
        return False
    if f_total == goal_offset:
        return True
    f_diff = f_total - goal_offset
    if f_diff % 2 == 1:
        return False
    f_diff //= 2
    diffs = {0}
    for f in fs:
        for d in list(diffs):
            d2 = f + d
            if d2 > f_diff:
                continue
            if d2 == f_diff:
                return True
            diffs.add(d2)
    return False


if fill(xlist, abs(gx - rx)) and fill(ylist, abs(gy - ry)):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 41456
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int[] ar = new int[3];
        for (int i = 0; i < 3; i++) {
            ar[i] = sc.nextInt();
        }
        Arrays.sort(ar);

        if (ar[0] == ar[1] && ar[1] == ar[2]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

double x1,yy1,x2,yy2,x3,yy3,x4,yy4;

int main(){
	while(cin>>x1>>yy1>>x2>>yy2>>x3>>yy3>>x4>>yy4){
		if((x1<=x3&&x2>=x3||x1>=x3&&x1<=x4)&&(yy1<=yy3&&yy2>=yy3||yy1>=yy3&&yy1<=yy4))cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll K, S;
  cin >> K >> S;

  ll ans = 0;
  REP(X, K + 1) {
    REP(Y, K + 1) {
      ll Z = S - X - Y;
      if (0 <= Z && Z <= K) {
        ans++;
      }
    }
  }

  cout << ans;
  return 0;
}

Measured memory_bytes: 256
function main(input) {
  var x = input[0]-0;
  var sosulist = [2];
  var ans = 1;
  var i=2;
  if(x==2 || x==1){
    console.log(2);
    return;
  }
  start:while(true){
    i++;
    for(var j=0;j<sosulist.length;j++){
      if(i%sosulist[j]==0) continue start;
      if(Math.sqrt(i)<sosulist[j]) break;
    }
    sosulist.push(i);
    if(i>=x){ans = i; break;}
  }
  console.log(ans);
}

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


Measured memory_bytes: 7628
module Hitachi2020.B

let fLine = stdin.ReadLine().Split(' ') |> Array.map int
let aNum = fLine.[0]
let bNum = fLine.[1]
let mNum = fLine.[2]

let aArray = stdin.ReadLine().Split(' ') |> Array.map int
let bArray = stdin.ReadLine().Split(' ') |> Array.map int

let mArray num =
    seq {
        for _ in 1 .. num -> stdin.ReadLine().Split(' ') |> Array.map int
    }
    |> Seq.toList

let minPriceWithTicket =
    mArray mNum
    |> List.map (fun m -> aArray.[m.[0] - 1] + bArray.[m.[1] - 1] - m.[2])
    |> List.min

let minPriceNoTicket = (Array.min aArray) + (Array.min bArray)

min minPriceNoTicket minPriceWithTicket |> printf "%d"


Measured memory_bytes: 40336
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	while(true){
		
		int n;
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		int ans = 100000000;
		double BMI = 100000000;
		
		for(int loop = 0; loop < n; loop++){
			double p, h, w;
			cin >> p >> h >> w;
			h /= 100;
			//cout << w / h / h << endl;
			if(abs(22 - w / h / h) < abs(22 - BMI)){
				ans = p;
				BMI = w / h / h;
			}else if(abs(22 - w / h / h) == abs(22 - BMI)){
				if(p < ans){
					ans = p;
				}
			}
		}
		
		cout << ans << endl;
		
	}
	return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n+1];
	for(int i=0;i<=n;i++) a[i]=0;
	for(int i=1;i<=n;i++){
	    for(int j=i;j<=n;j+=i)
	    a[j]++;
	}
	long long ans=0;
	for(int i=0;i<=n;i++)
	ans+= i*(long long)a[i];
	
	cout<<ans;
	return 0;
}


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

#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double aa = (h + m / 60) / 12 * 360;
    double ab = ((h + m / 60) * 360);
    while (aa >= 360) aa -= 360;
    while (ab >= 360) ab -= 360;
    double del = min(abs(aa - ab), 360 - abs(aa - ab));
    double ans = a * a + b * b - 2 * a * b * cos(del * acos(-1) / 180);
    ans = sqrt(ans);
    cout << fixed << setprecision(9) << ans << '\n';
    return 0;
}



Measured memory_bytes: 4180
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long A,B,N;
  cin >> A >> B >> N;
  
  if (B-1 > N){
    cout << A*N/B << endl;
  }
  
  else {
    cout << A*(B-1)/B << endl;
  }
  
}


Measured memory_bytes: 3636
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A,B,C;
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		if (A>=B&&A>=C) {
			System.out.println((A*2-(B+C))/2+(A*2-(B+C))%2*2);
		} else if (B>=A&&B>=C) {
			System.out.println((B*2-(A+C))/2+(B*2-(A+C))%2*2);
		} else if (C>=A&&C>=B) {
			System.out.println((C*2-(A+B))/2+(C*2-(A+B))%2*2);
		}
	}
}

Measured memory_bytes: 21588
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	int a[4],b[4];
	int i,j,x,y;

	while(scanf("%d %d %d %d",a,a+1,a+2,a+3)!=EOF){
		scanf("%d %d %d %d",b,b+1,b+2,b+3);
		x=0;
		y=0;
		for(i=0;i<4;i++)
			for(j=0;j<4;j++)
				if(a[i]==b[j])
					if(i==j)
						x++;
					else
						y++;
		printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 596
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

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

        int n = in.nextInt();
        Map<Integer, Integer> cnt = new HashMap<>();
        while(n-- > 0) {
            int a = in.nextInt();
            cnt.put(a, cnt.getOrDefault(a, 0) + 1);
        }
        int res = 0;
        for (int k: cnt.keySet()) {
            if (cnt.get(k) < k) {
                res += cnt.get(k);
            } else {
                res += cnt.get(k) - k;
            }
        }
        out.println(res);


        out.close();
        //INT OVERFLOW -> USE LONG
        //ARR OUT OF BOUNDS
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public double[] nextDoubleArray(int n) {
            double[] arr = new double[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        public char[] nextCharArray(int n) {
            char[] arr = nextLine().trim().replaceAll("\\s", "").toCharArray();
            return arr;
        }

        public String[] nextStringArray(int n) {
            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 48260
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 // #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
// const int mod=1e9+7;
 const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


void solve()
{
    char a;
    cin>>a;
    if(a>='A' && a<='Z')
        cout<<'A'<<endl;
    else
        cout<<'a'<<endl; 
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

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

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if (a * b == 15) {
        cout << "*";
    } else if  (a + b == 15) {
        cout << "+";
    } else {
        cout << "x";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const int N=2e5+7;
using namespace std;
int s[N],n,m;
vector<int >v[N];
queue<int >q;
int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
    	int a,b;
    	cin>>a>>b;
    	v[a].push_back(b);
    	v[b].push_back(a);
	}
	s[1]=0;
	for(int i=0;i<v[1].size();i++){
		q.push(v[1][i]);
		s[v[1][i]]=1;
	}
	while(!q.empty()){
		int p=q.front();
		q.pop();
		for(int i=0;i<v[p].size();i++){
		    if(s[v[p][i]]==0&&v[p][i]!=1){
		    	q.push(v[p][i]);
		    	s[v[p][i]]=p;
			}
		}
	}
	int f=1;
	for(int i=2;i<=n;i++)
		if(s[i]==0) {f=0;break;}
	if(f==1){
		cout<<"Yes"<<endl;
		for(int i=2;i<=n;i++) 
		    cout<<s[i]<<endl;
	}
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 12748
def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    ans = 0
    while(1):
        if num_list.count(0) == n:
            break
        i = 0
        while(i < n):
            if num_list[i] == 0:
                i += 1
            else:
                ans += 1
                while(i < n and num_list[i] != 0):
                    num_list[i] -= 1
                    i += 1

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 39152
import sys
sys.setrecursionlimit(10**9)

N = int(input())

def bfs(s, cnt, m):
	if cnt == N:
		print(s)
		return

	for i in range(97,ord(m)+2):
		if chr(i) > m:
			bfs(s+chr(i), cnt+1, chr(i))
		else:
			bfs(s+chr(i), cnt+1, m)

bfs('a',1,'a')

Measured memory_bytes: 4412
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[101] T;

void main()
{
    auto N = readln.chomp.to!int;
    foreach (a; readln.split.to!(int[])) ++T[a];

    size_t i;
    for (;; ++i) {
        if (T[i] == 0) continue;
        break;
    }
    auto h = i.to!int;
    if (T[i] == 2) {
        --h;
    } else if (T[i] > 2) {
        writeln("Impossible");
        return;
    }
    int s = T[i];

    foreach (_; 0..h) {
        ++i;
        if (T[i] < 2) {
            writeln("Impossible");
            return;
        }
        s += T[i];
    }

    writeln(s == N ? "Possible" : "Impossible");
}

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

#define fi first
#define se second
typedef pair<int,int> PII;


int n, m, cnt;
char a[20][20];

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
            if (a[i][j] == '#') cnt++;
        }
    for (int i = 0, it = 0; i < n; i++) {
        while (a[i][it] == '#') it++, cnt--;
        it--;
    }
    if (cnt > 0) cout << "Impossible\n";
    else cout << "Possible\n";
}


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

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

int main()
{
  int n,i;
  int heap[251];

  heap[0] = 0;

  scanf("%d",&n);

  for(i = 1; i <= n; i++){
    scanf("%d",&heap[i]);
  }

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

  return 0;
}

int parent(int i)
{
  return i/2;
}

int left(int i)
{
  return i*2;
}

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



Measured memory_bytes: 2108
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    unsigned long long X, Y;
    cin >> X >> Y;
    unsigned long long ans = 0;
    unsigned long long i = 0;
    while(true){
        if(X * (unsigned long long)pow((unsigned long long)2, i) <= Y){
            ans++;
            i++;
        }else{
            break;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
/*
 * kadai 6_2
 * kamecha
 */
#include <stdio.h>
#include <string.h>

#define SIZE 150

int main(void){
    char str[SIZE];
    int len = 0;
    fgets(str, SIZE, stdin);
    len = strlen(str);
    /*
     * lenの値は'\0'を加えられているので調整する
     */
    printf("%c%d%c\n", str[0], len-3, str[len-2]);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int H, W, N; cin >> H >> W >> N;
    int sy, sx; cin >> sy >> sx;
    string T, A; cin >> T >> A;

    vector<PII> LR(2);
    vector<PII> UD(2);
    LR[0] = {0, 1};
    LR[1] = {W+1, -1};
    UD[0] = {0, 1};
    UD[1] = {H+1, -1};

    string lr = "LR";
    string ud = "UD";
    for(int i=N-1; i>=0; i--){
        for(int j=0; j<2; j++){
            if(A[i]==lr[j]) LR[j^1].fs -= LR[j^1].sc;
            if(A[i]==ud[j]) UD[j^1].fs -= UD[j^1].sc;
        }
        LR[0].fs = max(0, LR[0].fs);
        LR[1].fs = min(W+1, LR[1].fs);
        UD[0].fs = max(0, UD[0].fs);
        UD[1].fs = min(H+1, UD[1].fs);

        
        for(int j=0; j<2; j++){
            if(T[i]==lr[j]) LR[j].fs += LR[j].sc;
            if(T[i]==ud[j]) UD[j].fs += UD[j].sc;
        }
        if(LR[1].fs - LR[0].fs == 1 || UD[1].fs - UD[0].fs == 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    
    if(sx > LR[0].fs && sx < LR[1].fs && sy > UD[0].fs && sy < UD[1].fs){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}



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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T, typename U>
void print1(T Array, U size) {
  for (int i = 0; i < size; i++) {
    cout << Array[i] << " ";
  }
  cout << endl;
}

template<typename T>
void print(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

// ------------------------------------------------------------------------------------------

const int INF = 1e15;

int dp[55555];
int c[22];

int n, m;

signed main() {
  cin >> n >> m;
  rep (i, m) {
    cin >> c[i];
  }

  fill(dp, dp+n+5, INF);
  dp[0] = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < m; j++) {
      if (i - c[j] >= 0) {
        dp[i] = min(dp[i], dp[i-c[j]] + 1);
      }
    }
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 3488
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <bitset>
#include <numeric>

using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

#define For(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define rall(a)		(a).rbegin(), (a).rend()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)
#define fi first
#define se second
bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
const int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
const int mod = 1000000007;
const int INF = 1e9;

int main()
{
	int n, k, s;

	while (cin >> n >> k >> s && n){

		int ans = 0;
		rep(i, (1 << n) + 1)if (__builtin_popcount(i) == k){
			
			int v = 0;
			rep(j, n){
				if ((i >> j ) & 1){
					v += j+1;
				}
			}

			if (v == s){
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S = ST()
    T = ST()
    ans = 0
    for i in range(3):
        if S[i] == T[i]:
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
n = int(input())

dict={}
for i in range(n):
    dict.setdefault(input())
print(len(dict)) 




### C++と同じく、実行は、Opt + Ctl + N

'''
# -*- coding: utf-8 -*-
# get a integer
a = int(input())
# get two integers separated with half-width break
b, c = map(int, input().split())
# get a string
s = input()
# output
print('{} {}'.format(a+b+c, s))
'''


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

int main () {
  string A, B;
  cin >> A >> B;
  int a = A.size();
  int b = B.size();
  if (a > b) {
    cout << "GREATER" << endl;
  }
  else if (a < b) {
    cout << "LESS" << endl;
  }
  else {
    if (A == B) cout << "EQUAL" << endl;
    else {
      for (int i = 0; i < a; i++) {
        if (A.at(i) > B.at(i)) {
          cout << "GREATER" << endl;
          return 0;
        }
        else if (A.at(i) < B.at(i)) {
          cout << "LESS" << endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1073741824
#define ll long long
#define PI (2*acos(0.0))
#define Hare printf("here\n")
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define x first
#define y second
#define on(val,pos) val|(1<<pos)
#define off(val,pos) val&(~(1<<pos))
#define check(val,pos) (val&(1<<pos))

//first four adjacent,second four corner
//int row[8]={0,-1,0,1,1,-1,-1,1};
//int col[8]={-1,0,1,0,-1,-1,1,1};
using namespace std;

int main(){
    int i,j,k,n,m,val,t=0,cnt,test;
    //freopen("000input.txt","r",stdin);
    cin>>n;
    int tem[3],arr[3];
    scanf("%d %d %d",&arr[0],&arr[1],&arr[2]);

    for(i=1;i<n;i++){
        scanf("%d %d %d",&tem[0],&tem[1],&tem[2]);
        int tem2[3]={0};
        for(j=0;j<3;j++){
            for(k=0;k<3;k++){
                if(j==k)continue;
                tem2[j]=max(tem2[j],arr[k]+tem[j]);
            }
        }
        arr[0]=tem2[0];
        arr[1]=tem2[1];
        arr[2]=tem2[2];
    }
    cout<<max(arr[0],max(arr[2],arr[1]));
    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<queue>
#include<set>
#include <climits>
using namespace std;

int main()
{
  int n, sum = 0, tmp = 0, result = INT_MAX;
  cin >> n;
  vector<int> a(n, 0);

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

  sort(a.begin(), a.end());
  int a_max = a.back();

  for (int i = 1; i < n; i++)
  {
    if(a[i -1] == a[i])
      tmp++;
  }

  if(tmp == n - 1)
  {
    cout << 0 << endl;
    exit(0);
  }

  for (int i = -100; i <= 100; i++)
  {
    tmp = 0;
    for (int j = 0; j < n; j++)
    {
      tmp += (i - a[j]) * (i - a[j]);
    }
    if(result > tmp) result = tmp;
  }
  cout << result << endl;
}


Measured memory_bytes: 256
A,B=map(int,input().split())
if A%2==0:
    d=B-A
    if d%4==0:
        print(B)
    elif d%4==1:
        print(1)
    elif d%4==2:
        print(1^B)
    else:
        print(0)
else:
    d=B-A-1
    if d%4==0:
        print(A^B)
    elif d%4==1:
        print(A^1)
    elif d%4==2:
        print(A^1^B)
    else:
        print(A^0)

Measured memory_bytes: 3064
"use strict"

const main = arg => {
  const digits = arg.toString().length;
  let input = parseInt(arg.trim());

  let divisor = Math.pow(10, digits - 1);
  let arr = [];
  
  for (var i = 0; i < digits; i++) {
  	arr.push(Math.floor(input / divisor))
  	input = input % divisor;
  	divisor /= 10;
  }
  
  let answer = arr.reduce((a, b) => a + b);
  if(answer == 1) {answer = 10;}

  console.log(answer);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 11468
import Data.List.Split
import qualified Data.Map as Map

--data Tree = Tree {node :: Int, left :: Tree, right :: Tree} | Emp
type Tree = Map.Map Int (Int,Int)

main = do
	ns <- getLoopValues
	let tree = createTree ns
	putStrLn "Preorder"
	putStr " " >> printList (preorder tree)
	putStrLn "Inorder"
	putStr " " >> printList (inorder tree)
	putStrLn "Postorder"
	putStr " " >> printList (postorder tree)

--リストの表示
printList [] = putStrLn ""
printList (x:[]) = putStrLn $ show x
printList (x:xs) = putStr (show (x) ++ " ") >> printList xs

--先行順巡回
preorder :: Tree -> [Int]
preorder tree = preorder_ (getRoot tree)
  where
    preorder_ (-1) = []
    preorder_ s = s:(preorder_ l) ++ (preorder_ r)
      where 
        (l,r) = tree Map.! s

--中間順巡回
inorder :: Tree -> [Int]
inorder tree = inorder_ (getRoot tree)
  where
    inorder_ (-1) = []
    inorder_ s = (inorder_ l) ++ s:(inorder_ r)
      where 
        (l,r) = tree Map.! s

--後行順巡回
postorder :: Tree -> [Int]
postorder tree = postorder_ (getRoot tree)
  where
    postorder_ (-1) = []
    postorder_ s = (postorder_ l) ++ (postorder_ r) ++ s:[]
      where 
        (l,r) = tree Map.! s

--木のルートを取得する
getRoot :: Tree -> Int
getRoot t = getRoot_ 0 t
  where
    getRoot_ n t = case getParent n t of
	                    Nothing -> n			--親が見つからなかった場合、今のノードがルート
	                    Just p -> getRoot_ p t --親が見つかった場合、さらにその親を取得する

--指定されたノードの親を取得する
getParent :: Int -> Tree -> Maybe Int
getParent c t = safeHead $ Map.keys $ Map.filter isChild t
  where 
    isChild (l,r)
      | l == c    = True
      | r == c    = True
      | otherwise = False

--headのMaybe版
safeHead []    = Nothing
safeHead (a:_) = Just a

--木（連想配列）を作る
createTree :: [(Int,Int,Int)] -> Tree
createTree ns = Map.fromList $ map (\(a,b,c) -> (a,(b,c))) ns

--画面入力の受付
getLoopValues :: IO([(Int,Int,Int)])
getLoopValues = do
    loopNum <- getInt
    lines <- getLoopValues' loopNum
    return $ map (\(a:b:c:_) -> (a,b,c)) $ map (map read) $ map (splitOn " ") $ lines

getLoopValues' :: Int -> IO([String])
getLoopValues' 0 = return []
getLoopValues' n = do
    v <- getLine
    vs <- getLoopValues' (n - 1)
    return $ v : vs

getInt :: IO (Int)
getInt = do
    str <- getLine
    return $ read str






Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int a,b;
    cin>>a>>b;
    ll ans=0;
    if(12.5*a+12.5<=10.0*b || 10.0*b+10.0<=12.5*a){
        cout<<-1<<endl;
        return 0;
    }else{
        double c=max(12.5*a,10.0*b);
        if(c==(int)c){
            ans=c;
        }else{
            ans=c/1+1;
        }
        cout<<ans<<endl;
        return 0;
    }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
/* Uncomment only if you are not using GNU compiler->
#include <map> #include <algorithm> #include <vector> #include <string.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <chrono> #include <thread> #include <iomanip>
*/ 
using namespace std;

#define endl "\n"
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define re(i,a) for(ll i=0; i<a; ++i)
#define tr(i,v) for(auto &i: v)
#define mem(a,val) memset(a,val,sizeof(a))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define in(v,n) vll v(n);re(i,n) cin>>v[i]
#define printVec(v,s) cout << s; tr(i, v) cout << i << " ";
#define sz(a) int((a).size())
#define dbgv(c, v) cout << c << " = " << v << endl;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<ll, ll> pll;
typedef vector< pll > vpll;
typedef vector< ll > vll;
typedef complex<double> point;

const long long MOD = 1000000007;
const long long inf = 1e18;
vll a;

void solve(){
	ll n, k;
    cin>>n>>k;
    a = vll(n+1);
    re(i, n) cin>>a[i+1];
    vb vis(n+1, 0);
    // if(k < n){
    //     curr = 1;
    //     re(i, k){
    //         curr = a[curr];
    //     }
    //     cout << curr;
    //     return;
    // }
    ll loopStart, curr=a[1];
    vis[1] = true;
    while(k > 0){
        if(!vis[curr]){
            vis[curr] = true;
            --k;
            if(k == 0){
                cout << curr;
                return;
            }
            curr = a[curr];
        }else{
            --k;
            loopStart = curr;
            if(k==0){
                cout << curr;
                return;
            }
            break;
        }
    }
    vll path;
    path.pb(loopStart);
    curr = a[loopStart];
    while(curr != loopStart){
        path.pb(curr);
        curr = a[curr];
    }
    cout << path[k % path.size()];
    
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif 
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    	solve();
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 5764
N= int(input())
Alist = list(map(int, input().split())) 
M= int(input())
px = [list(map(int, input().split())) for _ in range(M)]
res = sum(Alist)
for i in range(0,M):
    out = res -Alist[px[i][0]-1] + px[i][1]
    print(out)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(void){
  int n;
  int now=100000;
  int i,j;
  cin>>n;
  for(i=0;i<n;i++){
    now*=1.05;
    if(now%1000>=1){
      now+=1000;
      now/=1000;
      now*=1000;
    }
  }
  cout<<now<<endl;
  return 0;
}

Measured memory_bytes: 3052
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 v: Vec<usize> = read_vec();
    let (n, k) = (v[0], v[1]);
    let a = read_vec::<i64>();
    let mut dp = vec![std::i64::MAX; n];
    dp[0] = 0;
    dp[1] = (a[1] - a[0]).abs();
    for i in 2..n {
        for j in 1..k + 1 {
            if j > i {
                break;
            }
            // println!("{:?}", (i, j));
            dp[i] = std::cmp::min(dp[i], dp[i - j] + (a[i] - a[i - j]).abs());
        }
    }
    println!("{:?}", dp[n - 1]);
}


Measured memory_bytes: 6396
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	const int R = int(1e9);
	
	int N = 0;
	cin >> N;
	int minv, maxv = -R;
	cin >> minv;
	for (int j = 1; j < N; ++j) {
		int v;
		cin >> v;
		maxv = max(maxv, v - minv);
		minv = min(minv, v);
	}
	cout << maxv << endl;
	return 0;	
}

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

int main() {
	int A, B, X;
	cin >> A >> B >> X;
	if ((A <= X) && (X <= A + B)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
ans = 0
for j in range(len(a) - 1):
    ans += abs(a[j] - a[j + 1])
    
for i in range(n):
    p = abs(a[i + 2] - a[i])
    q = abs(a[i + 1] - a[i])
    r = abs(a[i + 1] - a[i + 2] )
    print(ans + p - q - r)

Measured memory_bytes: 64492
from itertools import combinations_with_replacement

def main():
    N, M, Q = map(int, input().split())
    ABCD = [list(map(int, input().split())) for i in range(Q)]
    ans = 0

    for A in combinations_with_replacement(range(M), N):
        temp = 0
        for abcd in ABCD:
            if A[abcd[1]-1]+1 == A[abcd[0]-1]+1 + abcd[2]:
                temp += abcd[3]
        if temp > ans:
            ans = temp
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9200