akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);

int main() {
  int n,k,h[110000];
  cin >> n >> k;
  for(int i = 0; i < n; i++)
    cin >> h[i];
  
  sort(h,h+n);
  int mi = 1000000000;
  for(int i = 0; i < n-k+1; i++) {
    mi = min(mi, h[k+i-1] - h[i]);
  }

  cout << mi << endl; 
}

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

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

	long long N;
	scanf("%lld", &N);

	if (N == 0)
	{
		cout << 0;
		return 0;
	}
	long long keta = 1;
	vector<long long> result = {};
	while (N != 0)
	{
		if (N % (keta * 2) != 0)
		{
			N -= keta;
			// cout << N << "\n";
			result.push_back(1);
		}
		else
		{
			result.push_back(0);
		}
		keta *= -2;
	}

	for (long long i = result.size() - 1; i >= 0; i--)
	{
		cout << result[i];
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define MOD                1000000007
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define REP(i,l,r)         for(int i=l;i<r;i++)
#define RER(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
#define test()             int x;cin >> x;while(x--)
using namespace std;
const int N = (int)1e5+5;
const int inf = (int)1e17+7;
void solve(){
	int n,m;
	cin >> n >> m;
	vi v(m);
	int s = 0;
	REP(i,0,m){
		cin >> v[i];
		s += v[i];
	}
	cout << max(-1LL,n-s) << endl;
}
int32_t main(){


	FASTIO;
	solve();
    return 0;

}

Measured memory_bytes: 3696
#include <iostream>
#include <cstdint>

int main()
{
    std::int64_t a;
    double b;
    std::cin >> a >> b;
    std::int64_t b2 = (int64_t)(b * 256.0);
    std::cout << a * b2 / 256 << std::endl;
}

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;


int main(void){
  int n,m,i,s[6],c[6];
  
  cin >> n >> m;
  for (i=0;i<m;i++) cin >> s[i] >> c[i];
  
  for (i=0;i<m;i++){
    if (s[i]!=1 || c[i]!=0) break;
  }
  if (i==m && n==1){
    cout << 0 << endl;
    return 0;
  }
  
  int t;
  for (t=1;t<1000;t++){
    int l=t;
    vector<int> y;
    while (l>0){
      y.push_back(l%10);
      l/=10;
    }
    if (y.size()!=n) continue;
    
    for (i=0;i<m;i++){
      if (y[y.size()-s[i]]!=c[i]) break;
    }
    if (i==m) break;
    
  }
  
  if (t==1000) cout << -1 << endl;
  else cout << t << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef priority_queue<double, vector<double>, less<double> > QUE_double;
typedef priority_queue<int, vector<int>, less<int> > QUE_int;//lessは大きい順にならべるよ
const int MAX = pow(10, 5)+1;//+1しないとREになる(out of rangeになるんかな?? )

ll gcd(ll a, ll b){//greatest common divider 最大公約数を求める
  if(b==0) return a;
  return gcd(b, a%b);
}

int main(){
  ll A, B;
  cin >> A >> B;
  ll lgm;//https://webkaru.net/clang/find-lcm-of-two-number/
  
  lgm = A*B/gcd(A, B);
  
  cout << lgm << endl;
}


Measured memory_bytes: 256
k, x = map(int, input().split())

start = x - k + 1
last = x + k - 1

result = []
result.append(start)

for i in range(1, last - start + 1):
    result.append(start + i)
for i in result:
    if i == start:
	    output = str(i)
    else:
        output = output + " " + str(i)

print(output)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main()
{
    int n, k;
    int hi;
    cin >> n;
    cin >> k;
    priority_queue<int> h;

    for (int i = 0; i < n; i++)
    {
        cin >> hi;
        h.push(hi);
    }

    int count = 0;
    int d = h.top();
    while (d >= k)
    {
        h.pop();
        count++;
        if (h.empty())
            break;
        d = h.top();
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 892
using System;
using System.Linq;

namespace apc001_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (x[0] % x[1] == 0) Console.WriteLine(-1);
            else
            {
                long ret = x[0];
                while (ret % x[1] == 0) ret += x[0];
                Console.WriteLine(ret);
            }
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll a,b,c;
  cin>>a>>b>>c;
  if(a%2==0||b%2==0||c%2==0)
  {
    cout<<0<<endl;
  }
  else
  {
    cout<<min({a*b,b*c,c*a})<<endl;
  }
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int main() {
	string a, b;
	cin >> a >> b;
	string s = a + b;
	int num = stoi(s);
	int i = 0;
	bool flag = false;
	while (num >= i*i) {
		if (num == i*i) {
			flag = true;
		}
		++i;
	}
	if (flag)cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for A - Iroha and Haiku (ABC Edition)
	var A, B, C int
	fmt.Scanf("%d %d %d", &A, &B, &C)

	if (A == 5 && B == 5 && C == 7) || (A == 5 && B == 7 && C == 5) || (A == 7 && B == 5 && C == 5) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1832
(defun Attention (str-list)
  (let ((saisyou 999999)
        (E-list (make-array (length str-list)))
        (index-count 0)
        (E-count 0))
    (dolist (c str-list)
      (if (char= c #\E)
          (setf (aref E-list index-count) (incf E-count))
          (setf (aref E-list index-count) E-count))
      (incf index-count))
    (setf index-count 0)
    (dolist (c str-list)
      (let ((E-num (aref E-list index-count)))
        (setf saisyou (min saisyou
                           (+
                            (- E-count E-num)
                            (- (1+ index-count) (if (char= c #\E) E-num (1+ E-num))))))
        (incf index-count)))
    (eval saisyou)))

(read-line)
(format t "~A~%" (Attention (coerce (read-line) 'list)))

Measured memory_bytes: 17128
n=int(input())
s=list(map(int,input().split()))
a=[0]
c=0
for si in s:
    c+=si
    a.append(c)
ans=[]
f=1
g=3
for i in range(2,n-1):
    while abs(a[f]-(a[i]-a[f])) > abs(a[f+1]-(a[i]-a[f+1])):
        f+=1
    while abs(a[g]-a[i]-(a[n]-a[g])) > abs(a[g+1]-a[i]-(a[n]-a[g+1])):
        g+=1
    ls=[a[f],a[i]-a[f],a[g]-a[i],a[n]-a[g]]
    ans.append(max(ls)-min(ls))
print(min(ans))


Measured memory_bytes: 28864
#include <iostream>
using namespace std;
int main(){
 char c[128];
 cin >> c;
 if(c[0] == 'T') cout << "A";
 else if(c[0] == 'A') cout << "T";
 else if(c[0] == 'G') cout << "C";
 else if(c[0] == 'C') cout << "G";
 return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var a = int.Parse(Console.ReadLine().Trim());
        var b = int.Parse(Console.ReadLine().Trim());
        var c = int.Parse(Console.ReadLine().Trim());
        var x = int.Parse(Console.ReadLine().Trim());
        var count = 0;
        for (int i = 0; i <= a; i++)
            for (int j = 0; j <= b; j++)
                for (int k = 0; k <= c; k++)
                    if (i * 500 + j * 100 + k * 50 == x) count++;
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 11092
n,m= map(int, input().split())
h =[0]+ [int(x) for x in input().split()]
miti=[]
for i in range(m):
    tmp = [int(x) for x in input().split()]
    miti.append(tmp)

good=[0]+[True]*n

for i in miti:
    if h[i[0]]<h[i[1]]:
        good[i[0]]=False
    elif h[i[1]]<h[i[0]]:
        good[i[1]]=False
    else:
        good[i[0]]=False
        good[i[1]]=False

print(good.count(True))

Measured memory_bytes: 31104
#
# File    : B.rb
# Author  : Kazune Takahashi
# Created : 12/6/2018, 11:06:29 PM
# Powered by Visual Studio Code
#

a, b, x = gets.chomp.split(" ").map{|i| i.to_i}
if a == 0
  puts b/x + 1
else
  puts (b/x + 1) - ((a - 1)/x + 1)
end


Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int main(){
    int A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;
    double min=100;
    int sugarwater;
    int sugar;
    for(int a=0;a<=30/A;a++){
        for(int b=0;b<=(30-A*a)/B;b++){
            for(int c=0;c<=3000/C;c++){
                for(double d=0;d<=(3000-C*c)/D;d++){
                    if(C*c+D*d+100*A*a+100*B*b<=F){
                        if(E*(A*a+B*b)-(C*c+D*d)>=0 and E*(A*a+B*b)-(C*c+D*d)<min*(A*a+B*b)){
                            min = E-(C*c+D*d)/(A*a+B*b);
                            sugarwater = 100*A*a+100*B*b+C*c+D*d;
                            sugar = C*c+D*d;
                        }
                    }
                }
            }
        }
    }
    cout<<sugarwater<<endl;
    cout<<sugar<<endl;
}

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

int main(){

    int w,h,n;
    cin >> w >> h >> n;

    int c[4];
    c[0]=0;
    c[1]=w;
    c[2]=0;
    c[3]=h;

    rep(i,n){
        int s,t,u;
        cin >> s >> t >> u;
        u--;
        if(u==0&&c[u]<s){
            c[u]=s;
        }else if(u==1&&c[u]>s){
            c[u]=s;
        }else if(u==2&&c[u]<t){
            c[u]=t;
        }else if(u==3&&c[u]>t){
            c[u]=t;
        }
    }

    int ans=w*h-c[0]*h-(w-c[1])*h-c[2]*w-(h-c[3])*w;
    ans+=(c[0]*c[2])+(c[0]*(h-c[3]))+((w-c[1])*c[2])+((w-c[1])*(h-c[3]));

    if(c[0]>=c[1]||c[2]>=c[3]){
        ans=0;
    }

    cout << max(ans , 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e2 + 5;
const int INF = 1e9 + 7;

int a;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	for (int i = 1; i <= 5; i++)
	{
		cin >> a;
		if (a == 0)
		{
			cout << i;
			return 0;
		}
	}
	return 0;
}
//10-09-2020 17:26:55

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n , m , d;
class matrix{ 
public:
	int mod;
	vector< vector< int>  > v;
	vector< vector<int> > ov;
	void init(int n , int m){
		v.resize(n);
		ov.resize(n);
		for(int i = 0 ; i < n ; i ++) v[i].resize(m) , ov[i].resize(m);
	}
	void get_mod(int x){
		mod = x;
	}
	void set(int x , int y , int vl){
		v[x][y] = vl;
	}
	void mult(vector< vector<int> > A , vector< vector<int> > B, vector< vector<int> > TA , vector< vector<int> > TB){
		vector< vector<int> > Mx;
		Mx.resize(A.size());
		vector< vector<int> > T;
		T.resize(A.size());
		for(int i = 0 ; i < Mx.size() ; i ++) Mx[i].resize(B[0].size() , 0) , T[i].resize(B[0].size() , 0);
		for(int i = 0 ; i < Mx.size() ; i ++ ){
			for(int j = 0 ; j < Mx[i].size() ; j ++){
				for(int k = 0 ; k < B.size() ; k ++){
					Mx[i][j] += (A[i][k] * B[k][j]);
					if(A[i][k] == 0 && B[k][j] == 0){
						if(TA[i][k] && TB[k][j]) T[i][j] = 1;
					}
					else if(A[i][k] == 0) T[i][j] = max(T[i][j] , T[i][k]);
					else if(B[k][j] == 0) T[i][j] = max(T[i][j] , T[k][j]);
					if(Mx[i][j] >= mod){
						T[i][j] = 1;
						Mx[i][j] %= mod;
					}
				}
			}
		}
		swap(Mx , v);
		swap(ov, T);
		// assumindo que Ca == Lb
	}
	vector< vector<int> > get_matrix(){
		return v;
	}
	vector< vector<int> > get_matrixT(){
		return ov;
	}
	int get(int i , int j ){
		return v[i][j];
	}
	int tvov(int i , int j){
		return ov[i][j];
	}
}; 
bool vis[101];
int c[101][101];
matrix binpow(matrix a , int k ){
	if(k == 1){
		return a;
	}
	matrix p = binpow(a , k/2);
	p.mult(p.get_matrix() , p.get_matrix() , p.get_matrixT() , p.get_matrixT());
	if(k%2) p.mult(a.get_matrix() , p.get_matrix() , a.get_matrixT() , p.get_matrixT());
	return p;
}

int32_t main(){
	int K;
	scanf("%lld%lld" , &n , &K );
	matrix dp;
	dp.init(n,n);
		dp.get_mod(1000000007);
		for(int i = 0 ; i < n; i ++){
			for(int j = 0 ; j < n; j ++){
				int x;
				scanf("%lld" , &x);
				dp.set(i,j,x);
			}
		}
			dp = binpow(dp , K);	
			int P = 0;
			for(int i = 0 ; i < n; i ++){
				for(int j = 0 ; j < n; j ++){
					P += dp.get(i,j);
					P %= 1000000007;
				}
			}
		printf("%lld\n" , P);
}

Measured memory_bytes: 3072
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<deque>
#include<string>
#include<random>
#include<stack>
#include<limits.h>
#define int long long
using namespace std;

unordered_map<int, int>U;//組み合わせiのときの最小値ｋ＋１
int b[26];
signed main() {
	U[0] = 1;
	string a; cin >> a;
	for (char c : a) {
		b[c-'a']++;
		int k = 0;
		for (int i = 0; i < 26; i++) {
			k *= 2;
			k += (b[i] & 1);
		}
		for (int i = 0; i < 26; i++) {
			int n = 0;
			for (int j = 0; j < 26; j++) {
				n *= 2;
				if(i!=j)n += (b[j] & 1);
				else n += (b[j] + 1) % 2;
			}
			if (U[n]) {
				if (U[k]) {
					U[k] = min(U[k], U[n] + 1);
				}
				else {
					U[k] = U[n] + 1;
				}
			}
		}
	}
	int k = 0;
	for (int i = 0; i < 26; i++) {
		k *= 2;
		k += (b[i] & 1);
	}
	cout << max(1ll,U[k] - 1) << endl;
}

Measured memory_bytes: 170332
#include <stdio.h>
int main(void){

int H,W;

while(1){
  scanf("%d %d",&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||i==H-1||j==0||j==W-1){
                printf("#");
            }else{
            printf(".");
        }
        }
        printf("\n");
    }
    printf("\n");
}
return 0;
}
    


Measured memory_bytes: 2024
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return len(divisors)

count = 0
for i in range(1, N + 1):
    if i % 2 == 1:
        number_divisors = make_divisors(i)
        if number_divisors == 8:
            count += 1

print(count)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007


int main()
{
	int n;
	cin >> n;
	for(int i = 1; i < 10; i++){
		if(n % i == 0 && n / i < 10){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}



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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<62)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N, T; cin >> N >> T;
  vector<int> t(N);
  rep(i, N) cin >> t[i];
  int last = 0;
  ll ans = 0;
  rep(i, N) {
    int diff = t[i] - last;
    if (diff > T)
      diff = T;
    ans += diff;
    last = t[i];
  }
  cout << ans + T << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N = 3000005;
/**********************************************************************************************/
 
vector<int> p;
void pre() {
	p.clear(); p.resize(N, -1);
	p[0] = 0; p[1] = 1;
	for (int i = 2; i < N; i++) {
		if (p[i] == -1) {
			for (int j = i; j < N; j += i) p[j] = i;
		}
	}
}
 
void solve() {
	pre();
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int g = a[0];
	for (int i = 1; i < n; i++)
		g = __gcd(g, a[i]);
	if (g != 1) {
		cout << "not coprime\n";
		return;
	}
	unordered_set<int> vis;
	int one = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == 1) one++;
		else vis.insert(p[a[i]]);
	}
	if (vis.size() + one == n) cout << "pairwise coprime\n";
	else cout << "setwise coprime\n";
}
 
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		
	}
 
	return 0;
}

Measured memory_bytes: 22048
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=1000000007;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}
vector<vec > adj(300000);
vec vis(300000,0);
vec dist(300000,0);
void dfs(ll t,ll n)
{
	vis[t]=1;
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			dist[adj[t][i]]=dist[t]+1;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
}*/
struct my_comp
{
	bool operator()(pair<ll,pll> p1, pair<ll,pll> p2)
	{
		if(p1.fi!=p2.fi)
		return p1.fi>p2.fi;
		return p1.se.fi<p2.se.fi;
	}
};
int main()
{
	char a;
	cin>>a;
	if(isupper(a))
	cout<<"A";
	else
	cout<<"a";
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
    char *ch;
    int flg = 0;

    ch = (char *)malloc(sizeof(char) * 4);

    cin >> ch;

    for (int i = 0; i < 4; i++) {
        if (i != 3) {
            if (ch[i] == ch[i+1]) {
                flg = 1;
            }
        }
    }

    if (flg == 1) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string s;
  cin  >> s;
  int n,p=0;
  n=s.length();
  n=(n-1)/2;

  for(int i=0 ;i<n ; i++){
    if(s[i]!=s[n+i+1]){
        p=1;
        break;
    }
  }
  
  if(p==1) cout<<"No";
  else cout<<"Yes";

  return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
    char suit;
    int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) {
    int i, j, k;
    int n1 = mid - left;
    int n2 = right - mid;
    for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
    for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
    L[n1].value = R[n2].value = SENTINEL;
    i = j = 0;
    for ( k = left; k < right; k++ ) {
        if ( L[i].value <= R[j].value ) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(struct Card A[], int n, int left, int right) {
    int mid;
    if ( left + 1 < right ) {
        mid = ( left + right ) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int partition(struct Card A[], int n, int p, int r) {
    int i, j;
    struct Card t, x;
    x = A[r];
    i = p - 1;
    for ( j = p; j < r; j++ ) {
        if ( A[j].value <= x.value ) {
            i++;
            t = A[i]; A[i] = A[j]; A[j] = t;
        }
    }
    t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
    return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
    int q;
    if ( p < r ) {
        q = partition(A, n, p, r);
        quickSort(A, n, p, q - 1);
        quickSort(A, n, q + 1, r);
    }
}

int main() {
    int n, i, v;
    struct Card A[MAX], B[MAX];
    char S[10];
    int stable = 1;
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ) {
        scanf("%s %d", S, &v);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }
    
    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n -1);
    
    for ( i = 0; i < n; i++ ) {
        if ( A[i].suit != B[i].suit ) stable = 0;
    }
    
    if ( stable == 1 ) printf("Stable\n");
    else printf("Not stable\n");
    for ( i = 0; i < n; i++ ) {
        printf("%c %d\n", B[i].suit, B[i].value);
    }
    
    return 0;
}


Measured memory_bytes: 5096
#include <stdio.h>
int main(void){
int i=0;
int a;
int y=0,z=0;
for(;~scanf("%d",&a);)i++?a%2?z--:(a%4?y++:z++):0;
puts((!y&&z>-2||y&&z+1)?"Yes":"No");
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x1,x2,x3,x4,x5;
	x2=0;
	for(int i=0;i<5;i++){
	scanf("%d",&x1);
	if(x1==0){
	x2=i+1;break;}
}
printf("%d\n",x2);
}

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


int main(){
	string s; cin >> s;
	int sum = 0;
	for(int i = 0; i < s.size(); i++){
		sum += s[i] - '0';
	}
	cout << ((sum % 9 == 0) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    map<string, int> wm;
    vector<string> vm(n);
    string ans = "Yes";
    for(int i=0;i<n; i++){
        cin>>vm[i];
        wm[vm[i]]++;
        if(wm[vm[i]] > 1){
            ans = "No";
        }
        if(i!=0 && vm[i-1][vm[i-1].size()-1] != vm[i][0]){
            ans = "No";
        }
    }
    cout<<ans<<endl;
}

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

int main(){
  int a,b,c,d;
  std::cin >> a >> b >> c >> d;

  int ab, bc, ac;
  ab = std::max(a-b,b-a);
  bc = std::max(b-c,c-b);
  ac = std::max(a-c,c-a);
  //std::cout << ab << bc << ac << '\n';

  if (ac <= d || (ab<=d && bc<=d)) std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int buf[5];
	int i, j, temp;

	scanf("%d %d %d %d %d", &buf[0], &buf[1], &buf[2], &buf[3], &buf[4]);
	for (i = 0; i < 4; i++) {
		for (j = 4; j > i; j--) {
			if (buf[j - 1] < buf[j]) {
				temp = buf[j];
				buf[j] = buf[j - 1];
				buf[j - 1] = temp;
			}
		}
	}
	printf("%d %d %d %d %d\n", buf[0], buf[1], buf[2], buf[3], buf[4]);
	return 0;
}

Measured memory_bytes: 596
// ~maqsat~

// #pragma GCC target ("avx2")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)
#define ever ;;

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 123;
const ll MOD = 1e9 + 7;
const ll INF = 1e15 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
#ifdef ZVER
	cerr << "Ready\n";
#endif
	fre("");
	ACCELERATE;
	
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	
	if (u == s) cout << a - 1 << " " << b;
	else cout << a << ' ' << b - 1;
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

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

    vector<int> x(100010,0);

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

    for(int i = 0; i<m;i++){
        x[start[i]]++;
        x[end[i]+1]--;
    }

    for(int i = 1;i < 100010 ;i++){
        x[i] += x[i-1];
    }

    int ans=0;
    for(int i=0;i<100010;i++){
        if(x[i]==m)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int n,h[25],ans = 1;
int main(){
	cin >> n;
	for(int i = 1;i <= n;i++)
		cin >> h[i];
	for(int i = 2;i <= n;i++){
		int yes = true;
		for(int j = 1;j < i;j++)
			if (h[j] > h[i]){
				yes = false;
				break;
			}
		if(yes)
			ans++;
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
N = int(input())
string = [0 for i in range(N)]
calc_str = lambda :"".join(list(chr(i+ord('a')) for i in string))
chr_a = ord('a')
print(calc_str())
now = N-2


while N > 1:
    if string[now+1]-max(string[:now+1]) > 0:
        if now == 0: break
        string[now+1] = 0
        now -= 1
        
    else:
        string[now+1] += 1
        now = N-2

        print(calc_str())

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define int long long
#include "string"

int32_t main(){
	boost;
	int n,k;
	cin>>n>>k;
	vector<int>a(n);
	int sum = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum += a[i];
	}

	auto okk = [&](int m){
		vector<int>b = a;
		int rem = k;
		for(int i=0;i<n;i++)
			b[i] %= m;
		sort(b.begin(),b.end());
		int l = 0,r = n-1;
		while(l<=r && rem > 0){
			int tt = min(b[l],m - b[r]);
			tt = min(tt,rem);
			b[l] -= tt;
			b[r]  = (b[r] + tt) % m;
			rem -= tt;
			if(b[l] == 0)
				l++;
			if(b[r] == 0)
				r--;
		}
		sort(b.begin(),b.end());
		return (b.back() == 0);
	};

	int ans = 0;
	for(int i=1;i*i <= sum;i++){
		if(sum % i == 0) {
			if(okk(i))
				ans = max(ans,i);
			if(okk(sum/i))
				ans = max(ans,sum/i);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3668
cards = list(range(1, 53))
n = int(input())

for i in range(n):
  mark, num = input().split()
  if mark == 'H':
    cards.remove(int(num) + 13)
  elif mark == 'C':
    cards.remove(int(num) + 26)
  elif mark == 'D':
    cards.remove(int(num) + 39)
  else:
    cards.remove(int(num))

for card in cards:
  if card > 39:
    mark = 'D'
    card -= 39
  elif card > 26:
    mark = 'C'
    card -= 26
  elif card > 13:
    mark = 'H'
    card -= 13
  else:
    mark = 'S'
  print(mark, str(card))



Measured memory_bytes: 5600
#include<cstdio>
using namespace std;
int m,n;
int main()
{
	scanf("%d%d",&m,&n);
	if(m==n)
	{
		printf("Draw");
		return 0;
	}
	if(m==1&&n==13)
	{
		printf("Alice");
		return 0;
	}
	if(m==13&&n==1)
	{
		printf("Bob");
		return 0;
	}
	if(m>n) 
	  printf("Alice");
	if(n>m)
	  printf("Bob");
	return 0;
}

Measured memory_bytes: 128
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var M = parseInt(input[0].split(" ")[1]);
  var C = parseInt(input[0].split(" ")[2]);
  var B = input[1].split(" ").map(x => ~~x);
  var A = [];
  for(var i=0; i < N; i++){ A[i] = input[i+2].split(" ").map(x => ~~x);}

  var AtCoder = function(){};

  AtCoder.prototype = {
    procedure: function(){
      var numCorrect=0;
      for(var j=0;j<N;j++){
        var sum=0;
        sum = sum+C;
        for(var i=0; i<M;i++){
          debugger;
          sum = sum+A[j][i]*B[i];
        }
        if(sum > 0) numCorrect++;
      }
      return numCorrect;
    }
  }
  var atcoder = new AtCoder();
  console.log(atcoder.procedure());
}

var input=Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// var input=`5 2 -4
// -2 5
// 100 41
// 100 40
// -3 0
// -6 -2
// 18 -13`
// Main(input);


Measured memory_bytes: 7372
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

// ll fc(int n) {
//   if(n == 1) return 1;
//   return n * fc(n-1);
// }
// int main() {
//   int n; cin >>n;
//   ll fd = fc(n);
//   // cout << "fd os " << fd << endl;
//   int sv[fd+1]; int ans = 0;
//   for(ll i = 1; i<=fd; i++) {
//     if(sv[i] == 1 || fd % i != 0) continue;
    
//     sv[i] = 1;
//     sv[fd/i] = 1;
//     ll rv = ans + 2;
//     ans =  rv % (ll) (10e9 + 7); 
//     // cout << "ans increment" << ans << endl;
//   }
//   cout << ans << endl;
//   return 0;
// }

	int main() {
		int n, a, b;
		cin >> n >> a >> b;
		int x[n];
		forn(i,n) cin >> x[i];
        ll ans = 0;
        REP(i,0, n-2) {
         ans +=  min((ll) (x[i+1] - x[i]) * a, (ll) b);
        }
        cout << ans <<endl;
		return 0;
	}


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

bool isprime(int x)
{
  if(x == 2) return true;

  if(x < 2 || x % 2 == 0) return false;

  for(int i=3;i*i <= x;i+=2)
    {
      if(x % i == 0)return false;
    }
  return true;
}
int main(){
  int n,x;
  int cnt=0;

  cin >> n;
  
  for(int i=0;i < n;i++)
    {
      cin >> x;
      if( isprime(x) ) cnt++;
    }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3088
def CountTriangles( A): 
  
    n = len(A); 
  
    A.sort();  
  
    count = 0; 
      
    for i in range(n - 1, 0, -1): 
        l = 0; 
        r = i - 1; 
        while(l < r): 
            if(A[l] + A[r] > A[i]): 
  
                # If it is possible with a[l], a[r] 
                # and a[i] then it is also possible 
                # with a[l+1]..a[r-1],a[r] and a[i] 
                count += r - l;  
  
                # checking for more possible solutions 
                r -= 1;  
              
            else: 
  
                # if not possible check for  
                # higher values of arr[l] 
                l += 1;  
    print(count); 
  
# Driver Code
n = int(input())
A = [int(x) for x in input().split()]
CountTriangles(A); 

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int A,N;
  cin>>N>>A;
  for(int i=0;i<=A;i++){
    for(int j=0;j<=20;j++){
      if(N==i+500*j){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val x = sc.nextLong()
  val y = sc.nextLong()

  // val tmpa = (x..y).map { it }

  var pre = x
  var count = 0L
  while (pre <= y) {
    count++
    pre *= 2
  }

  println(count)
}


Measured memory_bytes: 31264
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const tmp = readln.split.to!(long[]);
    auto D = tmp[0], N = tmp[1];
    auto res = 100^^D;
    if (N < 100) res *= N;
    else res *= N+1;
    writeln(res);
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;

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

    int n,m; cin >> n >> m;

    std::vector<std::vector<bool>> bulbs = std::vector<std::vector<bool>>(m, std::vector<bool>(n,false));

    rep(i,m){
        int k; cin >> k;

        rep(j,k){
            int s; cin >> s; s--;
            bulbs[i][s] = true;
        }
    }

    std::vector<int> p(m); rep(i,m) cin >> p[i];

    int ans = 0;


    for(int bit = 0; bit < (1<<n); bit++){
        
        std::vector<int> s;

        for(int i=0; i<n; i++){
            if(bit & (1<<i)){
                s.push_back(i);
            }
        }

        bool good = true;

        rep(i,m){

            vector<bool> available_swtiches = bulbs[i];

            int cnt = 0;

            rep(j,s.size()){
                int swtich_on = s[j];
                if(available_swtiches[swtich_on]) cnt++;
            }

            if(cnt%2!=p[i]) good = false;

        }

        if(good) ans++;

    }

    cout << ans << endl;
    
    

    return 0;
}

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

int main(){
 	int a,b,c;
  	cin>>a>>b>>c;
  
  	int arr[11];
  	memset(arr,0,sizeof(arr));
  
  	arr[a]++;
  	arr[b]++;
  	arr[c]++;
  
  	if(arr[5]==2 && arr[7] == 1)
      cout<<"YES"<<endl;
  	else
      cout<<"NO"<<endl;
  
  return 0;
}

Measured memory_bytes: 256
//#include "stdafx.h"
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>
#include "random"
#include "chrono"
#include "cstring"

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target_ans("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++)
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
//#define endl '\n'

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;

#define int long long
//#define int unsigned int
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;
typedef vector<vi> vvi;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

vi xx = { 1, 0, -1, 0 };
vi yy = { 0, 1, 0, -1 };
string dir = "LRUD";

const int N = 2e5 + 50, oo = 3e18 + 500;
//const int mod = 998244353;
const int mod = 1e9 + 7;
//const int mod = 1e9 + 9;
const double eps = 1e-12, PI = 2 * acos(0.0);
int n, m, k;
long long cnt = 0;
int lg = 18;
set<int> g[N];
vi rg[N];
vi visit(N, 0);

void dfs(vi &pr, int v, int p = -1)
{
	pr[v] = p;
	for (auto to : g[v])
	{
		if (to == p)continue;
		dfs(pr, to, v);
	}
}

signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("abbreviation.in", "r", stdin);
	freopen("abbreviation.out", "w", stdout);*/

	cin >> n >> k;

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

	sort(all(p));

	for (int i = 0; i < k; i++)
	{
		cnt += p[i];
	}

	cout << cnt;
}



Measured memory_bytes: 13428
#include <bits/stdc++.h>
using namespace std;
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;
}

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

ll N, A, B, C, D;
map<ll, ll> memo;

ll dfs(ll n) {
    if(n == 0) {
        return 0;
    }
    if(n == 1) {
        return D;
    }
    if(memo.count(n)) {
        return memo[n];
    }
    ll res = LLINF;
    if(n < res / D) {
        res = n * D;
    }

    ll l, r;
    l = (n / 2) * 2;
    r = ((n + 2 - 1) / 2) * 2;
    chmin(res, llabs(l - n) * D + A + dfs(l / 2));
    chmin(res, llabs(r - n) * D + A + dfs(r / 2));
    l = (n / 3) * 3;
    r = ((n + 3 - 1) / 3) * 3;
    chmin(res, llabs(l - n) * D + B + dfs(l / 3));
    chmin(res, llabs(r - n) * D + B + dfs(r / 3));
    l = (n / 5) * 5;
    r = ((n + 5 - 1) / 5) * 5;
    chmin(res, llabs(l - n) * D + C + dfs(l / 5));
    chmin(res, llabs(r - n) * D + C + dfs(r / 5));

    return (memo[n] = res);
}

void solve() {
    cin >> N >> A >> B >> C >> D;
    memo.clear();
    cout << dfs(N) << "\n";
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
}

Measured memory_bytes: 4388
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//FUNCTION

void solve(void)
{
  int N; cin>>N;
  multiset<int,greater<int>> SET;
  for (int i = 0; i < N; i++)
  {
    int A;
    cin>>A;
    auto itr = SET.upper_bound(A);
    
    if(itr == SET.end())
    {
      SET.insert(A);
    }
    else
    {
      SET.erase(itr);
      SET.insert(A);
    }


  }

  cout<<SET.size()<<endl;
  return;
}

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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 6528
/*C - Alchemist*/
#include <bits/stdc++.h>

using namespace std;

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

	int tam;
	cin >> tam;

	vector <double> arr(tam);
	double ans = 0.0;

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

	sort(arr.begin(), arr.end());

	ans = (arr[0] + arr[1]) / 2.0; 

	for (int i = 2; i < tam; ++i)
		ans = (arr[i] + ans) / 2.0;

	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    sum=accumulate(all(v),0);
    rep(i,n){
        sum-=v[i];
        f+=v[i];
        mini=min(mini,abs(sum-f));
    }
    cout<<mini<<endl;
    return 0;
}


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

int main (){
  long long n;
  int m;
  while(cin>>n>>m && (n||m)){
    int f=0;
    long long b;
    for(int i=0;i<m;i++){
      cin >> b;
      if(b==1) f=1;
    }
    if(f==1) printf("%.10f\n", (double)0 );
    else printf("%.10f\n", (double)n/2 );

  }
  return 0;
}

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

int main() {
  int A, B, C, D = 0;
  cin >> A >> B >> C >> D;
  while (A > 0 || C > 0){
    C = C - B;
    if (C <= 0){
      cout << "Yes" << endl;
      break;
    }
    A = A - D;
    if (A <= 0){
      cout << "No" << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	string S;
	cin >> S;
	if(S=="ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}


Measured memory_bytes: 3592
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_2-C: Stable Sort

#include <cstring>
#include <algorithm>
#include <iostream>

struct Card {
  char suit;
  unsigned int rank;
  bool operator<(const Card& rhs) { return rank < rhs.rank; }
  bool same(const Card& rhs) { return rank == rhs.rank && suit == rhs.suit; }
};

std::ostream& operator<<(std::ostream& os, const Card& card)
{
  return os << card.suit << card.rank;
}

std::istream& operator>>(std::istream& is, Card& card)
{
  return is >> card.suit >> card.rank;
}

static void print_cards(const Card cards[], const unsigned int n)
{
  const char* sep = "";
  for (auto i = 0u; i < n; ++i) {
    std::cout << sep << cards[i];
    sep = " ";
  }
  std::cout << std::endl;
}

static void bubble_sort(Card cards[], const unsigned int n)
{
  for (auto j = 0u; j < n-1; ++j) {
    for (auto i = n-1; i > j; --i) {
      if (cards[i] < cards[i-1]) {
        std::swap(cards[i], cards[i-1]);
      }
    }
  }
}

static void selection_sort(Card cards[], const unsigned int n)
{
  for (auto i = 0u; i < n-1; ++i) {
    auto min_j = i;
    for (auto j = i+1; j < n; ++j) {
      if (cards[j] < cards[min_j]) {
        min_j = j;
      }
    }
    if (i != min_j) {
      std::swap(cards[i], cards[min_j]);
    }
  }
}

int main()
{
  unsigned int n;
  std::cin >> n;
  Card cards1[n], cards2[n];
  for (auto i = 0u; i < n; ++i) {
    std::cin >> cards1[i];
  }
  std::memcpy(cards2, cards1, sizeof(cards1));
  /*
  for (auto i = 0u; i < n; ++i) {
    cards2[i] = cards1[i];
  }
  */
  bubble_sort(cards1, n);
  print_cards(cards1, n);
  std::cout << "Stable" << std::endl; // bubble sort is stable

  selection_sort(cards2, n);
  print_cards(cards2, n);
  /*
  if (std::memcmp(cards1, cards2, sizeof(cards1)) == 0) {
    std::cout << "Stable" << std::endl;
  } else {
    std::cout << "Not stable" << std::endl;
  }
  */
  for (auto i = 0u; i < n; ++i) {
    /*
    if (!(cards2[i].rank == cards1[i].rank &&
          cards2[i].suit == cards1[i].suit)) {
    */
    if (!cards2[i].same(cards1[i])) {
      std::cout << "Not stable" << std::endl;
      return 0;
    }
  }
  std::cout << "Stable" << std::endl;
}

// eof

Measured memory_bytes: 3152