akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<limits.h>
using namespace std;
//
// Created by karayuu on 2018-12-23.
//

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

    int max = INT_MIN, min = INT_MAX;
    long long int sum = 0;

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

        max = std::max(max, a);
        min = std::min(min, a);
        sum += a;
    }

    /*printf("%d %d %lli\n", min, max, sum);*/
    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3104
n,m = gets.split.map(&:to_i)
hash = Hash.new(0)
n.times do
  k,*a = gets.split.map(&:to_i)
  a.each do |aa|
    hash[aa] += 1
  end
end
sum = 0
hash.sort_by{|k,v| -v}.each do |k,v|
  if v == n
    sum += 1
  end
end
puts sum

Measured memory_bytes: 1788
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    long X = sc.nextLong();
    
    long now = 0;
    for (int i = 1; i <= 100000; i ++) {
      now += i;
      
      if (now >= X) {
        System.out.println(i);
        break;
      }
    }
    
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 21204
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, X int
	fmt.Scan(&N, &X)

	ans := 0
	m := make([]int, N)
	for i := range m {
		fmt.Scan(&m[i])
		X -= m[i]
		ans++
	}
	sort.Ints(m)
	ans += X / m[0]

	fmt.Println(ans)
}


Measured memory_bytes: 512
n,y = map(int,input().split())
ans = (-1,-1,-1)
for i in range(y // 10000 + 1):
  for j in range(y // 5000 + 1):
    if i * 10000 + j * 5000 + (n - i - j) * 1000  == y and n - i - j >= 0:
      ans = (i, j, n - i - j)
print(ans[0],ans[1],ans[2])



Measured memory_bytes: 40944
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>

int main() {
	int x;
	std::cin >> x;
	int nSum = 0, ans = 0;
	for (int i = 1;i <= x;i++) {
		if (nSum >= x) {
			break;
		}
		nSum += i;
		ans += 1;
	}
	std::cout << ans << std::endl;
	return 0;
}

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

int main() {
    ll N, K;
    string S;
    cin >> N >> K >> S;
    S[K - 1] = S[K - 1] - 'A' + 'a';
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
S = list(input())

white_count=0
black_count=0
white_acc_list=[0]
black_acc_list=[0]
for i in range(N):
    if(S[i]=="."):
        white_count+=1
    else:
        black_count+=1
    black_acc_list.append(black_count)
    white_acc_list.append(white_count)

v = []
for i in range(N+1):
    v.append(black_acc_list[i]+(white_acc_list[N]-white_acc_list[i]))


#print("black_acc_list:{}".format(black_acc_list))
#print("white_acc_list:{}".format(white_acc_list))
#print("v_list:{}".format(v))
print(np.min(v))


Measured memory_bytes: 32888
#include<stdio.h>
int main(void){
  int dice[7],q,num1,num2,num3;
  int k;
  for(k=1;k<=6;k++){
    scanf("%d",&dice[k]);
  }
  scanf("\n");
  scanf("%d",&q);
  for(k=1;k<=q;k++){
    scanf("%d %d",&num1,&num2);
    if(num1==dice[1]){
      if(num2==dice[2]) num3=dice[3];
      else if(num2==dice[3]) num3=dice[5];
      else if(num2==dice[4]) num3=dice[2];
      else if(num2==dice[5]) num3=dice[4];
    }
    if(num1==dice[2]){
      if(num2==dice[1]) num3=dice[4];
      else if(num2==dice[3]) num3=dice[1];
      else if(num2==dice[4]) num3=dice[6];
      else if(num2==dice[6]) num3=dice[3];
    }
    if(num1==dice[3]){
      if(num2==dice[1]) num3=dice[2];
      else if(num2==dice[2]) num3=dice[6];
      else if(num2==dice[5]) num3=dice[1];
      else if(num2==dice[6]) num3=dice[5];
    }
    if(num1==dice[4]){
      if(num2==dice[1]) num3=dice[5];
      else if(num2==dice[2]) num3=dice[1];
      else if(num2==dice[5]) num3=dice[6];
      else if(num2==dice[6]) num3=dice[2];
    }
    if(num1==dice[5]){
      if(num2==dice[1]) num3=dice[3];
      else if(num2==dice[3]) num3=dice[6];
      else if(num2==dice[4]) num3=dice[1];
      else if(num2==dice[6]) num3=dice[4];
    }
    if(num1==dice[6]){
      if(num2==dice[2]) num3=dice[4];
      else if(num2==dice[3]) num3=dice[2];
      else if(num2==dice[4]) num3=dice[5];
      else if(num2==dice[5]) num3=dice[3];
    }
    printf("%d\n",num3);
  }
  return 0;
}

Measured memory_bytes: 596
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  vector<int> v(3);
  for(int i=0; i<3; i++) cin >> v[i];
  sort(v.rbegin(), v.rend());
  int k;
  cin >> k;
  for(int i=0; i<k; i++) v[0] *= 2;
  cout << v[0]+v[1]+v[2] << endl;
  return 0;
}

Measured memory_bytes: 3664
from collections import deque

K = int(input())

q = deque(range(1,10))

for _ in range(K):
    x = q.popleft()
    r = x%10
    if r == 0:
        q.append(x*10)
        q.append(x*10+1)
    elif r == 9:
        q.append(x*10+8)
        q.append(x*10+9)

    else:
        q.append(x*10+r-1)
        q.append(x*10+r)
        q.append(x*10+r+1)
print(x)

Measured memory_bytes: 11980
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = Integer.parseInt(stdIn.next());
    String s = stdIn.next();
    String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    char[] str = new char[s.length()];
    for (int i = 0; i < s.length(); i++) {
      str[i] = s.charAt(i);
      int ans = alpha.indexOf(str[i]) + n;
      while (ans > 25) {
        ans -= 26;
      }
      System.out.print(alpha.charAt(ans));
    }    
  }
}


