akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define unmap unordered_map<int, int>
#define unset unordered_set<int>
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define ll long long
#define ull unsigned ll
#define ff first
#define ss second //typedef second ss;
#define foton(i, n) for (int i = 0; i < n; i++)
#define faton(i, a, n) for (int i = a; i <= n; i++)
#define mod 1000000007
#define endl "\n"
using namespace std;
void solve()
{
    ll n;
    cin >> n;
    string ans = "";
    while (n > 0)
    {
        n -= 1;
        ans += char('a' + (n % 26));
        n = floor(n / 26);
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

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

Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.L;
		int q=(int)Sqrt(n);
		for(int i = q;i>0;i--) {
			if(n%i==0){
				Console.WriteLine("{0}",i+n/i-2);
				break;
			}
		}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
def main():
    N, M = map(int, input().split())

    N, M = min(N, M), max(N, M)

    if N==1 and M==1:
        print(1)
    elif N==1 and M > 1:
        print(M-2)
    else:
        print((N-2)*(M-2))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <stdio.h>
int main(void)
{
    int H, W, i, j;
    while(1)
    {
        scanf("%d %d", &H, &W);
        if( H == 0 && W == 0 )
        {
            break;
        }
        for(i = 1; i <= H; i++)
        {
            for(j = 1; j <= W; j++)
            {
                if((i + j) % 2 == 0)
                {
                    printf("#");
                }
                else
                {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

struct cmp{
	bool operator() (const string &s, const string &t){
		return s.size() != t.size() ? s.size() < t.size() : s < t;
	}
};

int main(){
	map<string,int,cmp> mp;
	int n, x;
	string s;
	
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> s >> x;
		mp[s] += x;
	}
	
	for(map<string,int,cmp>::iterator it = mp.begin(); it != mp.end(); ++it){
		cout << it->first << ' ' << it->second << '\n';
	}
}

Measured memory_bytes: 1224
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main(){
	int N,K;
	int dp[11][2001];
	int c,g;
	vector<int> tp[11];
	
	scanf("%d %d",&N,&K);
	for(int i=0;i<N;i++){
		scanf("%d %d",&c,&g);
		tp[g].push_back(c);
	}
	for(int i=1;i<=10;i++){
		sort(tp[i].begin(),tp[i].end());
		reverse(tp[i].begin(),tp[i].end());
		for(int j=1;j<=K;j++){
			int sum=0;
			for(int k=0;k<=(int)tp[i].size();k++){
				if(j-k<0)
				break;
				if(k)
				sum+=tp[i][k-1];
				dp[i][j]=max(dp[i][j],dp[i-1][j-k]+(k-1)*k+sum);
			}
		}
	}
	printf("%d\n",dp[10][K]);
}


Measured memory_bytes: 3368
import java.util.Scanner;

public class Main {

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

	void solve() {
		Scanner sc = new Scanner(System.in);
		char[] C = sc.next().toCharArray();
		String S = "";
		sc.close();
		for(int i=0;i<C.length;i++) {
			if(C[i]=='B') {if(S.length()>0)S=S.substring(0, S.length()-1);}
			else S+=C[i];
		}
		System.out.println(S);
	}
}


Measured memory_bytes: 21844
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (u == s) a--;
    if (u == t) b--;
    cout << a << " " << b << endl;
    return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const int MAX = 1000000;
const long long INF = 5e9+1;
int V;
typedef pair<int, int> pii; /*first: 距離 second: 接続先*/
vector<pii> G[MAX];
long long dist[MAX];
int prev[MAX];
bool used[MAX];
void dijkstra(int s){
    fill(dist, dist+MAX, INF);
    fill(used, used+MAX, false);
    fill(prev, prev+MAX, -1);
    priority_queue<pii, vector<pii>, greater<pii> > q;
    q.push(pii(0, s));
    while(!q.empty()){
            int d; int t;
            pii p = q.top(); q.pop();
            d = p.first; t = p.second;
            if(used[t]) continue;
            used[t] = true; dist[t] = d;
            for(int i=0; i < G[t].size(); i++){
                        pii e = G[t][i];
                        if(dist[e.second] <= d+e.first) continue;
                        q.push(pii(d+e.first, e.second));
                        prev[e.second] = t;
                    }
        }
}

int main(){
    int E, S;
    cin >> V >> E >> S;
    for(int i=0; i< E; i++){
        int s, t, d;
        cin >> s >> t >> d;
        G[s].push_back(make_pair(d, t));
    }
    dijkstra(S);
    int ans = 0;
    vector<int> v;
    for(int i=0; i< V; i++){
        if(dist[i] == INF) cout << "INF" << endl;
        else cout << dist[i] << endl;
    }
}

Measured memory_bytes: 45740
#include<stdio.h>
int main(void){
	int n,black=0,i,white=0,ans=0,sum=0;
	scanf("%d",&n);
	char s[n];
	scanf("%s",s);

	for(i=0;i<n;i++){
		if(s[i]=='.'){white++;}
	}

	ans=white;

	for(i=0;i<n;i++){
		if(s[i]=='#'){black++;}
		else {white--;}
		sum = black + white;
		if(sum < ans){
			ans = sum;
		}
	}

	printf("%d\n",ans);

	return 0;
}


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


int main() {
    int N; cin >> N;
    vector<int> V(N);
    for(int &v:V)
        cin >> v;
    
    int c = 0;
    for(int i=0; i<N; i++){
        c ^= V[i];
    }
    
    if(c==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



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

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var N = int.Parse(Console.ReadLine());
            var dp = new List<long>[N];
            for (var i = 0; i < N; i++) dp[i] = new List<long>() { 0, 0, 0 };
            var abc = new List<long>[N];
            for (var i = 0; i < N; i++) abc[i] = RL<long>().ToList();
            dp[0] = abc[0];
            for (var i = 1;i < N; i++) {
                for(var j = 0; j < 3; j++) {
                    for(var k = 0; k < 3; k++) {
                        if (j == k) continue;
                        dp[i][k] = Math.Max(dp[i][k], dp[i - 1][j] + abc[i][k]);
                    }
                }
            }
            Console.Write(dp[N - 1].Max());
        }

        static T[] RL<T>() where T : IComparable {
            if (typeof(T) == typeof(int)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
            }
            if (typeof(T) == typeof(long)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            }
            if (typeof(T) == typeof(double)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(double.Parse).ToArray();
            }
            if (typeof(T) == typeof(decimal)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(decimal.Parse).ToArray();
            }
            return (T[])(object)Console.ReadLine().Trim().Split().ToArray();
        }
    }
}

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

int isprime(int n){
  if(n==1){
    return 0;
  }
  else{
    int m=sqrt(n);
    for(int i=2; i<=m; i++){
      if(n%i==0){
        return 0;
      }
    }
    return 1;
  }
}

int reverse(int64_t n){
  int k=1000000005;
  int64_t m=n;
  int64_t Ans=1;
  while(k>0){
    if(k%2==1){
      Ans*=m;
      Ans%=1000000007;
    }
    m*=m;
    m%=1000000007;
    k/=2;
  }
  return Ans;
}

int H(int n, int m){
  int64_t Ans=1;
  for(int i=n+1; i<n+m; i++){
    Ans*=i;
    Ans%=1000000007;
  }
  for(int i=1; i<m; i++){
    Ans*=reverse(i);
    Ans%=1000000007;
  }
  return Ans;
}

int main(){
  int N, M;
  cin >> N >> M;
  set<int> D;
  int S=sqrt(M);
  for(int i=1; i<=S; i++){
    if(M%i==0){
      D.insert(i);
      D.insert(M/i);
    }
  }
  set<int> P;
  while(D.size()!=0){
    int p=*D.begin();
    if(isprime(p)==1){
      P.insert(p);
    }
    D.erase(D.begin());
  }
  int L=P.size();
  vector<int> G(L);
  int j=0;
  while(P.size()!=0){
    int p=*P.begin();
    while(M%p==0){
      G.at(j)++;
      M/=p;
    }
    j++;
    P.erase(P.begin());
  }
  if(N==1){
    cout << 1 << endl;
  }
  else{
    int64_t Ans=1;
    for(int i=0; i<L; i++){
      Ans*=H(G.at(i), N);
      Ans%=1000000007;
    }
    cout << Ans << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

int main() {
    int X, ansa = -1, ansb = -1;
    cin >> X;
    for (int a = -120; a <= 120; a++) {
        for (int b = -120; b <= 120; b++) {
            if (a * a * a * a * a - b * b * b * b * b == X) {
                ansa = a, ansb = b;
                break;
            }
        }
    }
    cout << ansa << " " << ansb << endl;
    return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define maxc 100005
#define maxn 105
using namespace std;

int w[maxn], v[maxn], dp[maxc];
int n, W, sum = 0;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> W;
    for(int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
        sum += v[i];
    }
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;

    for(int i = 0; i < n; i++) {
        for(int j = sum; j >= v[i]; j--) {
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
        }
    }
    for(int i = sum; i >= 0; i--) {
        if(dp[i] <= W) {
            cout << i << '\n';
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 4064
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;


#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point {
 public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x+p.x, y+p.y); }
  Point operator - (Point p) { return Point(x-p.x, y-p.y); }
  Point operator * (double a) { return Point(a*x, a*y); }
  Point operator / (double a) { return Point(x/a, y/a); }

  double norm() { return x*x+y*y; }
  double abs() { return sqrt(norm()); }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

class Segment {
 public:
  Point p1, p2;

  Segment(Point p1 = Point(), Point p2 = Point()): p1(p1), p2(p2) {}
};

#define BOTTOM 0
#define LEFT 1
#define RIGHT 2
#define TOP 3

class EndPoint {
 public:
  Point p;
  int seg, st;
  EndPoint() {}
  EndPoint(Point p, int seg, int st): p(p), seg(seg), st(st) {}

  bool operator < (const EndPoint &ep) const {
    if (p.y == ep.p.y) {
      return st < ep.st;
    }else return p.y < ep.p.y;
  }
};

#define MAX_N 100000
#define MAX_P 1000000000
EndPoint EP[2*MAX_N];

int manhattanIntersection(vector<Segment> s) {
  int n = s.size();

  for (int i = 0, k = 0; i < n; i++) {
    if (s[i].p1.y == s[i].p2.y) {
      if (s[i].p1.x > s[i].p2.x) swap(s[i].p1, s[i].p2);
    }else if (s[i].p1.y > s[i].p2.y) {
      swap(s[i].p1, s[i].p2);
    }
    if (s[i].p1.y == s[i].p2.y) {
      EP[k++] = EndPoint(s[i].p1, i, LEFT);
      EP[k++] = EndPoint(s[i].p2, i, RIGHT);
    }else {
      EP[k++] = EndPoint(s[i].p1, i, BOTTOM);
      EP[k++] = EndPoint(s[i].p2, i, TOP);
    }
  }

  sort(EP, EP+(2*n));

  set<int> BT;
  BT.insert(MAX_P+1);
  int cnt = 0;

  for (int i = 0; i < 2*n; i++) {
    if (EP[i].st == TOP) {
      BT.erase(EP[i].p.x);
    }else if (EP[i].st == BOTTOM) {
      BT.insert(EP[i].p.x);
    }else if (EP[i].st == LEFT) {
      set<int>::iterator b = lower_bound(BT.begin(), BT.end(), s[EP[i].seg].p1.x);
      set<int>::iterator e = upper_bound(BT.begin(), BT.end(), s[EP[i].seg].p2.x);
      cnt += distance(b, e);
    }
  }

  return cnt;
}

int main() {
  int n;
  cin >> n;
  vector<Segment> p;
  for (int i = 0; i < n; i++) {
    Segment l;
    cin >> l.p1.x >> l.p1.y >> l.p2.x >> l.p2.y;
    p.push_back(l);
  }
  cout << manhattanIntersection(p) << endl;
}

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

int gcd(int a, int b){
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main() {
    int N, A[100000];
    cin >> N;

    for (int i = 0; i < N; ++i){
    	cin >> A[i];;
    }

    for (int i = 0; i < N - 1; ++i){
        A[i+1] = gcd(A[i], A[i+1]);
    }

    cout << A[N-1] << endl;
}

Measured memory_bytes: 640
#include<map>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
using namespace std;
bool pr(const pair<string,int>& p,const pair<string,int>& q){
	if(false){
	}else if(p.second>q.second){
		return true;
	}else if(p.second<q.second){
		return false;
	}else{
		return p.first<q.first;
	}
}
int main(){
	int i,j,k;
	int n;
	while(scanf("%d\n",&n),n){
		map<string,int> a[26];
		for(i=0;i<n;++i){
			char s[1026];
			fgets(s,1025,stdin);
			s[strlen(s)-1]='\0';
			for(j=0;s[j];j=k){
				for(;s[j]&&s[j]==' ';++j);
				for(k=j+1;s[k]&&s[k]!=' ';++k);
				if(k-j>0){
					char t[21];
					strncpy(t,s+j,k-j);
					t[k-j]='\0';
					++a[t[0]-'a'][t];
				}
			}
		}
		char c;
		scanf("%c",&c);
		vector<pair<string,int> > b;
		map<string,int>::iterator it;
		for(it=a[c-'a'].begin();it!=a[c-'a'].end();++it)
			b.push_back(*it);
		sort(b.begin(),b.end(),pr);
		if(b.size()){
			for(i=0;i<min(5,(int)b.size())-1;++i)
				printf("%s ",b[i].first.c_str());
			printf("%s\n",b[i].first.c_str());
		}else{
			puts("NA");
		}
	}
	return 0;
}

Measured memory_bytes: 0
<?php
[$X] = ints();
$A = 100;
for($i = 0; $i < 1000000; $i++){
    $A+=intdiv($A, 100);
    $A=floor($A);
    if($A>=$X){
        echo $i+1;
        exit;
    }
}

function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$M = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


Measured memory_bytes: 16100
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

const ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T binpow( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}


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

	int result = N;
	rep( i, N + 1 )
	{
		int cnt = 0;
		int tmp = i;
		while ( tmp > 0 ) { cnt += tmp % 6; tmp /= 6; }
		tmp = N - i;
		while ( tmp > 0 ) { cnt += tmp % 9; tmp /= 9; }
		chmin( result, cnt );
	}

	cout << result << endl;

	return ( 0 );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T> inline bool dpmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool dpmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(long long N) {
    ll n = N - 1;
    cout << n * (n+1) / 2 << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long N;
  cin >> N;
  solve(N);
  return 0;
}


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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
  int n,m,r;
  cin>>n>>m>>r;
  vector<int> q(r);
  rep(i,r){
    cin>>q[i];
    --q[i];
  }
  sort(q.begin(),q.end());
  int dist[n][n];
  rep(i,n) rep(j,n){
    if(i==j)dist[i][j]=0;
    else dist[i][j]=1000000000;
  }
  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    --a;--b;
    dist[a][b]=c;
    dist[b][a]=c;
  }
  rep(i,n) rep(j,n) rep(k,n) dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
  int ans=1000000000;
  while(true){
    int tmp=0;
    rep(i,r-1)tmp+=dist[q[i]][q[i+1]];
    ans=min(ans,tmp);
    if(!next_permutation(q.begin(),q.end())) break;
  }
  cout<<ans<<endl;
}


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

using namespace std ;

char s[300000] ;

int main()
{
    scanf("%s" , s + 1 ) ;
    int n = strlen( s + 1 ) ;
    int ans = 0 ;
    for(int i = 1 ; i <= n / 2 ; i++ ){
        ans += ( s[i] != s[n - i + 1] ) ;
    }
    cout << ans ;
}

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

int main(){
    int a,b;
    cin >> a >>b;
    if(a<6){
        b=0;
    }else if(a<=12){
        b/=2;
    }else{
        b=b;
    }
    cout << b<< endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define MAX           100004
#define pb            push_back
#define sz            size()
#define loop(i,n)     for(int i=0;i<n;i++)
#define loop1(i,n)    for(int i=1;i<=n;i++)
#define sc(n)         scanf("%d",&n)
#define sc2(n,m)      scanf("%d %d",&n,&m)
#define sc3(a,b,c)    scanf("%d %d %d",&a,&b,&c);
#define pf(n)         printf("%d",n)
#define pcase(a,b)    printf("Case %d: %d\n",a,b);
#define ll            long long
#define all(v)        v.begin(),v.end()
#define pii           pair<int,int>
#define pdd           pair<double,double>
#define vi            vector<int>
#define INF           1000000007
#define fileout       freopen("output.txt","w",stdout);
#define mem(a,n)      memset(a,n,sizeof a)
#define ff            first
#define ss            second
#define ret           return
#define mod           100000007
#define pi            acos(-1.0)
#define mp            make_pair
#define fastIO        ios_base::sync_with_stdio(false);cin.tie(NULL);


int main()
{
    int n,a[MAX];
    cin >>n;
    loop(i,n){
        cin >>a[i];
    }
    sort(a,a+n);
    cout <<a[n/2]-a[n/2-1]<<endl;
}



Measured memory_bytes: 640
#include<iostream>
using namespace std;
const int INF = 1e8;
int main() {
    int n;
    cin >> n;
    int *x = new int[n];
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        sum += x[i];
    }
    int MIN1 = 0, MIN2 = 0, MIN3 = 0;
    int p1 = sum/n, p2 = sum/n + 1, p3 = sum/n - 1;
    for (int i = 0; i < n; i++) {
        MIN1 += (x[i] - p1) * (x[i] - p1);
        MIN2 += (x[i] - p2) * (x[i] - p2);
        MIN3 += (x[i] - p3) * ( x[i] - p3);
    }
    MIN2 = min(MIN2, MIN3);
    cout << min(MIN1, MIN2);

}


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

int main()
{
  int h,w;
  while(1){
    cin>>h>>w;
    if(h==0&&w==0)break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(i==0 || j==0 || i==h-1 || j==w-1)cout<<'#';
	else cout<<'.';
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

ll ext_gcd(ll a, ll b, ll &x, ll &y){
	if(b==0){
		x = 1;
		y = 0;
		return a;
	}
	
	ll d = ext_gcd(b, a%b, y, x);
	y -= a/b * x;
	return d;
}

ll mod_inv(ll a, ll m){
	ll x,y;
	ext_gcd(a,m,x,y);
	return (m + x%m)%m;
}

int main(){
	ll n,a,b;
	cin >> n >> a >> b;
	const ll mod = 1000000007;
	
	ll N=n, x=2;
	ll ans = 1;
	while(N > 0){
		if(N & 1){
			ans *= x;
			ans %= mod;
		}
		x *= x;
		x %= mod;
		N = N >> 1;
	}
	
	ans = (ans-1+mod)%mod;
	
	ll nca=1;
	chmin(a, n-a);
	for(ll i=1; i<=a; i++){
		nca = (nca*(n-i+1))%mod;
		nca = (nca*mod_inv(i,mod))%mod;
	}
	ans = (ans-nca+mod)%mod;
	ll ncb=1;
	chmin(b, n-b);
	for(ll i=1; i<=b; i++){
		ncb = (ncb*(n-i+1))%mod;
		ncb = (ncb*mod_inv(i,mod))%mod;
	}
	ans = (ans-ncb+mod)%mod;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>
#define MAX 45

//int Fibonacci(int);
int aFibonacci(int);

int main(){
    int n;

    scanf("%d",&n);

    printf("%d\n",aFibonacci(n));

    return 0;
}

/*int Fibonacci(int n){
    if(n == 1 || n == 0)return 1;
    
    return Fibonacci(n - 1) + Fibonacci(n -2);
}*/

int aFibonacci(int x){
    int F[MAX];
    F[0] = F[1] = 1;
    for(int i = 2;i < MAX;i++){
        F[i] = F[i - 1] + F[i - 2];
    }
    return F[x];
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0;i < N;i++){
    cin >> A.at(i);
  }
  for(int i = K;i < N;i++){
    if(A.at(i - K) < A.at(i)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

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

#define ULLI unsigned long long int

int fat[1000 + 10][1000 + 10] = { 0 };  //unsigned???+??????????????\????????????
int len[1000 + 10];
int tai[1000 + 10];

int main()
{
	int n, m;

	int i, j;

	cin >> n >> m;

	for (i = 0; i < m+1; i++)
	{
		for (j = 0; j < n+1; j++)
		{
			fat[i][j]=-1;
		}
	}
	fat[0][0] = 0;

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

	for (i = 0; i < m; i++)
	{
		cin >> tai[i];
	}

	for (i = 0; i < m; i++)
	{
		for (j = 0; j < n; j++)
		{
			if (fat[i][j] > -1)
			{
				//stay
				if (fat[i + 1][j] == -1 || fat[i][j] < fat[i + 1][j])
				{
					fat[i + 1][j] = fat[i][j];
				}

				//go
				if (fat[i + 1][j + 1] == -1 || fat[i][j]+len[j]*tai[i] < fat[i + 1][j + 1])
				{
					fat[i + 1][j + 1] = fat[i][j] + len[j] * tai[i];
				}
			}
			
		}
		if (fat[i][n] > -1)
		{
			if (fat[i + 1][n] == -1 || fat[i][n] < fat[i + 1][n])
			{
				fat[i + 1][n] = fat[i][n];
			}
		}
	}

	cout << fat[m][n] << endl;

	/*
	cout << endl;
	for (i = 0; i <= m; i++)
	{
		for (j = 0; j <= n; j++)
		{
			printf("%5d ", fat[i][j]);
		}
		printf("\n");
	}
	*/

	//if (tes[1] == -1 || a < tes[1])
	return 0;
}

Measured memory_bytes: 7024
#include <stdio.h>

int ok(int y){
	if( y%4==0 ){
		if( y%400==0 ) return 1;
		if( y%100==0 ) return 0;
		return 1;
	}
	return 0;
}
int main(){
	int a,b,c,k;
	for(k=0;scanf("%d%d",&a,&b),a|b;k++){
		if( k )puts("");
		c=0;
		for(;a<=b;a++){
			if( ok(a) ){
				printf("%d\n",a);
				c=1;
			}
		}
		if( !c )puts("NA");
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = (0 until 3).map { (0 until 3).map { sc.next().toInt() } }
    println(problem088c(a))
}

fun problem088c(a: List<List<Int>>): String {
    val dp = (0 until 3).map { (0 until 3).map { 0 }.toMutableList() }
    for (i in 0 until 3) {
        for (j in 0 until 2) {
            dp[i][j] = Math.abs(a[i][j] - a[i][j + 1])
        }
    }
    return if (dp[0] == dp[1] && dp[0] == dp[1] && dp[0] == dp[2]) "Yes" else "No"
}

Measured memory_bytes: 29732
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
ans = [[-1 for _ in range(W)] for _ in range(H)]
ptr = 0

def draw_color():
    global ans, ptr
    if A[ptr] > 0: 
        A[ptr] -= 1
        return ptr + 1
    ptr += 1
    return draw_color()


# マス目の指示
for h in range(H):
    if h % 2 == 0:
        for w in range(W):
            ans[h][w] = draw_color()
    else:
        for w in reversed(range(W)):
            ans[h][w] = draw_color()

for h in range(H):
    print(*ans[h])

Measured memory_bytes: 43760
package main

import "fmt"

const mod = 1e9 + 7

const (
	FALSE = iota
	TRUE
)

func btoi(b bool) int {
	if b {
		return TRUE
	}
	return FALSE
}

func main() {
	var s string
	var d int
	fmt.Scan(&s, &d)

	n := 10000 + 5
	m := 100

	dp := make([][][]int, n)
	for i := 0; i < n; i++ {
		dp[i] = make([][]int, m)
		for j := 0; j < m; j++ {
			dp[i][j] = make([]int, 2)
		}
	}

	dp[0][0][0] = 1

	for i := 0; i < len(s); i++ {
		for j := 0; j < d; j++ {
			for k := 0; k < 10; k++ {
				sum := (dp[i+1][(j+k)%d][TRUE] + dp[i][j][TRUE]) % mod
				dp[i+1][(j+k)%d][TRUE] = sum
				if int(s[i]-'0') >= k {
					sum = (dp[i+1][(j+k)%d][btoi(int(s[i]-'0') > k)] + dp[i][j][FALSE]) % mod
					dp[i+1][(j+k)%d][btoi(int(s[i]-'0') > k)] = sum
				}
			}
		}
	}

	result := (dp[len(s)][0][TRUE] + dp[len(s)][0][FALSE]) % mod
	fmt.Println((mod + result - 1) % mod)
}

Measured memory_bytes: 45184
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()
	{
		string s = GetString();
		
		int left = 0;
		int right = s.Length - 1;
		int ans = 0;
		while(right > left)
		{
			if(s[left] == s[right])
			{
				left++;
				right--;
			}
			else if(s[left] == 'x')
			{
				left++;
				ans++;
			}
			else if(s[right] == 'x')
			{
				right--;
				ans++;
			}
			else
			{
				Console.WriteLine(-1);
				return;
			}
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

int main() {
  int n; cin >> n;
  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    mp[s]++;
  }

  int m; cin >> m;
  for (int i = 0; i < m; i++) {
    string s; cin >> s;
    mp[s]--;
  }

  int ans = 0;
  for (auto i = mp.begin(); i != mp.end(); i++) {
    ans = max(ans, mp[i->first]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <map>
using namespace std;


int main() {
    long long n;
    cin>>n;
    string s;
    cin>>s;
    map<char, long long> cnt;
    for(char c:s) {
        cnt[c] += 1;
    }
    long long ans = cnt['R'] * cnt['G'] * cnt['B'];
    for(int i=0; i<n; ++i) {
        for(int j=i+1; 2*j-i<n; j++) {
            if(s[i] != s[j] && s[i] != s[2*j-i] && s[j] != s[2*j-i]) --ans;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> x, y;

  for (int i=0;i<n;i++) {
    int xx;
    cin >> xx;
    x.push_back(xx);
  }

  y = x;
  sort(y.begin(), y.end());

  int m = y[n/2];
  for(int l=0;l<n;l++) {
    if(x[l] >=m) {
      cout << y[n/2-1] << endl;
    } else {
      cout << y[n/2] << endl;
    }
  }
  return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] int_array= new int[3];

		for (int i = 0; i < int_array.length; i++) {
			int_array[i] = sc.nextInt();
			}

		Arrays.sort(int_array);

		for (int i = 0; i < int_array.length; i++) {
			if (i == int_array.length - 1) {
				System.out.println(int_array[i]);
			} else {
				System.out.print(int_array[i] + " ");
			}
		}
	}
}



Measured memory_bytes: 26172
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
// #define endl "\n"
#define MOD 1000000007


ll recurse(ll i, ll j, vector<string>& grid, vector<vector<ll>>& dp) {
    ll h = grid.size();
    ll w = grid[0].size();

    if (i >= h || j >= w) {
        return 0;
    }

    if (i == h-1 && j == w-1) {
        return 1;
    }

    if (grid[i][j] == '#') {
        return 0;
    }

    if (dp[i][j] != -1) {
        return dp[i][j];
    }

    ll one = recurse(i+1, j, grid, dp);
    ll two = recurse(i, j+1, grid, dp);

    dp[i][j] = (one + two) % MOD;
    return dp[i][j];

}

int main(void) {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    ll h, w;
    cin >> h >> w;

    vector<string> grid (h);
    for (ll i = 0; i < h; i++) {
        cin >> grid[i];
    }
    vector<vector<ll>> dp (h, vector<ll> (w, -1));
    cout << recurse(0, 0, grid, dp);

    
    return 0;
}

Measured memory_bytes: 9216
a, b = map(int, input().split())

ans = -1
for v in range((100*10)+100):
  t8 = int(v * 0.08)
  t10 = int(v * 0.1)

  if t8 > a or t10 > b:
    break

  if t8 == a and t10 == b:
    ans = v
    break

print(ans)


Measured memory_bytes: 9104
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
      EXPLAINATION BELOW->
      Same as editorial ,main to uderstand no restriction on visiting again the visisted nodes
      Best TC
      5 4
      1 2,1 3,2 4, 2 5
      answer 1 2 3 4 5
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
   int n,i,t,flag=1;cin>>n;
   fo(i,0,n)
   {
       cin>>t;
       if(t&1)
       {}
       else
       {
           if(t%3==0||t%5==0)
           {}
           else
           flag=0;
       }
   }
   if(flag)cout<<"APPROVED";
   else cout<<"DENIED";
   cout<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define eps (1e-9)
#define equals(a,b) ((fabs((a)-(b))) < eps)
using namespace std;

struct P
{
  string name;
  int w,s,index;
  P(string name="$",int w=inf,int s=inf,int index=-inf):name(name),w(w),s(s),index(index){}
  bool operator < (const P& a)const
  {
    if(w != a.w)return w < a.w;
    if(s != a.s)return s < a.s;
    if(index != a.index)return index < a.index;
    return name < a.name;
  }
};


int main()
{
  int n;
  while(cin >> n,n)
    {
      P info[n];
      string names[n];
      double sum = 0;
      rep(i,n)
	{
	  cin >> info[i].name >> info[i].w >> info[i].s;
	  info[i].index = i;
	  names[i] = info[i].name;
	  sum += info[i].w;
	}
      sort(info,info+n);
      int ans[n],total[n];
      double G = inf;
      do
	{
	  double fac = 0;
	  bool skip = false;
	  rep(i,n)
	    {
	      fac += (i+1)*info[i].w;	  
	      total[i] = info[i].w + (i!=0?total[i-1]:0);
	    }
	  double pG = fac/sum;
	  if(equals(G,pG) || G < pG)continue;
	  
	  rep(i,n)
	    {
	      int on = (int)sum - total[i];
	      if(on > info[i].s)
		{
		  skip = true;
		  break;
		}
	    }       
	  if(skip)continue;


	  G = pG;
	  rep(i,n)ans[i] = info[i].index;

	}while(next_permutation(info,info+n));
      rep(i,n)cout << names[ans[i]] << endl;

    }
  return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(ll i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<ll,ll>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 10000000007;



int main() {

	ll n, k;
	cin >> n >> k;

	VLL a(n);
	REP(i, n)cin >> a[i];


	ll ok = 10000000000;
	ll ng = 0;

	while (ok - ng > 1) {

		ll mid = (ok + ng) / 2;
		ll cnt = 0;
		REP(i, n) {
			cnt += (a[i]-1) / mid;
		}
		if (cnt <= k)ok = mid;
		else ng = mid;
	}
	cout << ok << endl;


	return 0;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x ,int y){return (x%mod + y%mod)%mod;}
inline int submod(int x ,int y){return (x%mod - y%mod + mod)%mod;}
inline int mulmod(int x ,int y){return (x%mod *1LL* y%mod)%mod;}
inline int nextSubMask(int i , int mask) {return (i-1)&mask;} /// returns next smallest submask

void we_r_done(){cout<<"NO"; exit(0);}

void debug(bool ok , string mssg)
{
    if(ok)return;
    cout<<mssg;
    exit(0);
}


int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    int n,k;
    scn2(n,k);

    if(k==1)cout<<0;
    else cout<<n-k;

    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

/*#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif */
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int r,d,x;
    cin>>r>>d>>x;
    rep(i,0,10)
    {
        ll temp = r*x-d;
        cout<<temp<<endl;
        x = temp;
    }
    return 0;
}

Measured memory_bytes: 3656
open System

// input
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

// utils

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let flip f a b = f b a  

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Str =
  let length str = (str: string).Length
  let startsWith value str = (str: string).StartsWith(value: string)
  let toCharArray (str: string) = str.ToCharArray()
  let reverse (str: string) =
    let chars = str |> toCharArray
    Array.Reverse chars
    String.Concat chars

let S = readStr()

S
|> Str.toCharArray
|> Array.distinct
|> Array.length
|> function
| 2 -> "Yes"
| _ -> "No"
|> printfn "%s"

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

int n, a[1000005];
string s;

int f() {
	int i, j, re=0;
	for(i=0; i<n; i++) {
		j = n - 1 - i;
		if((i^j) == i+j) re += a[i];
	}
	return re%2;
}

int main() {
	int i;
	cin >> n >> s;
	for(i=0; i<n; i++) a[i] = s[i] - '1';
	if(f()) return puts("1") * 0;
	for(i=0; i<n; i++) {
		if(a[i]==1) break;
		a[i] /= 2;
	}
	if(i<n) return puts("0") * 0;
	cout << f() * 2;
	return 0;
}

Measured memory_bytes: 5252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    int in;
    int num;
    int ans=0;
    int point[105]={};
    while(1==1)
    {
        
        scanf("%d\n",&in);
        if(in==0)return 0;
        num=in;
        ans=0;
        REP(i,num)
        {
            scanf("%d\n",&point[i]);
            ans+=point[i];
        }
        sort(&point[0],&point[num]);
        ans-=(point[0]+point[num-1]);
        printf("%d\n",ans/(num-2));
    }
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int s[n],sum = 0,count = 0;
    for(int i = 0;i < n;i++)
    {
        cin >> s[i];
        sum += s[i];
        if(s[i] % 10 == 0)
        {
            count++;
        }
    }
    if(count == n)
    {
        cout << "0";
    }
    else
    {
        sort(s,s + n);
        int i = 0;
        while(sum % 10 == 0 && i < n)
        {
            if(s[i] % 10 != 0)
            {
                sum -= s[i];
            }
            i++;
        }
        cout << sum;
    }

    return 0;
}

Measured memory_bytes: 256
[n,m] = map(int, input().split())
a = [[0 for j in range(m)] for i in range(n)]
b = [0 for i in range(m)]

for i in range(n):
    v = list(map(int,input().split()))
    for j in range(m):
        a[i][j] = v[j]

for j in range(m):
    b[j] = int(input())

c = [0 for i in range(n)]

for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]

for i in range(n):
    print(c[i])

Measured memory_bytes: 8000
# coding: utf-8

# In[129]:


from collections import Counter


# In[141]:


n = int(input())
v = list(map(int, input().split()))


# In[142]:


v_even = Counter(v[::2]).most_common()
v_odd = Counter(v[1::2]).most_common()


# In[146]:


if len(v_even) == 1:
    v_even.append([0,0])
if len(v_odd) == 1:
    v_odd.append([0,0])
if v_even[0][0] == v_odd[0][0]:
    if v_even[1][1] > v_odd[1][1]:
        ret = n - v_even[1][1] - v_odd[0][1]
    else:
        ret = n - v_even[0][1] - v_odd[1][1]
else:
    ret = n - v_even[0][1] - v_odd[0][1]


# In[147]:


print(ret)



Measured memory_bytes: 20692