akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int dp[1<<21];
int sum[20][100001];
int a[100001];
int main(){
    int n,m;
    cin>>n>>m;
    rep(i,n) cin>>a[i];
    rep(i,m)rep(j,n){
        sum[i][j+1]=sum[i][j]+(a[j]-1==i);
    }
    rep(i,1<<m) dp[i]=1000100010;
    dp[0]=0;
    rep(i,(1<<m)){
        int cnt=0;
        rep(j,m){
            if(i>>j&1) cnt+=sum[j][n];
        }
        rep(j,m){
            if(i>>j&1) continue;
            else{
                dp[i|(1<<j)]=min(dp[i|(1<<j)],dp[i]+sum[j][n]-(sum[j][sum[j][n]+cnt]-sum[j][cnt]));
            }
        }
    }
    cout<<dp[(1<<m)-1]<<endl;
    return 0;
}


Measured memory_bytes: 15316
# ABC137D - Summer Vacation
import sys
from heapq import heappop, heappush

read = sys.stdin.buffer.read
heappop_max = lambda heap: -heappop(heap)
heappush_max = lambda heap, x: heappush(heap, -x)


def main():
    N, M, *all_jobs = map(int, read().split())
    available_jobs = [[] for _ in range(M + 1)]
    for waiting_days, reward in zip(*[iter(all_jobs)] * 2):
        if waiting_days <= M:
            available_jobs[waiting_days].append(reward)
    heap = []
    max_rewards = 0
    for jobs in available_jobs[1:]:
        for job in jobs:
            heappush_max(heap, job)
        if heap:
            max_rewards += heappop_max(heap)
    print(max_rewards)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24024
#include<deque>
#include<cstdio>

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	int a[100000];
	rep(i,n) scanf("%d",a+i);

	int dp[100000];
	rep(i,n) dp[i]=-1;

	deque< pair<int,int> > Q;
	Q.push_back(make_pair(0,0));
	while(!Q.empty()){
		int d=Q.front().first;
		int p=Q.front().second; Q.pop_front();

		if(dp[p]!=-1) continue;
		dp[p]=d;

		if(a[p]==0){
			for(int i=1;i<=6&&p+i<n;i++){
				Q.push_back(make_pair(d+1,p+i));
			}
		}
		else{
			Q.push_front(make_pair(d,p+a[p]));
		}
	}

	printf("%d\n",dp[n-1]);

	return 0;
}

Measured memory_bytes: 0
<?php
$cake = 4;
$donuts = 7;
$N = trim(fgets(STDIN));
$isExists = "No";
$x = floor($N / $cake);
$y = floor($N / $donuts);

for ($i = 0; $i <= $x; $i++) {
  for ($j = 0; $j <= $y; $j++) {
    $total = ($i * $cake) + ($j * $donuts);
    if ($N == $total) {
      $isExists = 'Yes';
    }
  }
}

printf("%s\n", $isExists);
?>

Measured memory_bytes: 4856
import std;
import core.bitop;