Measured memory_bytes: 25888
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 1000000007  # type: int


def solve(S: str):
    dp = [0]*13
    dp[0] = 1
    ep = [0]*13
    zero = [0]*13
    for c in S:
        ep[:] = zero
        for i in range(10):
            if c != "?" and int(c) != i:
                continue
            for j in range(13):
                ep[(10*j+i) % 13] += dp[j]
                ep[(10*j+i) % 13] %= MOD
        dp, ep = ep, dp

    print(dp[5])

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45036
#include <stdio.h>
int main(void) {
  int all, peo,i,zero = 0,one = 0,two = 0,thr = 0,fou = 0,fiv = 0,six = 0;
  
  scanf("%d",&all);
  while(all != 0) {
    zero = 0;one = 0;two = 0;thr = 0;fou = 0;fiv = 0;six = 0;
    for (i=0;i<all;i++) {
      scanf("%d",&peo);
      if(peo < 10 ) zero++;
      else if (peo < 20) one++;
      else if (peo < 30) two++;
      else if (peo < 40) thr++;
      else if (peo < 50) fou++;
      else if (peo < 60) fiv++;
      else  six++;
    }
    printf("%d\n",zero);
    printf("%d\n",one);
    printf("%d\n",two);
    printf("%d\n",thr);
    printf("%d\n",fou);
    printf("%d\n",fiv);
    printf("%d\n",six);
    scanf("%d",&all);
  }
  return(0);
}

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


int main(){
    int n;
    cin>>n;
    vector<int>v(n),dp(n);
    for(int i = 0 ; i < n ; i++){
        cin>>v[i];
    }
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);
    for(int i = 2 ; i < n ; i++ ){
        dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
    }
    cout<<dp[n-1];
    
}


Measured memory_bytes: 3992
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
	int n, m;
	bool adj[8][8] = {};

	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		adj[a][b] = adj[b][a] = true;
	}

	int ans = 0;
	int vertices[8] = {0, 1, 2, 3, 4, 5, 6, 7};
	do {
		int i;
		for (i = 0; i < n - 1; i++)
			if (!adj[vertices[i]][vertices[i + 1]])
				break;
		ans += i == n - 1;
	} while (next_permutation(vertices + 1, vertices + n));

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a==1||a==3||a==5||a==7||a==8||a==10||a==12){
		if(b==31)
			cout<<1<<endl;
		else
			cout<<0<<endl;
	}
	else if(a==2){
		if(b==28)
			cout<<1<<endl;
		else
			cout<<0<<endl;
	}
	else{
		if(b==30)
			cout<<1<<endl;
		else
			cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
// In the name of Allah
// #Isart

#include<bits/stdc++.h>

#define pii pair<int, int>
#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double

using namespace std;

const int MAXN = 1e3 + 10, mod = 1e9 + 7;
ll dp[MAXN][MAXN], f[MAXN], finv[MAXN], inv[MAXN];

ll add(ll a, ll b){
	return (a + b) % mod;
}

ll mul(ll x, ll y){
	return x * y % mod;
}

ll choose(int x, int y){
	return mul(f[y], mul(finv[x], finv[y - x]));
}

ll power(ll x, ll y){
	if(y == 1) return x;
	ll mid = power(x, y / 2);
	if(y & 1) return mul(mul(mid, mid), x);
	else return mul(mid, mid);
}

int main(){

	ios::sync_with_stdio(false); cin.tie(0);
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;

	f[0] = 1;
	for(int i = 1; i < MAXN; i ++) f[i] = mul(i, f[i - 1]);
	for(int i = 0; i < MAXN; i ++) finv[i] = power(f[i], mod - 2);	
	for(int i = 1; i < MAXN; i ++) inv[i] = power(i, mod - 2);

	dp[0][0] = 1;
	for(int i = 1; i <= n; i ++){
		for(int j = 0; j <= n; j ++){
			dp[i][j] = dp[i - 1][j];
			if(a <= i and i <= b){
				if(c * i > j) continue;
				ll now = 1;
				for(int t = 0; t < c - 1; t ++)
					now = mul(now, choose(i, j - t * i));
				now = mul(now, finv[c - 1]);
				for(int t = c; t <= d and t * i <= j; t ++){
					now = mul(now, choose(i, j - (t - 1) * i));
					now = mul(now, inv[t]);
					dp[i][j] = add(dp[i][j], mul(dp[i - 1][j - t * i], now));
				}
			}			
		}
	}

	cout << dp[n][n] << endl;
	return 0;	
}

Measured memory_bytes: 8192
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var N = int.Parse(inputs[0]);
        var K = int.Parse(inputs[1]);
        var S = Console.ReadLine();

        var ans = new System.Text.StringBuilder();
        for (int i = 0; i < S.Length; i++)
        {
            if (i == K - 1)
            {
                ans.Append(S[i].ToString().ToLower());
            }
            else
            {
                ans.Append(S[i]);
            }
        }

        Console.WriteLine(ans);
    }

}



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

