akhauriyash/Code-Regression huggingface dataset:
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 998244353;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  string s; cin >> s;
  int ans = 0;
  REP(i, 6){
    if(s[i] == '1') ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)














int main(){
    ll r;
    cin >> r;
    cout << 3 * r * r << endl;
}


Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <cassert>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int X, Y;

  cin >> X >> Y;

  bool ans = false;

  rep(i, X + 1) {
    int num = i * 2 + (X - i) * 4;
    if (num == Y) {
      ans = true;
      break;
    }
  }
  if (ans == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;
int v[100001],f[100001];
int main()
{
    int n,i,a,b;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
        scanf("%d",&v[i]);
    a=INT_MAX;
    b=INT_MIN;
    for(i=1; i<=n; i++)
    {
        a=min(a,v[i]);
        b=max(b,v[i]);
    }
    if(b-a<=1)
    {
        printf("Yes");
        return 0;
    }
    for(i=1; i<=n; i++)
        if(v[i]==b)
        {
            f[i]=1;
            v[i]--;
        }
    b--;
    for(i=1; i<n; i++)
        if(f[i]==0)
            if(v[i]>v[i+1])
                if(v[i]==v[i+1]+1)
                    v[i]--,f[i]=1;
                else
                {
                    printf("No");
                    return 0;
                }
    for(i=1; i<n; i++)
        if(v[i]>v[i+1])
        {
            printf("No");
            return 0;
        }
    printf("Yes");

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n, minNum = 10000000000000000, minI = 0;
    vi a(5);
    cin >> n;
    for(int i=0; i<5; i++){
        cin >> a.at(i);
        if(minNum>a.at(i)){
            minNum = a.at(i);
            minI = i;
        }
    }
    int64_t time = n%minNum==0?n/minNum:n/minNum+1;
    cout << 4 + time << endl;
}


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

#define NIL NULL

struct node {
  int key;
  struct node *left;
  struct node *right;
  struct node *point;
};
struct node *root;

void inorder(struct node *);
void preorder(struct node *);
void insert(int);
struct node *find(int);

int main()
{
  int i, x, n, key;
  char s[10];

  scanf("%d", &n);
  for(i=0; i<n; i++) {
    scanf("%s", s);
    if(strcmp("insert", s) == 0) {
      scanf("%d", &x);
      insert(x);
    }
    else if(strcmp("print", s) == 0) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp("find", s) == 0) {
      scanf("%d", &key);
      if(find(key) != NIL)
	printf("yes\n");
      else
	printf("no\n");
    }
  }
  return 0;
}

void inorder(struct node *T)
{
  if(T != NIL) {
    if(T->left != NIL)
      inorder(T->left);
    printf(" %d", T->key);
    if(T->right != NIL)
      inorder(T->right);
  }
}

void preorder(struct node *T)
{
  printf(" %d", T->key);
  if(T != NIL) {
    if(T->left != NIL)
      preorder(T->left);
    if(T->right != NIL)
      preorder(T->right);
  }
}

void insert(int key)
{
  struct node *y = NIL;
  struct node *x = root;
  struct node *z;

  z = (struct node *)malloc(sizeof(struct node));
  z->key = key;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL) {
    y = x;
    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->point = y;
  if(y == NIL)
    root = z;
  else if(z->key < y->key)
    y->left = z;
  else
    y->right = z;
}