// dfmt off
ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
void aryWrite(T = long)(T[] ary){ ary.map!(x => x.text()).join(' ').writeln(); }
alias Pair = Tuple!(long, "B", long, "W");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto n = lread();
    auto tree = new long[][](n, 0);
    foreach (_; iota(n - 1))
    {
        long a, b;
        scan(a, b);
        tree[a - 1] ~= b - 1;
        tree[b - 1] ~= a - 1;
    }
    auto c = aryread.sort!"a>b"().array();

    auto cost = new long[](n);
    void bfs()
    {
        auto q = DList!(long)(0L);
        auto reached = new bool[](n);
        reached[0] = true;
        long idx;

        while (!q.empty)
        {
            auto f = q.front();
            q.removeFront();
            cost[f] = c[idx++];

            foreach (e; tree[f])
            {
                if (!reached[e])
                {
                    q.insertBack(e);
                    reached[e] = true;
                }
            }
        }
    }

    bfs();
    c.reverse.take(n - 1).sum().writeln();
    cost.aryWrite();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

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

    n = N%10;    

    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
        cout << "hon" << endl;
    }
    else if (n == 3){
        cout << "bon" << endl;
    }
    else
    {
        cout << "pon" << endl;
    }
    

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    int k;
    cin >> k;
    sort(v.begin(), v.end());
    v[2] <<= k;
    cout << accumulate(v.begin(), v.end(), 0) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List <Long> a = new ArrayList<>();
        for(int i = 0;i < n;i++){
            a.add(sc.nextLong());
        }
        List <Long> sum = new ArrayList<>();
        sum.add(a.get(0));
        for(int i = 1;i < n;i++){
            sum.add(sum.get(i-1) + a.get(i));
        }
        long min = 100000000000000L;
        //System.out.println(min);
        for(int i = 0;i < n-1;i++){
            long x = sum.get(i);
            long y = sum.get(n-1) - x;
            //System.out.println("x = " + x);
            //System.out.println("y = " + y);
            long abs = Math.abs(x-y);
            min = Math.min(min,abs);
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 93964
#include <stdio.h>
#include <stdlib.h>
int comp(const void *a, const void *b){
  int* arr1=(int*)a;
  int* arr2=(int*)b;
  int d0=arr1[0]-arr2[0];
  return d0;
}
int main(){
	int N;
	int A[200000];
	int B[200000];
	scanf("%d",&N);
	int i;
	int c[200000][2];
	for(i=0;i<N;i++){
		scanf("%d %d",&A[i],&B[i]);
		c[i][0]=B[i];
		c[i][1]=A[i];
	}
	qsort(c,N,2*sizeof(int),comp);
	long long int time;
	time=0;
	for(i=0;i<N;i++){
		time=time+(long long int)c[i][1];
		if(time>(long long int)c[i][0]){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
}


Measured memory_bytes: 4860
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;

int main() {
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
}

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

typedef struct{
  double x;
  double y;
}Point;

void kock(double n,Point p1,Point p2)//p1 と　p2の間に点を打つ p1^s^u^t^p2
{
  Point s,t,u;
 
  if (n == 0)return;//100回点を打ったら終わり
  // p1, p2 から s, t, u を計算
  s.x=(2*p1.x + p2.x) / 3;
  s.y=(2*p1.y + p2.y) / 3;
  
  t.x=(p1.x + 2 * p2.x) / 3;
  t.y=(p1.y + 2 * p2.y) / 3;

  u.x=(t.x - s.x) * cos(M_PI/3) - (t.y - s.y) * sin(M_PI / 3) + s.x;
  u.y=(t.x - s.x) * sin(M_PI/3) + (t.y - s.y) * cos(M_PI / 3) + s.y;
 
  kock(n-1, p1, s);//p1^s
  printf ("%.8f %.8f\n",s.x,s.y);
  
  kock(n-1, s, u);//s^u
  printf ("%.8f %.8f\n",u.x,u.y);
  
  kock(n-1, u, t);//u^t
  printf ("%.8f %.8f\n",t.x,t.y);
  
  kock(n-1, t, p2);//t^p2clear
}



int main()
{
  int n;
  Point p1={0,0};//スタート
  Point p2={100,0};//エンド 
  scanf("%d",&n);//この数だけ真ん中に点を打つ
  


  printf ("%.8f %.8f\n",p1.x,p1.y);//スタート
  kock(n,p1,p2);
  printf ("%.8f %.8f\n",p2.x,p2.y);//エンド

  return 0;
}




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

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var res = 0;
        var dic = new Dictionary<int, int>();
        for(var i = 0; i < num; i++)
        {
            if (dic.ContainsKey(ar[i])) dic[ar[i]]++;
            else dic[ar[i]] = 1;
        }
        foreach (var val in dic)
        {
            res += val.Key > val.Value ? val.Value : val.Value - val.Key;
        }
        WriteLine(res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


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

void case_all_negative(vector<long long> v, int n) {
    long long maxi = -2e9; int index = 0;
    for (int i = 0; i < n; i++) {
        maxi = max(maxi, v[i]);
        if (maxi == v[i]) index = i;
    }
    vector<int> ans;
    for (int i = 0; i < index; i++) {
        ans.push_back(1);
    }
    while (ans.size() != n-1) {
        ans.push_back(n-ans.size());
    }
    cout << maxi << endl;
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
}

int main() {
    int n; cin >> n;
    vector<long long> v(n);
    vector<bool> use(n, false);
    long long count[2];
    memset(count, 0, sizeof(count));
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        if (v[i] > 0) count[i%2] += v[i];
    }
    int t = ((count[0] > count[1]) ? 0 : 1);
    if (count[t] == 0) {
        case_all_negative(v, n);
        return 0;
    }
    for (int i = 0; i < n; i++) {
        if (i % 2 == t && v[i] > 0) use[i] = true;
    }
    vector<long long> ans;
    int con = 0; bool left = true;
    for (int i = 0; i < n; i++) {
        if (left) {
            if (use[i]) left = false;
            else ans.push_back(1);
        } else {
            if (use[i]) { 
                while (con > 1) {
                    ans.push_back(3);
                    con -= 2;
                }
                ans.push_back(2);
                con = 0;
            } else {
                con++;
            }
        }
    }
    while (con > 0) {
        ans.push_back(con+1);
        con--;
    }
    cout << count[t] << endl;
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String S = br.readLine();
            
            if(S.matches("[A-Z]")){
                System.out.println("A");
            }else{
                System.out.println("a");
            }
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 33712
<?php
/*
    Problem URL : http://abc060.contest.atcoder.jp/tasks/abc060_d

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

ini_set('memory_limit', '256M');

// define('DEBUG', true);
define('DEBUG', false);

$ans = 0;
$mem = array();

fscanf(STDIN, "%d %d %d", $A, $B, $C);

while ($A % 2 != 1 && $B %2 != 1 && $C %2 != 1) {
    $str = "{$A}_{$B}_{$C}";
    if (isset($mem[$str])) {
        echo "-1\n";
        exit;
    } else {
        $mem[$str] = 1;
    }

    $ans ++;

    $A2 = $A / 2;
    $B2 = $B / 2;
    $C2 = $C / 2;

    $A = $B2 + $C2;
    $B = $A2 + $C2;
    $C = $A2 + $B2;

    // echo "{$A} {$B} {$C}\n";
}

echo $ans . PHP_EOL;


Measured memory_bytes: 4856
import java.util.Scanner;

public class Main {

    static int N = 0;
    static int W = 0;
    static int[] wi;
    static int[] vi;
    static long memo[][]; //関数の結果を保存するための配列

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        N = Integer.parseInt(sc.next());
        W = Integer.parseInt(sc.next());
        wi = new int[N];
        vi = new int[N];
        memo = new long[N+1][W+1];

        for (int i = 0; i < N; i++) {

            wi[i] = Integer.parseInt(sc.next());
            vi[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        System.out.println(knap(0,W));

    }

    //全探索する再帰
    public static long knap(int i,int j) {

        if (memo[i][j] != 0) {

            return memo[i][j];
        }

        long res = 0;

        if (i == N) { //商品がもうないので0を代入する

            res = 0;
        } else if (j < wi[i]) { //容量不足なので入れない処理だけをする

            res = knap(i+1, j);
        } else { //入れると最大になるとは限らないので入れる時と入れない時の大きい方を取る

            res = Math.max(knap(i+1, j), knap(i+1, j-wi[i]) + vi[i]);
        }

        return memo[i][j] = res;
    }

}

Measured memory_bytes: 126412
#include<bits/stdc++.h>
#include<cstring>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int           long long
#define umapii        unordered_map<int,int>
#define ps(x,y)       fixed<<setprecision(y)<<x // sets precision upto required digits
#define arr(a,n)      int n;cin>>n;int a[n];for(int i=0;i<n;i++){cin>>a[i];}
#define outarr(a,n)   for(int i=0;i<n;i++){cout<<a[i]<<" ";}
#define mod           1000000007
#define ff            first
#define big           1e15
#define ss            second
#define add           push_back
#define remove        pop_back
#define mapii         map<int,int>
#define large         *max_element
#define small         *min_element
#define float         double
#define pqi           priority_queue<int>
#define mpqi          priority_queue<int,vector<int>,greater<int>>
#define in(n)         int n;cin>>n;
#define w(t)          int t;cin>>t;while(t--)
#define vi            vector<int>
#define vivi          vector<vector<int>>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>pbds;






int32_t main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output3.txt", "w", stdout);
#endif
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = max(max(a * c, a * d), max(b * c, b * d));
    cout << ans << endl;

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
	}
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M;
        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
lli solve(){
	lli n;
	cin>>n;
	vll dp(n+10, 0);
	loop(i, 1, 10)
		dp[i] = i;
	loop(i, 10, n+1){
		dp[i] = dp[i-1];
		if(i%10 == 0)
			continue;
		string s = to_string(i);
		lli len = s.length();
		if(len == 2){
			if(s[0] == s[len-1])
				dp[i] += 3;
			else if(s[0] > s[len-1])
				dp[i] += 2;
		}
		else{
			if(s[0] == s[len-1]){
				loop(j, 1, len-2){
					dp[i] += 2*power(10, j);
				}
				// dp[i] += len-3;
				string temp = s.substr(1, len-2);
				dp[i] += 2 * (stoi(temp)+1);
				dp[i] += 3;
			}
			else if(s[0] > s[len-1]){
				dp[i] += 2;
				loop(j, 1, len-1)
					dp[i] += 2*power(10, j);
				// dp[i] += len-2;
			}
			else{
				dp[i] += 2;
				loop(j, 1, len-2)
					dp[i] += 2*power(10, j);
				// dp[i] += len-2;
			}
		}
	}
	// cout<<stoi("0000000");
	// cout<<dp[151] - dp[150];
	cout<<dp[n]<<"\n";
	return 0;
}
int main(){
	fastio;
	lli t;
	// cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

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

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

  ll X; cin >> X;
  ll K; cin >> K;
  ll D; cin >> D;

  if (X < 0) X = -X;

  ll ans = 0;
  ll q = X / D;
  ll r = X % D;

  if (K < q) {
    cout << (X - K * D) << '\n';
    return 0;
  }

  if ((K - q) % 2 == 0) ans = r;
  else ans = D - r;
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> a(N,0);
    vector<int> b(N,0);

    for(int i=0; i<N; i++){
        a[i]=30000*i+1;
        b[N-1-i]=30000*i+1;
    }
    for(int i=0; i<N; i++){
        int p;
        cin >> p;
        p--;
        a[p]+=i;
        b[p]+=i;
    }

    for(int i=0; i<N; i++){
        cout << (i ? " " : "") << a[i];
    }
    cout << '\n';
    for(int i=0; i<N; i++){
        cout << (i ? " " : "") << b[i];
    }
    cout << '\n';
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define pb push_back
#define point pair <int, int>
#define files(FileName) read(FileName); write(FileName)
#define read(FileName) freopen((FileName + ".in").c_str(), "r", stdin)
#define write(FileName) freopen((FileName + ".out").c_str(), "w", stdout)
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }

int n;
vector <int> arr;

int main() {
	ios::sync_with_stdio(false);
	srand(time(0));
	//read(FILENAME); 
	cin >> n;
	arr.resize(n * 2);
	for (int i = 0; i < n * 2; ++i)
		cin >> arr[i];
	sort(arr.begin(), arr.end());
	long long ans = 0;
	for (int i = 0; i < n * 2; i += 2) 
		ans += arr[i];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MD 1000000007
using namespace std;
int main(){
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	long long n,m,ans=0;
	cin>>n>>m;
	if(n>m) swap(n,m);
	if(m-n>1){
		cout<<0<<endl;
		return 0;
	}
	int i;
	if(m-n){
		ans=1;
		for(i=1;i<=n;i++) ans=((ans%MD)*(i%MD))%MD;
		for(i=1;i<=m;i++) ans=((ans%MD)*(i%MD))%MD;
		cout<<ans<<endl;
		return 0;
	}else{
		ans=1;
		for(i=1;i<=n;i++) ans=((ans%MD)*(i%MD))%MD;
		for(i=1;i<=n;i++) ans=((ans%MD)*(i%MD))%MD;
		ans%=MD;
		ans=ans*2;
		ans%=MD;
		cout<<ans<<endl;
		return 0;
	}
	#ifdef home
        eprintf("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
}


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

long long INF=1e18;

int main()
{
    int n;
    cin>>n;
    int x=(n+1)/2;
    double ans=double(x)/double(n);
    cout<<fixed;
    cout<<setprecision(10)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
const int mx = 107;
int n;
int x;
unordered_map<int, int> mp;

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    cin >> x >> n;
    FOR(i,1,n){
        int p; cin >> p;
        mp[p]++;
    }
    int diff = 0;
    while(true) {
        if(mp[x-diff]==0) {
            cout << x-diff << endl;
            return 0;
        }  
        if(mp[x+diff]==0){
            cout << x+diff << endl;
            return 0;
        }
        diff++;
    }
    return 0;
}


Measured memory_bytes: 3620
N,W = map(int, input().split())
wv = [[int(x) for x in input().split()] for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j - wv[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]] + wv[i][1])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[N][W])

Measured memory_bytes: 120044
/**
 * 	author: krayr
 * 	created: 20.05.2019
**/

#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define mp make_pair
#define forn(i, s, n) for(int i = s; i < int(n); i++)

typedef long long ll;
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int MAX_N = 1e6+5;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
       
    #ifdef _DEBUG
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    
	  int n, k; cin >> n >> k;
    string s; cin >> s;

    forn(i, 0, n){
      if(i == k-1){
        cout << char(tolower(s[i]));
      }else{
        cout << s[i];
      }
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())

if x1 <= x2 and y1 <= y2:
    dx, dy = abs(x2 - x1), abs(y2 - y1)
    x3 = -dy + x2
    y3 = dx + y2
    x4 = -dy + x1
    y4 = dx + y1
elif x2 <= x1 and y1 <= y2:
    dx, dy = abs(x1 - x2), abs(y2 - y1)
    x3 = -dy + x2
    y3 = -dx + y2
    x4 = -dy + x1
    y4 = -dx + y1
elif x1 <= x2 and y2 <= y1:
    dx, dy = abs(x2 - x1), abs(y2 - y1)
    x3 = dy + x2
    y3 = dx + y2
    x4 = dy + x1
    y4 = dx + y1
elif x2 <= x1 and y2 <= y1:
    dx, dy = abs(x1 - x2), abs(y2 - y1)
    x3 = dy + x2
    y3 = -dx + y2
    x4 = dy + x1
    y4 = -dx + y1

print(x3, y3, x4, y4)


Measured memory_bytes: 3064
#include<stdio.h>

int main(){

    int N, M;

    int min, Max;

    int ans;

    scanf("%d", &N);
    scanf("%d", &M);

    min = 1;
    Max = N;

    int L[M];
    int R[M];

    for(int i = 0; i < M; i++){
        scanf("%d", &L[i]);
        scanf("%d", &R[i]);
    }

    for(int i = 0; i < M; i++){

        if(min < L[i]){
            min = L[i];
        }

        if(Max > R[i]){
            Max = R[i];
        }
    }

    if(min<=Max){
        ans = Max - min + 1;
    }else{
        ans = 0;
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 896
N = int(input())
A = list(map(int,input().split()))

l,r = 0,0
num = 0
ans = 0
while r<N:
    if num^A[r] == num + A[r]:
        num += A[r]
        r += 1
        ans += r-l
        #print(l,r,num)
    else:
        if l==r:
            l += 1
            r += 1
            #print(l,r,num)
        else:
            num -= A[l]
            l += 1
            #print(l,r,num)
print(ans)

Measured memory_bytes: 77644
#include <cstdio>
#include <utility>
#include <string>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define bs inline bool scan
ii(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
ii() {return in(gcu());}
bs(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bs(char &c){c=gcu();gcu();return c!=EOF;}
bs(string &s){int c; s = "";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#undef ii
#undef bs
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
//vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

int main() {
	vector<int> c(10);
	c = {1};
	for (int i = 1; i < 10; i++)
		c[i] = c[i - 1] * (10 - i) / i;
	for (string s; scan(s);) {
		int b = 0;
		for (int i = 0; i < 10; i++)
			b += (s[i] - '0') * c[i];
		out(b % 10, '\n');
	}
}


Measured memory_bytes: 2516
import java.util.Scanner;


public class Main {

	private static int[][] cache;
	private static char[] x;
	private static char[] y;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int set = sc.nextInt();

		for (int k = 0; k < set; k++) {
			x = sc.next().toCharArray();
			y = sc.next().toCharArray();
			if (y.length > x.length) {
				char[] temp = x;
				x = y;
				y = temp;
			}
			int m = x.length;
			int n = y.length;
			
			// ボトムアップ型、メモリ節約
			cache = new int[2][Math.min(m, n) + 1];
			// 初期化不要(0)

			for (int i = 1; i <= m; i++) {
				for (int j = 1; j <= n; j++) {
					if (x[i - 1] == y[j - 1]) {
						cache[i % 2][j] = cache[(i - 1) % 2][j - 1] + 1;
					} else {
						cache[i % 2][j] = Math.max(cache[(i - 1) % 2][j], cache[i % 2][j - 1]);
					}
				}
			}
			
			System.out.println(cache[m % 2][n]);
		}
		
         sc.close();
	}
}

Measured memory_bytes: 21488
#include<stdio.h>

int main(void)
{
	int x, y, d, z;
	scanf( "%d", &x );
	scanf( "%d", &y );
	
	if( x < y ){
		z = x;
		x = y;
		y = z;
	}
	
	d = x % y;
	
	while( d != 0 ){
		x = y;
		y = d;
		d = x % y;
	}
	
	printf( "%d\n", y );
	
	return 0;
}


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

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

    int sum = (2*l+n-1)*n/2;
    if (l >= 0) cout << sum - l << endl;
    else if (l >= (1-n)) cout << sum << endl;
    else cout << sum - (l+n-1) << endl;
}

Measured memory_bytes: 256
let N = stdin.ReadLine() |> int
let W = stdin.ReadLine().Split() |> Array.map int

let rec resolver l r t i =
    if i = -1 then t
    else
        let ln = l - W.[i]
        let rn = r + W.[i]
        if t < abs (ln - rn) then t
        else resolver ln rn (abs (ln - rn)) (i - 1)

resolver (Array.sum W) 0 (Array.sum W) (N - 1) |> stdout.WriteLine


Measured memory_bytes: 13268
#include <stdio.h>
#include <algorithm>
using namespace std;

const int N = 1e5+10;

int n;
int T[N];
int DP[N];

int abso(int x){
  return x<0 ? -x : x;
}

int main(){
  scanf("%d",&n);
  for(int i=1; i<=n; i++)scanf("%d",&T[i]);
  DP[2] = abso(T[1]-T[2]);
  for(int i=3; i<=n; i++){
    DP[i] = min(DP[i-2]+abso(T[i-2]-T[i]),DP[i-1]+abso(T[i-1]-T[i]));
  }
  printf("%d\n",DP[n]);


  return 0;
}


Measured memory_bytes: 896
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    int n;
    string s;
    cin >> n >> s;
    if(s.size()<=n){
        cout << s << endl;
    }
    else{
        string t=s.substr(0,n);
        t+="...";
        cout << t << endl;
    }
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3632
s=input()
k=int(input())
p=s[0]
cnt=1
q=[]
for i in range(len(s)-1):
	if s[i+1]==p:
		cnt+=1
	else:
		q.append(cnt)
		cnt=1
		p=s[i+1]
q.append(cnt)
if q[-1]%2==0:
	cnt=True
else:
	cnt=False
ans=0
if cnt==True:
	for i in range(len(q)):
		ans+=q[i]//2
	print(ans*k)
	exit()
if len(q)==1:
	print(len(s)*k//2)
	exit()
for i in range(len(q)-2):
	ans+=q[i+1]//2
ans*=k
ans+=q[0]//2
if s[0]==s[-1]:#miss
	ans+=(q[0]+q[-1])//2*(k-1)
	ans+=q[-1]//2
	print(ans)
	exit()
else:
	ans=0
	for i in range(len(q)):
		ans+=q[i]//2
	print(ans*k)

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

int main() {
  int A,B;
  cin >> A >> B;
  int C = A+B;
  if(A%3 == 0 || B%3 == 0 || C%3 == 0){
    cout << "Possible" << endl;
    return 0;
  }
  cout << "Impossible" << endl;

}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

const int mod = 1e9+7;

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	vector<int> ch(n, 0);
	rep(i, n){
		int in;
		cin >> in;
		ch.at(in)++;
	}

	ll ans = 1;
	if(n % 2 == 0){
		if(ch.at(0) == 0){
			rep2(i, 1, n){
				if(ch.at(i) == 2) ans = (ans * 2) % mod;
				else{
					ans = 0;
					break;
				}
				i++;
			}
		}else{
			ans = 0;
		}
	}else{
		if(ch.at(0) == 1){
			rep2(i, 2, n){
				if(ch.at(i) == 2) ans = (ans * 2) % mod;
				else{
					ans = 0;
					break;
				}
				i++;
			}
		}else{
			ans = 0;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>

#define MOD 1000000007
#define INF INT_MAX
#define LLINF LLONG_MAX
using ll = long long;
using namespace std;

int main() {
    vector<bool> p(100001, true);
    vector<int> c(100001);
    int Q;
    cin >> Q;
    p[0] = p[1] = false;
    for (int i = 2; i <= 100000; i++)
    {
        if (p[i]) {
            for (int j = 2; i*j <= 100000; j++)
            {
                p[i*j] = false;
            }
        }
    }
    c[0] = c[1] = c[2] = 0;
    for (int i = 3; i <= 100000; i++)
    {
        c[i] = c[i - 1];
        if (p[i] && p[(i + 1) / 2]) {
            c[i]++;
        }
    }
    for (int i = 0; i < Q; i++)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", c[r] - c[l - 1]);
    }
    getchar(); getchar();
    return 0;
}

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

using namespace std;

#define LL long long
#define ULL unsigned LL
#define LD long double
#define debug(x) cerr << #x << " " << x << endl;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	LL a, b, n;
	cin>>a>>b>>n;
	LL x = min(b-1, n);
	LL w = (a*x)/b - a * (x/b);
	cout<<w;
}


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

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

    int y = stoi(S.substr(0, 4)),
        m = stoi(S.substr(5, 2)),
        d = stoi(S.substr(8, 2));

    if( y < 2019 ) cout << "Heisei" << endl;
    else if( 2019 < y ) cout << "TBD" << endl;
    else {
        if( m < 4 ) cout << "Heisei" << endl;
        else if( 4 < m ) cout << "TBD" << endl;
        else {
            if( d <= 30 ) cout << "Heisei" << endl;
            else cout << "TBD" << endl;
        }
    }

    return 0;
}


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

int main() {
    int n, m, s, c, ans = 0;
    cin >> n >> m;
    vector<int> number(n, -1);
    bool flag = true;
    rep(i, m) {
        cin >> s >> c;
        if(number.at(s - 1) == -1) number.at(s - 1) = c;
        else if(number.at(s - 1) != c) flag = false;
    }
    if(n != 1 && number.at(0) == 0) flag = false;
    if(n != 1 && number.at(0) == -1) number.at(0) = 1;
    else if(n == 1 && number.at(0) == -1) number.at(0) = 0;
    if(flag) {
        rep(i, n) {
            if(number.at(i) == -1) number.at(i) = 0;
            ans = 10 * ans + number.at(i);
        }
    } else {
        ans = -1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static int[] sx;
    static int[] sy;
    static int[] nx = {-1, 0, 1, -2, 2, -2, 2, -2, 2, -1, 0, 1};
    static int[] ny = {-2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 2};
    static boolean flag = false;

    static void dfs(int n, int d, int px, int py){
        if(d == n){
            flag = true;
            return;
        }else{
            int x = sx[d];
            int y = sy[d];
            for(int k = 0; k < 12; k++){  // ぴょん吉の移動先
                int nextx = px + nx[k];
                int nexty = py + ny[k];
                if(nextx < 0 || nextx >= 10 || nexty < 0 || nexty >= 10) continue;
                for(int i = -1; i <= 1; i++){
                    for(int j = -1; j <= 1; j++){   // 噴水の届く範囲
                        int wx = x + i;
                        int wy = y + j;
                        if(wx < 0 || wx >= 10 || wy < 0 || wy >= 10) continue;
                        if(nextx == wx && nexty == wy){
                            dfs(n, d + 1, nextx, nexty);
                        }
                    }
                }
            }
        }
    }

    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
       while(true){
           int px = sc.nextInt();
           int py = sc.nextInt();
           if(px + py == 0) break;
           flag = false;
           int n = sc.nextInt();
           sx = new int[n];
           sy = new int[n];
           for(int i = 0; i < n; i++){
               sx[i] = sc.nextInt();
               sy[i] = sc.nextInt();
           }
           dfs(n, 0, px, py);
           if(flag){
               System.out.println("OK");
           }else{
               System.out.println("NA");
           }
       }
   }
}


Measured memory_bytes: 26248
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  long long int arr[n], max = 1e18, prod = 1, flag = 0, zero = 0;
  
  for (int i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
    flag = (arr[i] > max) ? 1 : flag;
    prod *= arr[i];
    (arr[i]) ? max /= arr[i] : zero = 1;
  }

  (zero) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));
  return 0;
}

Measured memory_bytes: 3940
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
#define minn(x,y) x=min(x,y)
#define maxx(x,y) x=max(x,y)
using namespace std;
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d%d",&n,&m);
	n--;
	for(i=m-n;i<=n+m;i++)
	{
		printf("%d ",i);
	}
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll K, A, B; cin >> K >> A >> B;
  
  ll ans = 1;

  if(B-A < 2) {
    ans += K;
  } else {
    ll k1 = K - (A - 1);
    if(k1 < 0) {
      ans += K;
    } else {
      ans += (A - 1);
      ans += (k1 / 2) * (B - A);
      ans += k1 % 2;
    }
  }
  
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
    int ar[100000],num,h,i,j=0;
    scanf("%d%d",&num,&h);
    for(i=0;i<num;i++){
        scanf("%d",&ar[i]);
    }
    printf("\n");
    for(i=0;i<num;i++){
        if(ar[i]>=h)
            j++;
    }
    printf("%d\n",j);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    string s;
    cin >> s;
    int k = (int)s.size();
    for(int i = 0; i < k - 8; i++){
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[200007],b[2000007];
priority_queue<pair<int,int> >q;
int n;
int mi(int x){
    return x==1?n:x-1;
}
int pl(int x){
    return x==n?1:x+1;
}
int main(){
    cin>>n;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    for(int i=1;i<=n;++i){
        cin>>b[i];
        q.push({b[i],i});
    }
    long long ans=0;
    while(!q.empty()){
        int i=q.top().second;
        q.pop();
        if(b[i]==a[i])
            continue;
        if(a[i]>b[i]-b[mi(i)]-b[pl(i)])
            return puts("-1"),0;
        int tmp=b[mi(i)]+b[pl(i)];
        int tot=b[i]-a[i];
        ans+=tot/tmp;
        tot%=tmp;
        b[i]=a[i]+tot;
        if(a[i]>b[i])
            return puts("-1"),0;
        if(a[i]!=b[i])
            q.push({b[i],i});
    }
    cout<<ans;
    return 0;
}


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

#define int unsigned long long

using namespace std;



int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int A;
long double B;
    cin >> A >> B;
long double D = A;
long double res = A*B;
int otro = res;
B*=100.0;
int c = B;


    int temp = A*B;
if(otro > temp/100)cout << otro << '\n';
    else cout << temp/100 << '\n';

    return 0;
}


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

int n,k,card[10],count;
int check[10001];

// used[i]==1ÈçÎ iÍgÁÄ¢é
// used[i]==1ÈçÎ card[i]ÍgÁÄ¢é

void func(int a[],int now)
{
	int i,j,temp,keta=0,flg;
	
	if(now == k){
		char str[9];
		for(i=0;i<k;i++){
			temp=sprintf(str+keta,"%d",a[i]);
			keta+=temp;
		}
		temp=atoi(str);
		check[count]=temp;
		count++;
	}
	
	else {
		int used[10] = { 0 };
		
		for(i=0; i<now; i++){
			for(j=0;j<n;j++){
				if(a[i]==card[j] && used[j]==0){
					used[j]=1;
					break;
				}
			}
		}
		
		for(i=0;i<n;i++){
			if(used[i] == 0){
				a[now] = card[i];
				func(a,now+1);
			}
		}
	}
}

int main(void)
{
	int i,j,array[5];
	while(scanf("%d",&n),n){
		scanf("%d",&k);
		for(i=0;i<n;i++){
			scanf("%d", &card[i]);
		}
		
		func(array,0);
		for(i=0;i<count;i++){
			for(j=0;j<count;j++){
				if(check[i]==check[j] && i!=j && check[i]!=0){
					check[j]=0;
				}
			}
		}
		
		count=0;
		for(i=0;i<10000;i++){
			if(check[i]!=0){
				count++;
			}
		}
		printf("%d\n",count);
		
		for(i=0;i<10001;i++){
			check[i]=0;
		}
		count=0;
		for(i=0;i<10;i++){
			card[i]=0;
		}
		
	}
	return 0;
}

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


int main() {

	ll n; cin>>n;
	string str; cin>>str;

	ll r=0,g=0,b=0;
	for(ll i=0;i<n;i++){
		if(str[i]=='R')r++;
		else if(str[i]=='G')g++;
		else b++;
	}
	ll res=r*g*b;

	for(ll i=0; i<n; i++){
		for(ll j=i+1; j<n; j++){
			if(str[i] == str[j])continue;
			ll k = j+(j-i);
			if(k >= n)continue;
			if(str[k] == str[i] || str[k] == str[j])continue;
			res--;
		}
	}
	cout<<res<<endl;
}


Measured memory_bytes: 3640
#include<iostream>

using namespace std;

int main(void)
{
	int a,b,c,k;
	cin >> a >> b >> c >> k;

	int x=max(a,max(b,c));

	int ans=a+b+c-x;

	for(int i=1;i<=k;i++)
		x*=2;

	ans+=x;

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<=(n); i++)
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define gsort(x,n) sort(x,x+n,greater<int>())
#define rv(s) reverse((s).begin(),(s).end())
#define abs(a) llabs(a)
#define int int64_t
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define INF 1000000000;
int n,h[100005],mem[100005];
 
signed dp(int i){
if(i == 1) return 0;
if(i < 1) return INF;
if(mem[i] != -1) return mem[i];
 
int a1 = dp(i - 1) + abs(h[i-1] - h[i]);
int a2 = dp(i - 2) + abs(h[i-2] - h[i]);
return mem[i] = min(a1,a2);
}
 
signed main(){
int n;
cin >> n;
memset(mem,-1,sizeof(mem));
 
reps(i,n){
cin >> h[i];
}
 
cout<<dp(n)<<'\n';
return 0;
}

Measured memory_bytes: 4992
Scanf.scanf "%d" (fun n ->
    Printf.printf "%d\n" @@ n * (n - 1) / 2 - n / 2;
    let m = n + 1 - n mod 2 in
    for i = 1 to n - 1 do
        for j = i + 1 to n do
            if i + j <> m then Printf.printf "%d %d\n" i j
        done
    done
)

Measured memory_bytes: 5272
#include<bits/stdc++.h>
using namespace std;
stack<int> pila;
int operacion(string ss){
    int a,b;
    a=pila.top();
    pila.pop();
    b=pila.top();
    pila.pop();
    if(ss=="+") return a+b;
    if(ss=="-") return b-a;
    if(ss=="*") return a*b;
}

int main(){
    ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	int a,b;
	while(cin>>s){
        if(s=="+"||s=="-"||s=="*"){
            pila.push(operacion(s));
        }else{
            pila.push(atoi(s.c_str()));
        }
	}
	cout<<pila.top()<<"\n";
    return 0;
}




Measured memory_bytes: 3204
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define db long double
# define IOS ios_base :: sync_with_stdio(0)
# define halt(...) {fo << (__VA_ARGS__) << '\n';exit(0);}
# define pp(n) cerr << #n << " = " << n << '\n'
# define ppp(v) for (auto it : v) cerr << it << ' ';cerr << '\n'
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    vector < string > s;
    int n,l;
    fi>>n>>l;
    for (int i = 0;i < n;++i)
    {
        string str;
        fi>>str;
        s.push_back(str);
    }
    sort(s.begin(),s.end(),[&](string a,string b)
    {
        return a + b < b + a;
    });
    for (int i = 0;i < n;++i) fo << s[i];
    fo << '\n';
}




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

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}


int main(){
    int a,b,H,M;
    cin >> a >> b >> H >> M;
    double hd = 0,md = 0;
    bool flag = false;
    for(int i=0;i<12;i++) {
        for(int j=0;j<60;j++) {
            if(i==H && M==j){
                flag = true;
                break;
            }
            hd += 0.5;
            md += 6.0;
        }
        if(flag)break;
        md = 0;
    }
    double ans = sqrt(a*a + b*b  - 2*a*b*cos((hd-md)* M_PI / 180));
    printf("%.20f\n",ans);

    return 0;
}

Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, L;
  cin>>N>>L;
  string res = "";
  string S[N];
  for(int i=0;i<N;i++){
    cin>>S[i];
  }
  sort(S, S+N);
  for(int i=0;i<N;i++){
    res.append(S[i]);
  }
  cout<<res<<endl;
}


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

int main(){
	int n;
    string s;
    int cnt=0;
    int ans=0;
	cin>>n>>s;
    for (int i=0;i<n;i++){
        if (s[i]=='D') cnt-=1;
        else cnt+=1;
        ans=max(ans,cnt);
    }
	cout<<ans<<endl;
    return 0;

}


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

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(a+b>=c) puts("Yes");
    else puts("No");
    
    return 0;
}








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