int main() {
  int N;
  cin >> N;
  int l, r, n = 0;
  rep(i, N) {
    cin >> l >> r;
    n += r - l + 1;
  }
  cout << n << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する

int main(){
    //dequeの問題
    string s;
    cin>>s;
    int n = s.length();
    int fb=1;
    int64_t q;
    cin>>q;
    rep(i,q){
        int t;
        cin>>t;
        if(t==1){
            fb *= -1;
        }
        else{
            int f;
            char c;
            cin>>f>>c;
            if(f==1){//先頭にciを追加
                if(fb==1){
                    s.insert(s.begin(),c);
                }
                else{
                    s.push_back(c);
                }
            }
            else{//f==2 => 末尾にcを追加    
                if(fb==1){
                    s.push_back(c);
                }
                else{
                    s.insert(s.begin(),c);
                }
            }
        }
    }
    if(fb==1){
        rep(i,s.length()){
            cout<<s[i];
        }
    }
    else{
        for(int i=s.length()-1;i>=0;i--){
            cout<<s[i];
        }
    }
    cout<<endl;
}

Measured memory_bytes: 1028
#include<stdio.h>
#include <stdlib.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)

int main(){
	int n;
	scanf("%d",&n);

	int ai,*check = (int *)calloc(n,sizeof(int));
	FOR(i,0,n){
		scanf("%d",&ai);
		check[ai]++;
	}

	int tmp = n-1,ans = 0;
	while(tmp>0){
		if(check[tmp] != 2) ans++;
		tmp -= 2;
	}

	if(n%2 == 0 && check[0] != 0) ans++;
	if(n%2 == 1 && check[0] != 1) ans++;

	if(ans != 0) printf("0\n");
	else{
		int pow = 1;
		FOR(i,0,n/2) pow = (pow * 2) % 1000000007;
		printf("%d",pow);
	}
}

Measured memory_bytes: 512
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  set<int> s;
  REP(i,3) {
    int x;
    cin >> x;
    s.insert(x);
  }
  cout << s.size() << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>

using namespace std;

bool f(const string& s) {
	int l = s.size();
	for (int i = 0; i < l - 1 - i; i++) {
		if (s[i] != s[l - 1 - i]) return false;
	}
	return true;
}

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int n = s.size();
	string s1 = string(s.begin(), s.begin() + (n - 1) / 2);
	string s2 = string(s.begin() + (n + 3) / 2 - 1, s.end());
	if (f(s) && f(s1) && f(s2))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}









Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a;
  cin>>a;
  int b[4];
  for(int i=0;i<4;i++){
    b[i]=a%10;
    a=a/10;
  }
  
  if((b[0]==b[1]&&b[1]==b[2])||(b[1]==b[2]&&b[2]==b[3]))
     cout<<"Yes";
  else if(b[0]==b[1]&&b[1]==b[2]&&b[2]==b[3])
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}


Measured memory_bytes: 3104
#include <stdio.h>

#include <stack>