struct node *find(int key)
{
  struct node *x = root;
  while(x != NIL && key != x->key) {
    if(key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  return x;
}

Measured memory_bytes: 19364
from collections import defaultdict

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1

N = int(input())
xd = defaultdict(lambda: [])
yd = defaultdict(lambda: [])
for i in range(N):
    x,y = map(int,input().split())
    xd[x].append(i)
    yd[y].append(i)

uf = UnionFind(N)
es = []
pre_x = pre_i = None
for x,idxs in sorted(xd.items()):
    if len(idxs) >= 2:
        for i1,i2 in zip(idxs,idxs[1:]):
            if uf.is_same(i1,i2): continue
            uf.unite(i1,i2)
    if pre_x is not None:
        dx = x - pre_x
        es.append((dx,pre_i,idxs[0]))
    pre_x = x
    pre_i = idxs[0]
pre_y = pre_i = None
for y,idxs in sorted(yd.items()):
    if len(idxs) >= 2:
        for i1,i2 in zip(idxs,idxs[1:]):
            if uf.is_same(i1,i2): continue
            uf.unite(i1,i2)
    if pre_y is not None:
        dy = y - pre_y
        es.append((dy,pre_i,idxs[0]))
    pre_y = y
    pre_i = idxs[0]

if uf.count == N-1:
    print(0)
    exit()
ans = 0
for cost,a,b in sorted(es):
    if uf.is_same(a,b): continue
    uf.unite(a,b)
    ans += cost
    if uf.count == N-1:
        break
print(ans)

Measured memory_bytes: 84244
#include <iostream>
#include <string>

using namespace std;
struct P
{
	int x, y;
	int direction;		//0:North 1:East 2:South 3:West
};

void solve()
{
	int W, H;
	while(cin >> W >> H, W || H)
	{
		P p;
		p.x = 0;
		p.y = 0;
		p.direction = 0;
		string str;
		while(cin >> str)
		{
			if(str == "STOP")
			{
				cout << p.x + 1 << " " << p.y + 1 << endl;
				break;
			}
			else if(str == "FORWARD" || str == "BACKWARD")
			{
				int move;
				cin >> move;
				if(str == "FORWARD" && p.direction == 0 || str == "BACKWARD" && p.direction == 2)
				{
					p.y += move;
					if(p.y >= H)
					{
						p.y = H - 1;
					}
				}
				else if(str == "FORWARD" && p.direction == 2 || str == "BACKWARD" && p.direction == 0)
				{
					p.y-= move;
					if(p.y < 0)
					{
						p.y = 0;
					}
				}
				else if(str == "FORWARD" && p.direction == 1 || str == "BACKWARD" && p.direction == 3)
				{
					p.x += move;
					if(p.x >= W)
					{
						p.x = W - 1;
					}
				}
				else if(str == "FORWARD" && p.direction == 3 || str == "BACKWARD" && p.direction == 1)
				{
					p.x -= move;
					if(p.x < 0)
					{
						p.x = 0;
					}
				}	
			}
			else
			{
				if(str == "RIGHT")
				{
					p.direction = (p.direction + 1) % 4;		//cw
				}
				else if(str == "LEFT")
				{
					p.direction = (p.direction + 3) % 4;		//ccw
				}
			}
		}
	}
}

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

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

int main(){
    long long a,b,c,k;
    cin >> a >> b >> c >> k;
    long long ans;
    if(k<=a) ans=k;
    else if(k>a&&k<=a+b) ans=a;
    else ans=a-(k-a-b);
    cout << ans << endl;
}

Measured memory_bytes: 3624
import os
N, P = map(int, input().split())

def trial_division(n):
    if n < 2:
        return []
    prime_factors = []
    for p in range(2, int( n**0.5)):
        if p*p > n: break
        cnt = 0
        while n % p == 0:
            cnt += 1
            n //= p
        prime_factors.append([p, cnt])
    if n > 1:
        prime_factors.append([n, 1])
    return prime_factors

prime_factors = trial_division(P)
ans = 1
for p in prime_factors:
    if p[1] >= N:
        ans *= p[0]**(p[1] // N)
print(ans)

Measured memory_bytes: 58768
#include <bits/stdc++.h>
using namespace std;
int x[150];
int main()
{

   int r,c;
   cin>>r>>c;
   string s[r];
   for(int i=0;i<r;i++)cin>>s[i];
   for(int i=0;i<c+2;i++)cout<<"#";
   cout<<endl;
   for(int i=0;i<r;i++)
   {
       cout<<"#"<<s[i]<<"#"<<endl;
   }
    for(int i=0;i<c+2;i++)cout<<"#";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
def int
  gets.to_i
end

def ints
  gets.split.map(&:to_i)
end

a = int
b = int
c = int
d = int
e = int
k = int

pos = [a, b, e, d, e].sort

puts (pos.last - pos.first) <= k ? 'Yay!' : ':('


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

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> X(M);
    for (int i = 0; i < M; i++) {
        cin >> X[i];
    }

    if (N >= M) cout << 0 << endl;
    else {
        sort(X.begin(), X.end());

        vector<ll> dist(M-1);
        for (int i = 0; i < M-1; i++) {
            dist[i] = X[i+1]-X[i];
        }

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

        ll sum = 0;
        for (int i = 0; i < M-N; i++) {
            sum += dist[i];
        }

        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1792
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int t=-1;
  reps(i,1,11){
    cout<<"? 1"<<string(i-1,'0')<<endl;
    string s;
    cin>>s;
    if(s=="N"){
      t=i-1;
      break;
    }
  }
  if(t==-1){
    reps(i,1,11){
      cout<<"? "<<string(i,'9')<<endl;
      string s;
      cin>>s;
      if(s=="Y"){
	cout<<"! 1"<<string(i-1,'0')<<endl;
	return 0;
      }
    }
    cout<<"! 1"<<endl;
    return 0;
  }
  //out(t,1);
  ll l=1;
  rep(i,t-1) l*=10;
  ll r=l*10;
  while(r-l>1){
    ll m=(l+r)/2;
    cout<<"? "<<m*10<<endl;
    string s;
    cin>>s;
    (s=="N"?l:r)=m;
  }
  cout<<"! "<<r<<Endl;
  return 0;
}


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

#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int N;
    cin>>N;
    if(N==25) cout<<"Christmas"<<endl;
    else if(N==24) cout<<"Christmas Eve"<<endl;
    else if(N==23) cout<<"Christmas Eve Eve"<<endl;
    else if(N==22) cout<<"Christmas Eve Eve Eve"<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1000000000;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
     int n;
     cin >> n;
     for(int i = 1; i <= 3500; i++){
		for(int j = 1; j <= 3500; j++){
			int num = 4 * i * j - ( i + j) * n;
			int den = n * i * j;
			if (num <= 0) continue;
			if (den % num == 0){
			  int val = den / num;
			  cout << i << " " << j << " " << val << endl;	
			  exit(0);
		   }
		} 
	}
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	
	vector<int>a;
	int n;
	cin >> n;

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

		int t;
		cin >> t;
		a.push_back(t);

	}
	int r = 0;
	for (int i = 1; i < n - 1; i++) {
		
		vector<int>y;
		y.push_back(a[i]);
		y.push_back(a[i - 1]);
		y.push_back(a[i + 1]);
		sort(y.begin(), y.end());
		if (y[1] == a[i])r++;

	}
	cout << r << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<double, double> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

void strmax(string &x, string y) {
    if(x=="INF") x=y;
    else if(x.size() < y.size()) x=y;
    else if(x.size()==y.size() && x<y) x=y;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d[] = {2,5,5,4,5,6,3,7,6};
    int n,m; cin >> n >> m;
    vector<int> a(m);
    REP(i,m) {
        cin >> a[i];
    }
    vector<string> dp(n+10, "INF");
    dp[0] = "";
    REP(i,n) {
        if(dp[i]=="INF") continue;
        REP(j,m) {
            strmax(dp[i+d[a[j]-1]], dp[i] + (char)('0'+a[j]));
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 43776
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long K){
  priority_queue<pair<ll, ll>> q;

  for(ll i=1; i<10; i++)
    q.push(make_pair(i*(-1), i));

  ll cnt = 0;
  
  while(cnt+1 < K) {
    pair<ll, ll> x = q.top();
    q.pop();
    cnt++;
    x.first = x.first*(-1);
    q.push(make_pair((x.first*10+x.second)*(-1), x.second));
    if(x.second == 0) {
      q.push(make_pair((x.first*10+x.second+1)*(-1), x.second+1));
    } else if(x.second == 9) {
      q.push(make_pair((x.first*10+(x.second-1))*(-1), x.second-1));
    } else {
      q.push(make_pair((x.first*10+x.second+1)*(-1), x.second+1));      
      q.push(make_pair((x.first*10+(x.second-1))*(-1), x.second-1));
    }
  }
  std::cout << q.top().first*(-1) << std::endl;
}

int main(){
  long long K;
  scanf("%lld",&K);
  solve(K);
  return 0;
}



Measured memory_bytes: 6512
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

bool f(int a, int b, vector<int> v) {
  bool ta = false;
  bool tb = false;
  for(auto p : v) {
    if(a == p) {
      ta = true;
    }
    if(b == p) {
      tb = true;
    }
  }
  if(ta && tb) {
    return true;
  }
  else {
    return false;
  }
}

int main() {
  int a, b;
  cin >> a >> b;
  vector<int> ga(7);
  ga = {1, 3, 5, 7, 8, 10, 12};
  vector<int> gb(4);
  gb = {4, 6, 9, 11};
  vector<int> gc(1);
  gc = {2};

  if(f(a, b, ga) || f(a, b, gb) || f(a, b, gc)) {
    cout << "Yes" << endl;
  } 
  else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
    public static void main(String Args[])
    {
        Scanner sc=new Scanner(System.in);
        int k=sc.nextInt();
        int a=sc.nextInt();
        int b=sc.nextInt();
        int n=a%k;
        int num=k-n;
        if(a+num<=b||n==0)
        System.out.println("OK");
        else
        System.out.println("NG");
    }
    
}


Measured memory_bytes: 35756
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    long long x;
    cin >> x;

    vector<long long> dp(n + 2, 0);
    dp[0] = 1;
    vector<long long> dp2(n + 2, 0);
    dp2[0] = 1;
    for (int i = 1; i <= n; ++i) {
        // assert(dp[i] < LLONG_MAX);
        dp[i] = dp[i - 1] * 2 + 3;
        dp2[i] = dp2[i - 1] * 2 + 1;
        // cout << i << " " << dp2[i] << endl;
    }
    // cout << dp[n] << endl;

    long long res = 0;

    for (int i = n; i > 1 && x > 0; --i) {
        if (dp[i - 1] + 1 + 1 <= x) {
            res += dp2[i - 1] + 1;
            x = max(0LL, x - dp[i - 1] - 1 - 1);
        } else {
            --x;
        }
    }
    if (x > 0) {
        --x;
        res += min(3LL, x);
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[5],b[5];
int deg[5];
int main(){
    ios::sync_with_stdio(false);
    for(int i=1;i<=3;i++){
        cin>>a[i]>>b[i];
        deg[a[i]]++;
        deg[b[i]]++;
    }
    int odd=0,even=0;
    for(int i=1;i<=4;i++){
        if(deg[i]&1){
            odd++;
        } else
            even++;
    }
    if(odd==2&&even==2){
        cout<<"YES";
    } else{
        cout<<"NO";
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
     
int main() {
  std::string s;
  cin >> s;
  
  int size = s.length();
        
  char cary[size]; 
  s.copy(cary, size);
      
  int cnt1 = 0;
  int cnt2 = 0;
  for(int i=0;i<size;i++){
    if(i%2==0){
      if(cary[i]!='0'){
        cnt1+=1;
      }else{
        cnt2+=1;
      }
    } else {
      if(cary[i]!='1'){
        cnt1+=1;
      }else{
        cnt2+=1;
      }
    }
  }
  
  if(cnt1<=cnt2){
    cout << cnt1 << endl;
  }else{
    cout << cnt2 << endl;
  }

  return 0;
}

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

int main() {
  
  vector<char> s(3);
  for (int i=0; i<3; i++) cin >> s.at(i);
  
  vector<char> t(3);
  for (int j=0; j<3; j++) cin >> t.at(j);
  
  int count=0;
  for (int i=0; i<3; i++) {
    if (s.at(i)==t.at(i)) count++;
  }
  
  cout << count << endl;
}

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

using namespace std;

int main()
{
    string str,com;
    cin >> str;

    int q,num1,num2;
    cin >> q;

    for(int i=0;i<q;i++){
        cin >> com >> num1 >> num2;
        if(com=="print"){
            for(int j=num1;j<=num2;j++){
            cout << str[j];
            }
            cout << endl;
        }
        else if(com=="reverse"){
            for(int j=num1;j<num1+(num2-num1+1)/2;j++){
                char c=str[num1+num2-j];
                str[num1+num2-j]=str[j];
                str[j]=c;
                
            }
        }
        else if(com=="replace"){
            string s;
            cin >> s;
            str.replace(num1,num2-num1+1,s);
        }
    }
    
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int main() {
  //std::cout << std::fixed << std::setprecision(20);
  int64_t A;
  string B;
  cin >> A;
  cin >> B;
  
  int x = 0;
  int y = 0;
  int j = 0;
  for(int i = B.size() - 4; i > -1; i--){
    x += (B[i] - '0') * pow(10,j);
    j++;
  }
  y = (B[B.size() - 2] - '0' ) * 10 + (B[B.size()-1] - '0');







  int64_t ans = A * x;
  int64_t t = (int64_t)((A * y)/100);
  ans += t;

  cout << ans << endl;
}

Measured memory_bytes: 3852
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N, K := getInt(), getInt()
	s := getString()
	cur := s[0]
	cnt := 0
	rev := false // 反転させたフラグ（次に列が異なるまで反転させているとみなす）
	for i := 1; i < N; i++ {
		// out(cnt, K, string(s[i]), string(cur))
		if s[i] != cur && rev == true {
			rev = false
			cur = s[i]
		}
		if s[i] == cur {
			cnt++
			continue
		}
		if K > 0 {
			cnt++
			cur = s[i]
			rev = true
			K--
		} else {
			cur = s[i]
		}
	}
	out(cnt)
}


Measured memory_bytes: 2104
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,m;
vector<int> G[MAXN];
bool vis[MAXN];
deque<int> ans;
void dfs(int v)
{
    vis[v]=true; ans.push_back(v);
    for(auto to:G[v])
    {
        if(vis[to]) continue;
        dfs(to); break;
    }
}
void extend(int v)
{
    for(auto to:G[v])
    {
        if(!vis[to])
        {
            ans.push_front(to);vis[to]=true;
            extend(to);break;
        }
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);G[v].push_back(u);
    }
    memset(vis,false,sizeof(vis));
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            ans.clear();
            dfs(i);
            if(ans.size()>1)
            {
                extend(i);
                printf("%d\n",(int)ans.size());
                for(auto v:ans) printf("%d ",v);
                return 0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 6784
import java.util.Scanner;

public class Main {
	public static int ceil(int a, int b){
		int x = (a + (b - 1))/b;
		return x;
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int H[] = new int[N];
		int ans = 0;
		int tmp = 0;
		
		for(int i=0; i < N; i++) {
			H[i] = sc.nextInt();
		}
		
		for(int i=1; i < N; i++) {
			if(H[i-1] >= H[i]) {
				tmp += 1;
			} else {
				ans = Math.max(ans, tmp);
				tmp = 0;
			}
		}
		ans = Math.max(ans, tmp);
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 52392
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
    int n;
    ll d;
    scanf("%d%lld",&n,&d);
    ll a,b;
    d *= d;
    int x = 0;
    
    while (n --) {
        scanf("%lld%lld",&a,&b);
        if (a * a + b * b <= d) x ++;
    }
    printf("%d\n",x);
    return 0;
}


Measured memory_bytes: 3820
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <algorithm>

using namespace std;

int main() {
	string S;
	bool b = false;

	cin >> S;

	for (int i = 1; i < (int)S.size(); i++) {
		if (S[i] == 'C' && S[i-1] == 'A') b = true;
	}

	if (b) {
		cout << "Yes" << endl;

	}
	else {
		cout << "No" << endl;
	}



	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct edge{int to,cost;};
vector<edge>G[100];
const int inf=1e9;
using P=pair<int,int>;
int main(){
	int n,k;
	while(cin>>n>>k,n!=0||k!=0){
	    for(int i=0;i<100;i++)
	        G[i]=vector<edge>();
    	for(int i=0;i<k;i++){
    		int type;
    		cin>>type;
    		if(type==0){
    			int a,b;
    			cin>>a>>b;
	    		int dist[100];
    			for(int i=0;i<n;i++)
    				dist[i]=inf;
    			dist[--a]=0;
    			priority_queue<P,vector<P>,greater<P>> que;
    			que.push(P(0,a));
    			while(!que.empty()){
    				P p=que.top();
    				que.pop();
    				int v=p.second;
    				for(auto x:G[v]){
    					int u=x.to;
    					if(dist[u]>dist[v]+x.cost){
    						dist[u]=dist[v]+x.cost;
    						que.push(P(dist[u],u));
    					}
    				}
    			}
    			cout<<(dist[--b]==inf?-1:dist[b])<<endl;
    		}else{
    			int c,d,e;
    			cin>>c>>d>>e;
    			G[--c].push_back((edge){--d,e});
	    		G[d].push_back((edge){c,e});
    		}
    	}
	}
}



Measured memory_bytes: 3148
import java.util.Scanner;

class Main {
    
    public static void main (String[] args){
        
        Main main = new Main ();
        
        Scanner sc = new Scanner (System.in);
        
        int N = sc.nextInt();
        int D = sc.nextInt();
        
        int [] list = new int [N*D];
        
        for (int index=0; index<N*D; index++){
            list[index]=sc.nextInt();
        }
        
        int count = 0;
        for (int index=0; index<N; index++){
            
            for (int index2=index+1; index2<N; index2++){
                
                double  sum = 0;
                
                for (int index3=0; index3<D; index3++){
                    
                    sum+=Math.abs((list[index*D+index3]-list[index2*D+index3])*(list[index*D+index3]-list[index2*D+index3]));
                }
                
                sum=Math.sqrt(sum);
                
                if (sum%1==0){
                    count++;
                }
            }
        }
        
        System.out.println(count);
        
        
    }
}

Measured memory_bytes: 21844
S = input()
flag = True
cnt = 1
for i in S:
    if cnt % 2 != 0:
        if i != "R" and i != "U" and i != "D":
            flag = False
            break
    else:
        if i != "L" and i != "U" and i != "D":
            flag = False
            break
    cnt += 1
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (x == 0 && y == 0) break;
            String print = Arrays.asList(x, y).stream().sorted().map(num -> String.valueOf(num))
                    .collect(Collectors.joining(" "));
            System.out.println(print);
        }
        sc.close();
    }
}



Measured memory_bytes: 41204
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

int main() {

	int a, b, c;
	cin >> a >> b >> c;
	cout << c - min(a - b, c) << endl;






}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string> 
#include<map>
#include<set>
#include<vector>
#include<string.h> 
#include<math.h>
#include<stdio.h> 
#include<queue>
using namespace std;
int a[100002];
int main()
{int n,s=0,p=0,c;cin>>n;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++)s=max(a[i],s);
for(int i=0;i<n;i++)if(min(a[i],s-a[i])>p){
	p=min(a[i],s-a[i]);c=a[i];
}
cout<<s<<" "<<c;
system("pause");
return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;
using std::abs;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;
const int INF = (int)2e9;
const int64 INF64 = (int64)2e18;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

template<typename T>
std::ostream& operator<<(std::ostream& os, const vector<T>& vec) {
	os << '[';
	int fst = 1;

	for(auto& elem: vec) {
		if(fst == 0) {
			os << ' ';
		}

		os << elem;
		fst = 0;
	}

	os << ']';
	return os;
}

const int MAX_N = 507;
const int MAX_C = 35;

int D[MAX_C][MAX_C], n, C;
int cnt[3][MAX_C];

void solve() {
	cin >> n >> C;

	for(int i = 0; i < C; ++i) {
		for(int j = 0; j < C; ++j) {
			cin >> D[i][j];
		}
	}

	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < n; ++j) {
			int color, rem = (i + j) % 3;
			cin >> color;
			--color;

			++cnt[rem][color];
		}
	}

	int answ = INF;
	int paint[3];

	for(paint[0] = 0; paint[0] < C; ++paint[0]) {
		for(paint[1] = 0; paint[1] < C; ++paint[1]) {
			for(paint[2] = 0; paint[2] < C; ++paint[2]) {
				if(paint[0] == paint[1] || paint[0] == paint[2] || paint[1] == paint[2]) {
					continue;
				}

				int local = 0;

				for(int color = 0; color < C; ++color) {
					for(int rem = 0; rem < 3; ++rem) {
						int needed_color = paint[rem];

						local += cnt[rem][color] * D[color][needed_color];
					}
				}

				answ = std::min(answ, local);	
			}
		}
	}

	cout << answ << '\n';
}

int main() {
	init_IO();
	solve();

	return 0;
}


Measured memory_bytes: 256
#include <complex>
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <sstream>
#include <stdio.h>
 
class Point {
public:
    Point();
    Point(double x_in, double y_in);
 
    Point  operator+(const Point& obj);
    Point  operator-(const Point& obj);
    Point  operator*(const double n);
    Point  operator/(const double n);
 
    void set(double x_in, double y_in);
 
    double x;
    double y;
};
 
Point::Point() {
    x = 0;
    y = 0;
}
 
Point::Point(double x_in, double y_in) {
    x = x_in;
    y = y_in;
}
 
Point Point::operator+(const Point& obj) {
    Point temp;
    temp.x = x + obj.x;
    temp.y = y + obj.y;
    return temp;
}
 
Point Point::operator-(const Point& obj) {
    Point temp;
    temp.x = x - obj.x;
    temp.y = y - obj.y;
    return temp;
}
 
Point Point::operator*(const double n) {
    Point temp;
    temp.x = x * n;
    temp.y = y * n;
    return temp;
}
 
Point Point::operator/(const double n) {
    Point temp;
    temp.x = x / n;
    temp.y = y / n;
    return temp;
}
 
void Point::set(double x_in, double y_in) {
    x = x_in;
    y = y_in;
}
 
double abs(Point point) {
    return sqrt(point.x * point.x + point.y * point.y);
}
 
int N;
Point V[50];
 
std::string solve() {
    if (N % 2 != 0) return "NA";
    Point center = (V[0] + V[N / 2]) / 2.0;
    for (int i = 1; i < N / 2; i++) {
        Point median = (V[i] + V[i + N / 2]) / 2.0;
        Point dist = center - median;
        if (abs(dist) >= 0.00001) {
            return "NA";
        }
    }
    char str[128];
    sprintf(str, "%.5f %.5f", center.x, center.y);
    return str;
}
 
int main() {
    //入力
    std::cin >> N;
    double x, y;
    for (int i = 0; i < N; i++) {
        std::cin >> x >> y;
        V[i].set(x, y);
    }
    //演算
    std::string answer = solve();
    //出力
    std::cout << answer << std::endl;
    return 0;
}

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

public class Hello
{
    public static void Main()
    {
        int[] hw;
        string s;

        while((s = Console.ReadLine()) != null)
        {
            hw = s.Split(' ').Select(x => int.Parse(x)).ToArray();

            if (hw[0] == 0 || hw[1] == 0) break;

            for(int i = 0; i < hw[0]; i++)
            {
                for(int j = 0; j < hw[1]; j++)
                {
                    if((i % 2 == 0 && j % 2 == 0) || (i % 2 != 0 && j % 2 != 0))
                    {
                        Console.Write("#");
                    }
                    else
                    {
                        Console.Write(".");
                    }
                }
                Console.Write("\n");
            }
            Console.WriteLine();
        }
    }
}

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

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nm = readints;
    int m = nm[1];
    int[][] a;
    for (int i = 0; i < m; i++) a ~= readints;

    // 各区間の右端の位置でソート
    a.sort!((a, b) => a[1] < b[1]);

    int ans = 0;
    int p = -1; // 切断した位置
    foreach (e; a) {
        // 以前に切断した区間に含まれている
        if (e[0] <= p && p <= e[1]) continue;

        // 切断位置の更新
        p = e[1] - 1;
        ans++;
    }
    writeln(ans);
}


Measured memory_bytes: 15228
#include <cstdio>
#include <cstdlib>
#include <map>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
map<string,bool> bmap;
int card[10];
int selected[4],temp[4];
bool used[10];
int n,k,num;
void solve(int m) {
	if(m==k) {
		for(int i=0;i<k;i++)temp[i]=selected[i];
		do {
			stringstream str;
			for(int i=0;i<k;i++)str<<selected[i];
			if(bmap.find(str.str())==bmap.end())num++;
			bmap[str.str()]=true;
		}while(next_permutation(selected,selected+k));
		for(int i=0;i<k;i++)selected[i]=temp[i];
	}else {
		for(int i=0;i<n;i++) {
			if(used[i]==false) {
				used[i]=true;
				selected[m]=card[i];
				solve(m+1); 
				used[i]=false;
			}
		}
	}
}
int main() {
	while(scanf("%d %d",&n,&k),n) {
		for(int i=0;i<n;i++)scanf("%d",&card[i]);
		fill(used,used+10,0);
		bmap.clear();
		num=0;
		solve(0);
		printf("%d\n",num);
	}
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
        long long int t=0,b[1000000]={0};
        string c;
        string s;
       long long int n,m,o=0,l,d=0,i,j,p=0,k,f;
       double pie=3.141592653589793238;
    long long int MOD=1000000007;
    cin>>s;
    for(i=0;i<s.length();i++)
    {
        if(i%2==0&&s[i]=='L')
        {
            break;
        }
        if(i%2!=0&&s[i]=='R')
        {
            break;
        }
    }
    if(i==s.length())
    cout<<"Yes";
    else
    cout<<"No";
    
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long 
#define ret return
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair <int,  int>
#define pll pair <long long , long long>  
#define FAST ios::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 2e5 + 10;

int main() {
    FAST
    int a , b;
    cin >> a >> b;
    cout << 1ll * a * b << endl;
}

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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
const Int MAX = 5050;
const Int INF = 1e17;
Int dp[MAX][MAX];
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];

  Int s=0;
  for(Int i=0;i<n;i++) s+=a[i];
  Int x=s/n;
  
  vector<vector<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  vector<Int> sz(n,1);
  function<void(Int, Int)> dfs=
    [&](Int v,Int p){      
      for(Int u:G[v])
	if(u!=p) dfs(u,v),a[v]+=a[u];
      
      for(Int i=0;i<MAX;i++) dp[v][i]=INF;
      dp[v][0]=dp[v][1]=0;
      for(Int u:G[v]){
	if(u==p) continue;
	vector<Int> nx(sz[v]+sz[u]+2,INF);
	for(Int i=0;i<=sz[v];i++)
	  for(Int j=0;j<=sz[u];j++)
	    chmin(nx[i+j],dp[v][i]+dp[u][j]+abs(a[u]-((x+1)*j+x*(sz[u]-j))));
	
	sz[v]+=sz[u];
	for(Int i=0;i<=sz[v];i++) dp[v][i]=nx[i];
      }
    }; 

  dfs(0,-1);  
  cout<<dp[0][s%n]<<endl;
  return 0;
}



Measured memory_bytes: 201124
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
before = -1
manzoku = sum(B)

for cnt in range(len(A)):
  if A[cnt] - before == 1:
    manzoku += C[before-1]
  before = A[cnt]

print(manzoku)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int k;
    cin >> k;
    vector<int> s;
  	s.pb(0);
    rep(i,k){
        int n=sz(s);
        for(int j=n-1;j>=0;j--){
            if(!j){
                if(s[0]==9){
                    s.clear();
                    s.pb(1);
                    rep(p,n)s.pb(0);
                    break;
                }
                else{
                    s[0]++;
                    for(int p=1;p<=n-1;p++){
                        s[p]=max(0,s[p-1]-1);
                    }
                  	break;
                }
            }
            else{
                if(s[j]<=s[j-1] && s[j]!=9){
                    s[j]++;
                    for(int p=j+1;p<=n-1;p++){
                        s[p]=max(0,s[p-1]-1);
                    }
                    break;
                }
            }
        }
    }
  	for(auto x:s)cout << x;


}

/*



 */




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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll whole = 0;
    rep(i,n){
        whole ^= a[i];
    }
    rep(i,n){
        cout << ll(whole ^ a[i]) << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4648
#include<stdio.h>

int c[50];
int main(){
	int n,m;
	int a[50],b[50];
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d %d",&a[i],&b[i]);
		c[a[i]]++;
		c[b[i]]++;
	}
	for(int i=1;i<n+1;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}

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

struct Stack{
    int box[1000];
    int top;
    Stack():top(0){};
    void pop_in(int in){
        box[top] = in;
        top++;
    };
    int pop_out(){
        if(top == 0)
            return 0;
        int ret = box[top-1];
        top--;
        if(top < 0)
            top = 0;
        return ret;
    };
};


int main(){
    Stack stack;
    string input;
    cin >> input;
    while(!cin.fail()){
        if(input == "+"){
            int right = stack.pop_out();
            int left = stack.pop_out();
            stack.pop_in(left + right);
        }else if(input == "-"){
            int right = stack.pop_out();
            int left = stack.pop_out();
            stack.pop_in(left - right);
        }else if(input == "*"){
            int right = stack.pop_out();
            int left = stack.pop_out();
            stack.pop_in(left * right);
        }else{
            int temp = stoi(input);
            stack.pop_in(temp);
        }
        cin >> input;
    }
    cout << stack.pop_out() << endl;
    return 0;
}


Measured memory_bytes: 3208