int b[100];
int main() {
    int n, ans;
    cin >> n;
    for(int i=0; i<n-1; i++) cin >> b[i];

    ans = b[0];
    for(int i=0; i<n-2; i++) {
        if(b[i]<=b[i+1]) ans += b[i];
        else ans += b[i+1];
    }
    ans += b[n-2];

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int n;
   cin >> n;
   vector<int> str(n);
	for (int i = 0; i < (n); i++) cin >> str.at(i);
  	int j = 0;
  	int count = 0;
  	for (int i = 0; i < n; i++) {
      j= str.at(j) - 1;
      count++;
      if(j==1){ 
      cout << count << endl;
      break;
      }
      else if (i==n-1) cout << -1 << endl;
    }
      
}

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main(){

    input!{
        n: usize,
        k: usize,
        q: usize,
        a: [usize;q],
    }

    let mut dp1: Vec<i64> = vec![0;n];
    let d: i64 = (k as i64) - (q as i64);
    let mut dp2: Vec<i64> = vec![d;n];

    for i in 0..q{
        dp1[a[i]-1] += 1;
    }

    for i in 0..n {
        dp2[i] = dp2[i] + dp1[i];
        if dp2[i] > 0 {
            println!("Yes");
        } else {
            println!("No");
        }
    }

}

Measured memory_bytes: 6780