int main(void){
    using namespace std;
    stack<int> a,b;
    int n,j,i,ball,flag;
    scanf("%d",&n);
    for(j=0; j<n; j++){
        flag=0;
        for(i=0; i<10; i++){
            scanf("%d",&ball);
            if(a.empty()){
                a.push(ball);
            }else if(a.top() < ball){
                a.push(ball);
            }else if(b.empty()){
                b.push(ball);
            }else if(b.top() < ball){
                b.push(ball);
            }else{
                flag=1;
            }
        }
        while(!a.empty()){
            a.pop();
        }
        while(!b.empty()){
            b.pop();
        }
        if(flag==0){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1016
#include <stdio.h>

int main(void)
{
    int a, b, c, min, max;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

    if (a < b) {
        if (b < c) {
            min = a;
            max = c;
        }
        else {
            max = b;
            if (a < c) min = a;
            else min = c;
        }
    }
    else {
        if (a < c) {
            min = b;
            max = c;
        }
        else {
            max = a;
            if (b < c) min = b;
            else min = c;
        }
    }

    printf("%d %d\n", min, max);

    return 0;
}


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

int main () {
  int a,b,k;
  cin >> a >> b >> k;
  
  for(int i=100;i>0;i--){
    if(a%i==0&&b%i==0){
      k--;
    }
    if(k==0){
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define pb push_back
#define prev prev_
#define stack stack_
#define inf 0x3f3f3f3f

typedef long long ll;
inline int read(){
	register int num = 0;
	register char ch = getchar();
	while ( ch > '9' || ch < '0' ) ch = getchar();
	while ( ch <= '9' && ch >= '0' ) num = num * 10 + ch - '0' , ch = getchar();
	return num;
}
int num[10];
inline void write(int x){
	register int cnt = 0;
	if ( !x ){ printf("0"); return; } //一定要特判0！！！
	while ( x ) num[++cnt] = x % 10 , x /= 10;
	while ( cnt ) putchar(num[cnt--] + '0');
}
int n,cnt;
int a[maxn],x;

int main(){
	scanf("%d %d",&n,&x);
	rep(i,1,n) scanf("%d",&a[i]);
	sort(a + 1,a + n + 1);
	rep(i,1,n) if ( x >= a[i] ) cnt++,x -= a[i];
	if ( x && cnt == n ) cnt--;
	cout<<cnt<<endl;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n; cin >> n;
    vector<ll> c(n), l(n), r(n);
    vector<pair<ll, ll>> xl(n);
    rep(i, n){
        ll x, a; cin >> x >> a;
        xl[i].first = x+a;
        xl[i].second = x-a;
    }
    sort(xl.begin(), xl.end());
    ll pos = -1000000000, cnt = 0;
    rep(i, xl.size()){
        if(pos <= xl[i].second){
            pos = xl[i].first;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 7208
#include<iostream>
#include<algorithm>
using namespace std;
int v[21],vc[4];
int main()
{
    int n,ans=0;
    cin>>n;
    for ( int i = 1 ; i <= n ; i++ ){
        cin>>v[i];
    }
    for ( int i = 2 ; i <= n - 1 ; i++ ){
        vc[1] = v[i-1];
        vc[2] = v[i];
        vc[3] = v[i+1];
        sort ( vc + 1 , vc + 4 );
        if ( v[i] == vc[2] )
            ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int dis(int n){
    int sum=0;
    while(n>0){
      sum+=n%10;
      n/=10;
    }
    return sum;
  }

int main() {
  int N;
  cin>>N;
  
  
  
  int ini=dis(1)+dis(N-1);
  for(int i=2;i<(N+1)/2;i++){
    if(ini>(dis(i)+dis(N-i))){
      ini=dis(i)+dis(N-i);
    }
  }
  cout<<ini<<endl;
}
    

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

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

    vector<string>
        dd = {"dream", "dreamer", "erase", "eraser"};
    int m = s.length() / 5 + 1;
    vector<string> rem(1, s);
    for (int i = 0; i < m; ++i)
    {
        int n = rem.size();
        for (int j = 0; j < n; ++j)
        {
            for (int k = 0; k < 4; ++k)
            {
                if (rem[j].find(dd[k]) == 0)
                {
                    string rs = rem[j];
                    rs.erase(0, dd[k].length());
                    if (rs.length() == 0)
                    {
                        cout << "YES" << endl;
                        return 0;
                    }
                    rem.push_back(rs);
                }
            }
        }
        for (int j = 0; j < n; ++j)
        {
            rem.erase(rem.begin());
        }
        if (rem.size() == 0)
        {
            break;
        }
    }
    cout << "NO" << endl;
    return 0;
}


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

void Main() {
    // input
    int A, B, C;
    int X;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;

    // translate
    int ans = 0;

    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                if (500 * i + 100 * j + 50 * k == X) {
                    ans++;
                }
            }
        }
    }


    // output
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
import math

N = int(input())
A = list(map(int, input().split()))

flag = True
if 0 in A:
    prod = 0
else:
    prod = 1
    for i in range(N):
        prod *= A[i]
        if prod > 10**18:
            flag = False
            break

if flag == True:
    print(prod)
else:
    print(-1)

Measured memory_bytes: 22196
n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])
ans = 1
passenger = 0
limit = t[0] + k

for p in t:
    if passenger < c and p <= limit:
        passenger += 1
    else:
        ans += 1
        passenger = 1
        limit = p + k
print(ans)


Measured memory_bytes: 14156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp33 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int A = st[0];
            int B = st[1];
            int C = st[2];

            if (B / A >= C) {
                Console.WriteLine(C);
            } else {
                Console.WriteLine(B / A);
            }

        }
    }
}


Measured memory_bytes: 13396
n, m = map(int, input().split())
s = [[int(i) for i in input().split()[1:]] for _ in range(m)]
p = [int(i) for i in input().split()]
c = 0

for i in range(2**n):
    addable = True
    for j in range(m):
        d = sum(2 ** (k - 1) for k in s[j])
        if bin(i & d).count('1') % 2 != p[j]:
            addable = False
            break
    if addable:
        c += 1
print(c)


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

using namespace std;

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

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

    int cost0=0;
    int costn=0;
    for(int i=0;i<x;i++) cost0+=a[i];
    for(int i=x;i<n;i++) costn+=a[i];
    cout << min(cost0,costn) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;

int main(){
  int n,ni=1;
  double x[51],y[51];
  while(cin>>n && n){
    double s=0;
    for(int i=0;i<n;i++) cin>>x[i]>>y[i];
    x[n]=x[0];y[n]=y[0];
    for(int i=0;i<n;i++)
      s += (x[i]*y[i+1] - x[i+1]*y[i]);
    if(s<0) s*=-1;
    printf("%d %.1f\n",ni,s/2.0);
    ni++;
  }
  
  return 0;
}

Measured memory_bytes: 1244
/*
	  Chase
	   Your
	  Legend

	英雄志逐传奇
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>

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

const int INF = 1e8;

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

	vector<int>vec(n);
	rep(i, n) {
		cin >> vec[i];
	}

	int ans = INF;
	for (int i = -100; i <= 100; i++) {
		int cost = 0;
		for (int j = 0; j < n; j++) {
			cost = (vec[j] - i) * (vec[j] - i) + cost;
		}
		ans = min(ans, cost);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
#include <utility>
//#include <set>
#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

void solve(){
	ll a,b,c,d,n ;
	cin >> n >> a >> b >> c >> d ;
	map<ll,ll> m ;
	priority_queue<pll> pq ;
	pq.emplace(0,n) ;
	while(!pq.empty()){
		ll cur = pq.top().second ;
		ll cost = -pq.top().first ;
		pq.pop() ;
		if(m.count(cur)) continue ;
		m[cur] = cost ;
		if(cur==0){
			cout << cost << endl ;
			return ;
		}
		if(cur%2==0){
			if(!m.count(cur/2)){
				if(a/d>=cur/2) pq.emplace(-cost-cur/2*d,cur/2) ;
				else pq.emplace(-cost-a,cur/2) ;
			}
//			if(!m.count(cur+2)) pq.emplace(-cost-2*d,cur+2) ;
		}else{
			if(!m.count(cur+1)) pq.emplace(-cost-d,cur+1) ;
			if(!m.count(cur-1)) pq.emplace(-cost-d,cur-1) ;
		}
		if(cur%3==0){
			if(!m.count(cur/3)){
				if(b/d>=cur/3*2) pq.emplace(-cost-cur/3*2*d,cur/3) ;
				else pq.emplace(-cost-b,cur/3) ;
			}
//			if(!m.count(cur+3)) pq.emplace(-cost-3*d,cur+3) ;
		}else{
			if(!m.count(cur+3-cur%3)) pq.emplace(-cost-(3-cur%3)*d,cur+3-cur%3) ;
			if(!m.count(cur-cur%3)) pq.emplace(-cost-cur%3*d,cur-cur%3) ;
		}
		if(cur%5==0){
			if(!m.count(cur/5)){
				if(c/d>=cur/5*4) pq.emplace(-cost-cur/5*4*d,cur/5) ;
				else pq.emplace(-cost-c,cur/5) ;
			}
//			if(!m.count(cur+5)) pq.emplace(-cost-5*d,cur+5) ;
		}else{
			if(!m.count(cur+5-cur%5)) pq.emplace(-cost-(5-cur%5)*d,cur+5-cur%5) ;
			if(!m.count(cur-cur%5)) pq.emplace(-cost-cur%5*d,cur-cur%5) ;
		}
	}
}

int main(){
	ll t ; cin >> t ;
	while(t--) solve() ;
}


Measured memory_bytes: 7432
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
int a[6],ans,maxx;
template<typename I>inline void read(I&ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0' && ch<='9'){x=10*x+ch-'0'; ch=getchar();}
	ot=x*f;}
template<typename I,typename... U>inline void read(I&x,U&... y){read(x); read(y...);}
inline int mx(int x,int y){return x>y ? x : y;}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(a[1],a[2],a[3],a[4],a[5]);
	for(int i=1;i<=5;i++)
	{
		int tt=(10-a[i]%10)%10;
		maxx=mx(maxx,tt);
		ans+=a[i]+tt;
	}
	printf("%d\n",ans-maxx);
//	fclose(stdin); fclose(stdout);
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>T operator()(T&& lhs, T&& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>T operator()(T&& lhs, T&& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();
}

void dfs(int i, int p, std::vector<int>const& node, lib::graph_t const& edge, std::vector<int>& dp, std::vector<int>& result)
{
	auto ind = boost::lower_bound(dp, node[i]) - dp.begin();
	std::optional<int> impl;
	if (ind != dp.size())
	{
		impl = dp[ind];
		dp[ind] = node[i];
	}
	else
	{
		dp.push_back(node[i]);
	}
	result[i] = dp.size();
	for (auto n : edge[i])
	{
		if (n == p)
		{
			continue;
		}
		dfs(n, i, node, edge, dp, result);
	}
	if (impl)
	{
		dp[ind] = *impl;
	}
	else
	{
		dp.pop_back();
	}
}

void Main()
{
	int N;
	std::cin >> N;
	std::vector<int> node(N);
	for (auto& v : node)
	{
		std::cin >> v;
	}
	lib::graph_t edge(N);
	for (auto _ : boost::irange(N - 1))
	{
		int a, b;
		std::cin >> a >> b;
		--a; --b;
		edge[a].emplace(b);
		edge[b].emplace(a);
	}
	std::vector<int> dp, result(N);
	dfs(0, -1, node, edge, dp, result);
	for (auto r : result)
	{
		std::cout << r << std::endl;
	}
}

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

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

int main(){
  double A,B,i,tax=-1;
  cin >> A >> B;
  for(i=0;i<=1000;++i){
    if(floor(i*0.08)==A&&floor(i*0.1)==B){
      tax = i;
      break;
    }
  }
  cout << tax;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;i <= 0; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x); i++)
#define rreps(i,x) for(ll i = (ll)(x)-1; i <= 1; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    ll ans = 0;
    reps(i,sqrt(n)+1){
        if(n%i == 0 && n > i * (i+1))ans += n/i-1;
    }
    cout << ans << endl;
}

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

using namespace std;


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

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

  vector<bool> is_passed(n, false);
  vector<int> penalties(n, 0);
  for (int i = 0; i < m; i++)
  {
    int pi;
    string si;
    cin >> pi >> si;
    pi--;  // the index starts from 1.
    if (is_passed[pi])
    {
      continue;
    }

    if (si == "WA")
    {
      penalties[pi]++;
    } else
    {
      is_passed[pi] = true;
    }
  }

  int cnt_passed = 0, cnt_penalty = 0;
  for (int i = 0; i < n; i++)
  {
    if (is_passed[i])
    {
      cnt_passed++;
      cnt_penalty += penalties[i];
    }
  }

  cout << cnt_passed << " " << cnt_penalty << endl;
}

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

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

    if ( n / 100 == 7 || n % 10 == 7 || n % 100 / 10 == 7 )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;
#define INF 0x3f3f3f3f
#define ESP 1e-8
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
const double PI = acos(-1.0);

int main(){
    // FILE *fp = freopen("out.txt", "w", stdout);
    // freopen("in.txt", "r", stdin);
    int h, n, T, A;
    while(scanf("%d", &n) != EOF){
        double tmp=INF;
        int ans;
        scanf("%d%d", &T, &A);
        int i;
        for(i = 1; i <= n; i++){
            scanf("%d", &h);
            double t = 1.0*T-0.006*h-A;
            t = (t<0?-t:t);
            if(t < tmp){
                tmp = t;
                ans = i;
            }
        }
        printf("%d\n", ans);
    }

    // fclose(fp);
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
using namespace __gnu_pbds;
using namespace std;

#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define INF               1e18
#define ff                first
#define ss                second
#define vi                vector<int>
#define pii               pair<int,int>
#define mii               map<int,int>
#define endl              "\n"
#define GCD(x,y)          (__gcd((x), (y)))
#define LCM(x,y)          (((x)/__gcd((x), (y)))*(y))
#define debug(x)          cout<<#x<<" is "<<(x)<<endl
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(long long i=a;i<b;i++)
#define sp(ans,p)         fixed <<setprecision(p)<<ans;
#define IOS ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// constexpr int N=;
void solve()
{
    int ans = 0;
    string s;
    cin >> s;
    rep(i, 0, s.length())
    {

        if (s[i] == 'S') continue;
        int ct = 0;
        while (s[i] == 'R' and i < s.length())
        {
            i++;
            ct++;
        }
        ans = max(ct, ans);
    }
    cout << ans << endl;


    return;
}

signed main()
{
    IOS;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    // sieve();
    int t = 1;
    //cin >> t;
    while (t--)   solve();
    return 0;
}

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> list(N);
    for (int i = 0; i < N; i++)
        cin >> list[i];
    sort(list.begin(), list.end());
    reverse(list.begin(), list.end());
    int ans = 0;
    for (int i = 0; i < K; i++)
        ans += list[i];
    cout << ans;
}

Measured memory_bytes: 256
S = gets.chomp

ans = Float::INFINITY

ans = 0 if S.chars.uniq.size == 1

S.chars.uniq.each do |ch|
  s = S.dup
  flg = true

  while flg
    temp = s.dup
    str = ''
    flg = false

    0.upto(temp.size - 2) do |i|
      if s[i] == ch || s[i + 1] == ch
        str << ch
      else
        str << s[i]
        flg = true
      end
    end

    s = str
  end

  cnt = S.size - s.size

  ans = cnt if ans > cnt
end

puts ans


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

const long long INF=10000000000ll;

int main()
{
  int n;
  scanf("%d",&n);
  vector<long long> a(n),b(n);
  for(int i=0;i<n;i++){
    scanf("%lld%lld",&a[i],&b[i]);
  }
  vector<pair<long long,int> > P(2*n);
  for(int i=0;i<n;i++){
    P[i]=make_pair(a[i],i);
    P[i+n]=make_pair(b[i],i+n);
  }
  sort(P.begin(),P.end());
  long long ans=0;
  vector<bool> A(n,false),B(n,false);
  for(int i=0;i<n;i++){
    ans+=P[i].first;
    int k=P[i].second;
    if(k<n)
      A[k]=true;
    else
      B[k-n]=true;
  }
  int L=0,R=0;
  for(int i=0;i<n;i++){
    if(A[i]&&!B[i]){
      L++;
    }
    if(!A[i]&&B[i]){
      R++;
    }
  }
  if(L>0&&R>0&&L+R==n){
    long long S=INF;
    for(int i=0;i<n;i++){
      if(!A[i]){
	S=min(S,a[i]-(L>1&&P[n-1].first==b[i]?P[n-2].first:P[n-1].first));
      }
      if(!B[i]){
	S=min(S,b[i]-(R>1&&P[n-1].first==a[i]?P[n-2].first:P[n-1].first));
      }
    }
    ans+=S;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 4992
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] a = new int[n+1];
    for(int i = 0; i < n; i++){
      int tmp = sc.nextInt();
      a[tmp]++;
    }
    Arrays.sort(a);
    int count = 0;
    for(int i = 0; i <= a.length - 1 - k; i++){
      count += a[i];
    }
    
    System.out.println(count);
  }
}

Measured memory_bytes: 74920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll INF = (ll)1e9 * (ll)1e9 + 100;

ll calc(const vector<int>& v) {
	int d = v.size();
	ll dp[d + 1][10][10][4][2] = {};
	for (int i = 0; i < 10; i++) {
		for (int j = i + 1; j < 10; j++) {
			dp[0][i][j][0][0] = 1;
		}
	}
	for (int i = 0; i < d; i++) {
		for (int d1 = 0; d1 < 10; d1++) {
			for (int d2 = d1 + 1; d2 < 10; d2++) {
				if (i != 0 || d1 != 0) {
					if (d1 < v[i]) {
						for (int s = 0; s < 4; s++) {
							dp[i + 1][d1][d2][s | 1][1] = min(INF, dp[i + 1][d1][d2][s | 1][1] + dp[i][d1][d2][s][1]);
							dp[i + 1][d1][d2][s | 1][1] = min(INF, dp[i + 1][d1][d2][s | 1][1] + dp[i][d1][d2][s][0]);
						}
					}
					else if (d1 == v[i]) {
						for (int s = 0; s < 4; s++) {
							dp[i + 1][d1][d2][s | 1][1] = min(INF, dp[i + 1][d1][d2][s | 1][1] + dp[i][d1][d2][s][1]);
							dp[i + 1][d1][d2][s | 1][0] = min(INF, dp[i + 1][d1][d2][s | 1][0] + dp[i][d1][d2][s][0]);
						}
					}
					else {
						for (int s = 0; s < 4; s++) {
							dp[i + 1][d1][d2][s | 1][1] = min(INF, dp[i + 1][d1][d2][s | 1][1] + dp[i][d1][d2][s][1]);
						}
					}
				}
				if (d2 < v[i]) {
					for (int s = 0; s < 4; s++) {
						dp[i + 1][d1][d2][s | 2][1] = min(INF, dp[i + 1][d1][d2][s | 2][1] + dp[i][d1][d2][s][1]);
						dp[i + 1][d1][d2][s | 2][1] = min(INF, dp[i + 1][d1][d2][s | 2][1] + dp[i][d1][d2][s][0]);
					}
				}
				else if (d2 == v[i]) {
					for (int s = 0; s < 4; s++) {
						dp[i + 1][d1][d2][s | 2][1] = min(INF, dp[i + 1][d1][d2][s | 2][1] + dp[i][d1][d2][s][1]);
						dp[i + 1][d1][d2][s | 2][0] = min(INF, dp[i + 1][d1][d2][s | 2][0] + dp[i][d1][d2][s][0]);
					}
				}
				else {
					for (int s = 0; s < 4; s++) {
						dp[i + 1][d1][d2][s | 2][1] = min(INF, dp[i + 1][d1][d2][s | 2][1] + dp[i][d1][d2][s][1]);
					}
				}
			}
		}
	}
	ll all = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = i + 1; j < 10; j++) {
			all = min(INF, all + dp[d][i][j][3][1]);
		}
	}
	return all;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	ll N;
	while (cin >> N, N) {
		--N;
		ll d = 2;
		while (true) {
			ll cnt = calc(vector<int>(d, 9));
			if (N < cnt) break;
			N -= cnt;
			++d;
		}
		vector<int> res(d);
		for (int p = 0; p < d; p++) {
			while (res[p] < 9) {
				++res[p];
				if (N < calc(res)) {
					--res[p];
					break;
				}
			}
		}
		for (int i = 0; i < d; i++) {
			cout << res[i];
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3476
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

class union_find{
  int n_; 
  vector<int> par, rank, size;
public:
  union_find(int n): n_{n} {
    par.resize(n_);
    rank.resize(n_);
    size.resize(n_);

    REP(i, n_){
      par[i] = i;
      rank[i] = 1;
      size[i] = 1;
    }
  } 

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  ll unite(int x, int y) {
    x = find(x);
    y = find(y);

    if(x == y) return 0;

    if(rank[x] > rank[y]){
      par[y] = x;
      ll ret = 1LL * size[x] * size[y];
      size[x] += size[y];

      return ret;
    } else {
      par[x] = y;
      ll ret = 1LL * size[x] * size[y];
      size[y] += size[x];
      if(rank[x] == rank[y]) rank[y]++;

      return ret;
    }
  }

  int find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }

  vector<int> get_par(){ return par; }
};

int main() {
  ll n, m; cin >> n >> m;
  vector<int> a(m), b(m);
  REP(i, m){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }

  vector<ll> ans(m, 0LL);
  ans[m-1] = n * (n-1) / 2;

  union_find uf(n);
  for(int i=m-1; i>=0; i--){
    ll res = uf.unite(a[i], b[i]);
    
    if(i > 0) ans[i-1] = ans[i] - res;
  }

  REP(i, m) cout << ans[i] << endl;
    
  return 0;
}


Measured memory_bytes: 4096
import numpy as np

q = int(input())

# 高速素数判定
is_prime = np.ones(100001, dtype=int)
is_prime[0]=0
is_prime[1]=0

for i in range(2,100001):
    if is_prime[i]==1:
        j=i+i
        while j <= 100000:
            is_prime[j] = 0
            j += i

like2017 = [1 if is_prime[i] and is_prime[(i+1)//2] else 0 for i in range(0,100001) ]

for i in range(1,100001):
    like2017[i] += like2017[i-1]
for i in range(q):
    l,r = map(int, input().split())
    print(like2017[r]-like2017[l-1])


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

int main()
{
    int H,W;
    cin >> H >> W;
    int h,w;
    cin >> h >> w;
    int ans = (H-h)*(W-w);
    cout << ans <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  string S, T;
  cin >> S >> T;
  ll A, B;
  cin >> A >> B;
  string U;
  cin >> U;

  if (S == U)
    A--;
  else
    B--;
  cout << A << " " << B << endl;
}

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

int main()
{
  int x,y;
  while(1){
    cin >>x>>y;
    if(x==0 && y==0){break;}
    if(x>y){cout<<y<<" "<<x<<endl;}
    else{cout<<x<<" "<<y<<endl;}

  }
  return 0;
}
      

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

public class Main {
	int n,m;
	int[]A,B;

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

	void solve() {
		Scanner sc = new Scanner(System.in);
		n = Integer.parseInt(sc.next());
		m = Integer.parseInt(sc.next());
		A = new int[m];
		B = new int[m];
		long[] badP = new long[m];//逆順 不便度

		for(int i=0;i<m;i++) {
			A[i] = Integer.parseInt(sc.next())-1;
			B[i] = Integer.parseInt(sc.next())-1;
		}
		sc.close();

		UnionFind uf = new UnionFind(n);
		badP[m-1]=1L*n*(n-1)/2;

        for (int i = m - 1; i >= 1; i--) {
            if (uf.same(A[i], B[i])) {
                badP[i-1] = badP[i];
            } else {
                int sx = uf.size(A[i]);
                int sy = uf.size(B[i]);
                uf.union(A[i], B[i]);
                badP[i-1] = badP[i] - sx * sy;
            }
        }
		for(int i=0;i<m;i++)System.out.println(badP[i]);
	}

    class UnionFind {
        @SuppressWarnings("unused")
		private int n, t;
        private int[] parent, rank, size;

        public UnionFind(int n) {
            this.n = n;
            this.parent = new int[n];
            this.rank = new int[n];
            this.size = new int[n];
            Arrays.fill(rank, 1);
            Arrays.fill(size, 1);
            for (int i = 0; i < n; i++) parent[i] = i;
        }

        public void union(int x, int y) {
            t++;
            int _x = find(x);
            int _y = find(y);

            if (_x > _y) {
                parent[_y] = _x;
                size[_y] += size[_x];
                size[_x] = size[_y];
            } else if (_x < _y) {
                parent[_x] = _y;
                size[_x] += size[_y];
                size[_y] = size[_x];
            } else {
                parent[_y] = _x;
                rank[_y]++;
                size[_x] += size[_y];
                size[_y] = size[_x];
            }
        }

        public int find(int x) {
            if (x != parent[x]) {
                parent[x] = find(parent[x]);
            }
            return parent[x];
        }

        public int size(int x) {
            return size[find(x)];
        }

        public boolean same(int x, int y) {
            return find(x) == find(y);
        }
    }
}


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

int n,m;
bool graph[55][55];
bool vis[55];
void dfs(int v){
    if(vis[v])return;
    vis[v]=true;
    for(int i=0; i<=n; ++i){
        if(graph[v][i])dfs(i);
    }
}

int main(){
    cin>>n>>m;
    vector<pair<int,int>>p;
    rep(i,m){
        int a,b; cin>>a>>b;
        graph[a][b]=true;
        graph[b][a]=true;
        p.push_back(make_pair(a,b));
    }
    int ans=0;
    rep(i,m){
        for(int i=0; i<55; ++i)vis[i]=false;
        graph[p[i].first][p[i].second]=false;
        graph[p[i].second][p[i].first]=false;
        dfs(1);
        graph[p[i].first][p[i].second]=true;
        graph[p[i].second][p[i].first]=true;
        bool ok=true;
        for(int j=1; j<=n; ++j){
            if(!vis[j])ok=false;
        }
        if(!ok)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    agc031a()
}

private const val MOD = (1e9 + 7).toLong()
private fun mod(x: Long) = x % MOD

fun agc031a() {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    val answer = s.groupBy { it }.map { it.value.size }
        .fold(1L) { acc, i -> mod(acc * (i + 1)) } - 1

    println(mod(answer))
}


Measured memory_bytes: 34932
#include<stdio.h>
int main(void){
	int a, b, c, d, n, cnt;
	while(scanf("%d", &n) != EOF){
		cnt = 0;
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						if(a+b+c+d == n) cnt++;
					}
				}
			}
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 596