akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
ll dp[100100][4];
//dp[i][j]でsのi文字目までにj文字目まで照合してる時の場合の数
//j=0で何も照合してない1でAまで2でBまで3でCまで
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < 100100; ++i) {
		for (int j = 0; j < 4; ++j) {
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < s.size(); ++i) {
		for (int j = 0; j <= 3; ++j) {
			if (s[i] != '?') {
				dp[i + 1][j] += dp[i][j];
			}
			else {
				dp[i + 1][j] += dp[i][j] * 3;
			}
		}
		if (s[i] == 'A') {
			dp[i + 1][1] += dp[i][0];
		}
		else if (s[i] == 'B') {
			dp[i + 1][2] += dp[i][1];
		}
		else if (s[i] == 'C') {
			dp[i + 1][3] += dp[i][2];
		}
		else {
			dp[i + 1][3] += dp[i][2];
			dp[i + 1][2] += dp[i][1];
			dp[i + 1][1] += dp[i][0];
		}
		for (int j = 0; j <= 3; ++j) {
			dp[i + 1][j] %= INF;
		}
	}
	cout << dp[s.size()][3] << endl;
	return 0;
}



Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
using namespace std;

typedef long long ll;
#define N 5050
int a[N]={0};
int  main(){
    ll n,k;
    cin>>n>>k;
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    sort(a,a+n);//排序，容易知道一定是最小的那几个是不需要的
    ll sum = 0;
    ll p = n;

    for(ll i=n-1; i>=0; i--){
        if(sum+a[i]<k){
            sum +=a[i];
        }
        else{
            p = i;
        }
    }
    cout<<p<<endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

n,m=[int(i) for i in input().split()]
inp=[]
for i in range(m):
    p,y=[int(i) for i in input().split()]
    inp.append([p,y,i])

P=[[] for i in range(n)]
for i in range(m):
    P[inp[i][0]-1].append(inp[i])

out=[]
for i in range(n):
    P[i].sort(key=lambda x:x[1])
    l=len(P[i])
    for j in range(l):
        P[i][j].append(j+1)
        out.append(P[i][j])
out.sort(key=lambda x:x[2])

for i in range(m):
    x=str(out[i][0])
    y=str(out[i][3])
    ID=x.zfill(6)+y.zfill(6)
    print(ID)


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

using namespace std;

long n;
long res=0;

int dfs(long m,long a,long b, long c){

 if(m>n) return res;
  if(a&&b&&c) res++;
  dfs(10*m+3,1,b,c);
  dfs(10*m+5,a,1,c);
  dfs(10*m+7,a,b,1);
  
}

int main(){

  cin >> n;
 

  cout << dfs(0,0,0,0) << endl;
   

}

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

int main() {
    
    long long N;
    cin >> N;
    vector<long long> a(N);
    int i = 0;
    for(i=0;i<N;i++){
        a[i] = 0;
    }
    int j = 0;
    int v = 1
    
    ;
    int ans = 0;
    for(i = 1;i<sqrt(N);i++){
        for(j = 1;j<sqrt(N);j++){
            for(v =1;v<sqrt(N);v++){
                ans = i*i+j*j+v*v+i*j+j*v+i*v;
                if(ans <= N){
                    a[ans-1]++;
                }
            }
        }
    }

    for(i=0;i<N;i++){
        cout << a[i] << endl; 
    }
}

Measured memory_bytes: 3504
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) vdeb(da[i]);
    std::cout << std::endl;
}

using namespace std;

int main(){
    int n; cin >> n;
    vector<Pll> da(n);
    rip(i,n,0) cin >> da[i].first;
    rip(i,n,0) da[i].second = i;
    vector<vector<ll>> dp(n+1, vector<ll>(n+1));
    sort(all(da));
    reverse(all(da));
    rip(i,n+1,0){
        for(int j = n; j > i; --j){
            int now = n - j + i;
            chmax(dp[i+1][j], dp[i][j] + da[now].first * abs(i-da[now].second));
            chmax(dp[i][j-1], dp[i][j] + da[now].first * abs(j-da[now].second-1));
        }
    }
    ll ans = 0;
    rip(i,n-1,0){
        chmax(ans, dp[i][i]);
    }
    // vdeb(dp);
    cout << ans << endl;
}

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

int main() {
    int N,R;
    cin >> N >> R;
    int R_I;

    if(N<10){
        R_I = R + 100*(10-N);
    }else{
        R_I = R;
    }

    cout << R_I << endl;

    return 0;
}


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

int main() {
  int A, B;
  scanf("%d %d",&A,&B);
  char S[A+B+1];
  scanf("%s",S);
  int cnt=0;
  for (int i=0; i<A+B+1; i++) {
    if (i!=A && (S[i]>='0' && S[i]<='9')) {
      cnt++;
    }
    if (i==A && S[i]=='-') {
      cnt++;
    }
  }
  if (strlen(S)==cnt) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;
int xv[]={0,1,0,-1};
int yv[]={1,0,-1,0};
char map[1002][1002];
int flag[1002][1002];
int main(){
	int H,W,N;
	cin>>H>>W>>N;
	
	for(int i=0;i<=W+1;i++)map[i][0]=map[i][H+1]='X';
	for(int i=0;i<=H+1;i++)map[0][i]=map[W+1][i]='X';
	int pos[10][2];
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin>>map[j][i];
			if(map[j][i]=='S')pos[0][0]=j,pos[0][1]=i;
			if('0'<map[j][i]&&map[j][i]<='9')pos[map[j][i]-'0'][0]=j,pos[map[j][i]-'0'][1]=i;
		}
	}
	int ans=0;
	for(int n=1;n<=N;n++){
		
		memset(flag,-1,sizeof(flag));
		queue<int>X;
		queue<int>Y;
		X.push(pos[n-1][0]);
		Y.push(pos[n-1][1]);
		flag[pos[n-1][0]][pos[n-1][1]]=0;
		for(int x,y;!X.empty();X.pop(),Y.pop()){
			x=X.front();
			y=Y.front();
			if(map[x][y]==(n+'0')){
				ans+=flag[x][y];
				break;
			}
			for(int i=0;i<4;i++){
				x=X.front()+xv[i];
				y=Y.front()+yv[i];
				if(map[x][y]!='X'&&flag[x][y]<0){
					flag[x][y]=(flag[X.front()][Y.front()]+1);
					X.push(x);
					Y.push(y);
				}
				
				
			}
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 6120
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, T, A;
    cin >> N >> T >> A;
    double ans = 1000;
    int ans_n = 0;
    for (int i = 1; i <= N; i++)
    {
        double H;
        cin >> H;
        double tmp = T - H * 0.006;
        double sa = abs(A - tmp);
        if (sa < ans)
        {
            ans = sa;
            ans_n = i;
        }
    }
    cout << ans_n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  string s; cin >> s;
  bool ok = false;
  rep(i,3){
    if(s[i]=='7') ok = true;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main(){
  int N;
  string S;
  int myAC=0;
  int myWA=0;
  int myRE=0;
  int myTLE=0;
  cin >> N;
  
  for (int i=0 ;i<N;i++){
    cin >> S;
    if (S == "AC"){
      myAC++;
    }else if(S == "WA"){
      myWA++;
    }else if(S == "TLE"){
      myTLE++;
    }else if(S == "RE"){
      myRE++;
    }
  }
  cout << "AC x " << myAC << endl << "WA x " << myWA << endl<< "TLE x "  << myTLE << endl<< "RE x "  << myRE << endl;
  
  return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	int N=sc.nextInt();
    	int K=sc.nextInt();
    	int X=sc.nextInt();
    	int Y=sc.nextInt();

    	int result=0;
    	if(N-K>0) {
    		result=(N-K)*Y+K*X;
    	}else {
    		result=N*X;
    	}

    	System.out.println(result);
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}
int ans[1000005];
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++)
        {
            for(int k=1;k<=100;k++)
            {
                int z=i*i+j*j+k*k+i*j+j*k+i*k;
                ans[z]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<'\n';

} 
    


Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,r=0,b=0;string s;cin>>N>>s;
  for(int i=0;i<N;i++){
    if(s.at(i)=='R')r++;
    else b++;
  }
  if(r>b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
def resolve():
    n = int(input())
    h = list(map(int, input().split()))
    c = 0
    ans = 0
    for i in range(n - 1):
        if h[i + 1] <= h[i]:
            c += 1
            if c > ans:
                ans = c
        else:
            c = 0
    print(ans)
 
 
if __name__ == '__main__':
    resolve()

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

int search(int A[], int n, int key){
    int i=0;
    A[n] = key;
    while(A[i] != key) i++;
    return i != n;
}

int main(){
    int i, n, A[10000+1], q, key, sum = 0;
    cin >> n;
    for(i=0; i<n; i++) scanf("%d", &A[i]);
    cin >> q;
    for(i=0; i<q; i++){
        scanf("%d", &key);
        if(search(A,n,key)) sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3240
#include <iostream>

#include <algorithm>
#include <cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>

using namespace std;
typedef long long LL;

int main() {


	int a, b,c;
	//----------------------
	LL n, X, Z,A,B,N,ans1,ans2,i;
	LL ans, count=0 ;
	bool f=true;
	string s;

	cin >> i;

	ans = i / 100 + i % 100 / 10 + i % 100%10;
	

	

	cout << ans << endl;

	
	//------------------------
	//cin >> Z;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{ll to,cost;};
const int inf = 1<<27;
const ll INF = 1LL<<60;
const int COMBMAX = 1001001;
const ll MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n, ll mod = MOD){ll res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}

int main(){
vector<string> m = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
    ll K; cin >> K;
    ll cnt = 0;
    queue<string> q;
    rep(i, 9) q.push(m[i + 1]); 
    while(true){
        cnt++;
        string v = q.front(); q.pop(); 
        if (cnt == K){
            pt(v);
            return 0;
        }
        if (*(v.end() - 1) == '0'){
            q.push(v + "0");
            q.push(v + "1");
        }else if (*(v.end() - 1) == '9'){
            q.push(v + "8");
            q.push(v + "9");
        }else{
            int lc = *(v.end() - 1) - '0';
            q.push(v + (m[lc - 1]));
            q.push(v + (m[lc]));
            q.push(v + (m[lc + 1]));
        }
    }
    return 0;
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int h, w; cin >> h >> w;
	vector<string> s(h), res(h * 2);
	for (int i = 0; i < h; i++) cin >> s[i];
	for (int i = 0; i < 2 * h; i++) {
		res[i] = s[i / 2];
	}
	for (int i = 0; i < 2 * h; i++) cout << res[i] << '\n';
	return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#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 INF 1000000
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
const ll inf = 1LL << 60;
const int cost = 10;

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

    int H,W;cin>>H>>W;
    vector<vector<int> > C(cost,vector<int>(cost,INF));
    REP(i,cost){
        REP(k,cost){
            cin >> C[i][k];
        }
    }
    REP(i,cost){
        C[i][i] = 0;
    }
    REP(k,cost){
        REP(i,cost){
            REP(j,cost){
                C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
            }
        }
    }
    int ans = 0;
    //int A[H][W];
    REP(i,H){
        REP(k,W){
            int a; cin>>a;
            if(a == -1)continue;
            else{
                ans += C[a][1];
            }
        }
    }

    cout << ans << endl;

}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int h;
    static int w;
    static char[][] road;
    
    public static void main(String[] args) {
        h = sc.nextInt();
        w = sc.nextInt();
        road = new char[h][w];
        for(int y = 0; y < h; ++y) road[y] = sc.next().toCharArray();
        dfs(0, 0);
        String ans = (hasVisitedAllGrids()) ? "Possible" : "Impossible";
        System.out.println(ans);
    }
    
    static int[] dy = {0, 1};
    static int[] dx = {1, 0};
    static void dfs(int y, int x) {
        road[y][x] = '!';
        for(int i = 0; i < 2; ++i) {
            int ty = y + dy[i];
            int tx = x + dx[i];
            
            if(isOutside(ty, tx) || road[ty][tx] != '#') continue;
            
            dfs(ty, tx);
            return;
        }
    }
    
    static boolean isOutside(int y, int x) {
        return (y < 0 || h <= y || x < 0 || w <= x);
    }
    
    static boolean hasVisitedAllGrids() {
        for(int y = 0; y < h; ++y) {
            for(int x = 0; x < w; ++x) {
                if(road[y][x] == '#') return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

const int MOD = 1e9+7;

int dfs(vc<vi> &G,int now,int from,int K){
    int ans=1;
    int pos;

    if(G[now].size()>K) return 0;

    if(from==-1) {
        pos=K-1;
        rep(i,G[now].size()){
            ans*=pos;
            ans%=MOD;
            pos--;
        }
    }
    else {
        pos=K-2;
        rep(i,G[now].size()-1){
            ans*=pos;
            ans%=MOD;
            pos--;
        }
    }
    
    for(auto a:G[now]){
        if(a==from) continue;
        else {
            ans*=dfs(G,a,now,K);
            ans%=MOD;
        }
    }
    return ans;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,K; cin >> N >> K;
    vc<vi> G(N);
    rep(i,N-1){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].eb(b);
        G[b].eb(a);
    }
    int ans=(K*dfs(G,0,-1,K))%MOD;
    cout << ans << endl;
}

Measured memory_bytes: 11648
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n, k; cin >> n >> k;
    LL ans = 1e9;
    rep(bit, 1 << n) {
        LL cnt = 1;
        rep(i, n) {
            if (bit & (1 << i)) {
                cnt *= 2;
            } else {
                cnt += k;
            }
        }
        ans = min(ans , cnt);
    }
    cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 30;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  int r, g, b;
  cin >>r >> g >> b;
  if((10*g+b)%4==0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,k,num,min=0;
  vector<int> h;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> num;
    h.push_back(num);
  }
  sort(h.begin(),h.end());
  min=h[k-1]-h[0];
  for(int i=1;i+k-1<n;i++){
    num=h[i+k-1]-h[i];
    min=(num<min)?num:min;
  }
  cout << min << endl;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b){
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b){
	int res=1;
	while(b){
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

int X=3999;

void solve(){
	int H,W,h,w;
	cin>>H>>W>>h>>w;
	vector<vector<int>>a(H,vector<int>(W,X));
	int val=-X*(h*w-1)-1;
	for(int i=h-1;i<H;i+=h){
		for(int j=w-1;j<W;j+=w){
			a[i][j]=val;
		}
	}
	ll sum=0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			sum+=a[i][j];
		}
	}
	if(sum<=0){
		cout<<"No";
		return;
	}
	cout<<"Yes\n";
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cout<<a[i][j]<<' ';
		}
		cout<<'\n';
	}	
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 2560
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        if(X<A) System.out.println(0);
        else System.out.println(10);

    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

ll dp[60][60][3000];

int main()
{
    ll n, ans = 0;
    cin >> n;
    map<int, int> mp;
    rep(i, n)
    {
        ll x;
        cin >> x;
        mp[x]++;
    }
    for (auto e : mp)
    {
        if (e.second % 2 != 0)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n;
  int tmp;
  int score;

  while(1){
    cin >> n;
    if(!n)break;

    score = 0;
    n /= 4;
    for(int i=0;i<n;i++){
      cin >> tmp;
      score += tmp;
    }

    cout << score << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int> l(n);
  rep(i,n)cin>>l[i];
  int ml=0;
  rep(i,n)chmax(ml,l[i]);
  int summ=0;
  rep(i,n)summ+=l[i];
  if(ml*2<summ)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;

}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli a, b, c;
    cin>>a>>b>>c;
    Yes((a<c&&c<b)||(b<c&&c<a));
}

Measured memory_bytes: 3600
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <climits>
using namespace std;
  
int main() {
  long long M, N;
  cin >> N >> M;
  vector<long long> books(N);
  for(int i=0; i<N; i++) {
    cin >> books[i];
  }
      
  unsigned long long l = 1, r = ULLONG_MAX;
  while(r - l > 1) {
    long long m = (l+r)/2;
    int BPS = 0;
    for(int i=0; i<M; i++) {
      long long size = m;
      for(;;) {
        if(BPS == N) break;
        if(size - books[BPS] < 0) break;
        size -= books[BPS++];
      }
      if(BPS == N) break;
    }
    if(BPS == N) {
      r = m;
    } else l = m;
  }
      
  cout << l+1 << endl;
  
    
  return 0;
}

Measured memory_bytes: 1796
#include <cstdio>
#include <math.h>
#include <utility>

using namespace std;

int main ()
{
  int H, W;
  int count = 0;
  pair<int, int> data[5000];

  while (1) {
    scanf("%d", &H);
    scanf("%d", &W);
    if (H == 0 && W == 0) {
      break;
    }
    data[count].first = H;
    data[count].second = W;
    count++;

  }

  for (int i = 0; i < count; i ++) {
    for (int j = 0; j < data[i].first; j++) {
      for (int k = 0; k < data[i].second; k++) {
        if (j == 0 || j == data[i].first - 1 || k == 0 || k == data[i].second - 1) {
          printf("#");
        } else {
          printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 2628
#include "bits/stdc++.h"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<vd> vvd;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
const int MAX = 1000010;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  ll x,y;cin>>x>>y;
  ll s,t;
  if((x+y)%3!=0){cout<<0<<endl;}
  else{
    t=(x*2-y)/3;s=x-t*2;
    if(s<0||t<0){cout<<0<<endl;}
    else{
      COMinit();
      cout<<COM(s+t,max(s,t))<<endl;
    }
  }
}

Measured memory_bytes: 23808
#include <cstdio>
#include <map>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

const int MAX = 405;

vector <int> col[MAX];
map <vector<int>, int> M;

void rotate(vector <int> &V)
{
  int poc = V[0];
  for (int i=0; i<3; i++)
    V[i] = V[i+1];
  V[3] = poc;
}

vector <int> minrot(vector <int> V)
{
  vector <int> R = V;
  for (int i=0; i<4; i++) {
    rotate(V);
    R = min(R, V);
  }

  return R;
}

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

  for (int i=0; i<n; i++) {
    for (int j=0; j<4; j++) {
      int x;
      scanf("%d", &x);
      col[i].push_back(x);
    }
    col[i] = minrot(col[i]);
    M[col[i]]++;
  }

  ll rje = 0;
  for (int i=0; i<n; i++) {
    M[col[i]]--;
    reverse(col[i].begin(), col[i].end());
    for (int j=i+1; j<n; j++) {
      M[col[j]]--;
      reverse(col[j].begin(), col[j].end());
      for (int rot=0; rot<4; rot++) {
        int sus[4] = {col[j][1], col[j][0], col[j][3], col[j][2]};
        vector <int> kocke[4];
        for (int l=0; l<4; l++) {
          kocke[l] = vector<int>{col[i][l], col[i][(l+1)%4], sus[(l+1)%4], sus[l]};
          kocke[l] = minrot(kocke[l]);
        }

        int koef = 1;
        for (int l=0; l<4; l++) {
          int br = 0;
          vector <int> tmpkoc = kocke[l];
          for (int rr=0; rr<4; rr++) {
            if (kocke[l] == tmpkoc)
              br++;
            rotate(tmpkoc);
          }
          koef *= br;
        }

        ll tmp = 1;
        for (int l=0; l<4; l++)
          tmp *= M[kocke[l]]--;
        for (int l=0; l<4; l++)
          M[kocke[l]]++;

        rotate(col[j]);
        rje += tmp * koef;
      }


      reverse(col[j].begin(), col[j].end());
      M[col[j]]++;
    }
  }

  printf("%lld\n", rje);

  return 0;
}


Measured memory_bytes: 139904
'use strict'
const Main = (arg) => {
  let input = arg.trim().split('\n');
  let N = input[0].split(' ').map(Number)[0];
  let Arr = input[1].split(' ').map(Number);

  let SmS = [];
  for (let i = 1; i < N; i++) {
    let leftS = Arr.slice(0, i).reduce((ttl, data) => { return ttl + data });
    let rightS = Arr.slice(-(N - i)).reduce((ttl, data) => { return ttl + data });
    SmS.push(Math.abs(leftS - rightS));
  }
  console.log(Math.min(...SmS));


}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7624
n, m = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(m)]

vis = [0] * n
vis[0] = 1

G = [[0] * n for i in range(n)]
for a, b in A:
    G[a -1][b - 1] = 1
    G[b - 1][a - 1] = 1
    
cnt = 0
    
def dfs(x):
    global cnt
    if sum(vis) == n:
        cnt += 1
        return
    for i in range(n):
        if G[x][i] == 1 and vis[i] == 0:
            vis[i] = 1
            dfs(i)
            vis[i] = 0
    return

dfs(0)
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==v.size()?"":" ");
    return os;
}


signed main(){
    int l,r,d;cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;i++){
        if(i%d==0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(){
  int h, w, n;
  std::cin >> h >> w >> n;
  if( n%max(h,w) == 0 ){
    std::cout << n / max(h,w) << '\n';
  }else{
    std::cout << n / max(h,w) + 1 << '\n';
  }
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  rep(i,s.length())s.replace(i, 1,"x");
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

bool exist[8];
int numofAHO=0;
int ans=0;
int ansmax=0;

void judgecolor(int n){
  if(n<400){
    exist[0]=true;
  }
  else if(n<800){
    exist[1]=true;
  }
  else if(n<1200){
    exist[2]=true;
  }
  else if(n<1600){
    exist[3]=true;
  }
  else if(n<2000){
    exist[4]=true;
  }
  else if(n<2400){
    exist[5]=true;
  }
  else if(n<2800){
    exist[6]=true;
  }
  else if(n<3200){
    exist[7]=true;
  }
  else{
    numofAHO++;
  }
}

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d\n", &N);
  int tmp;
  for (size_t i = 0; i < N; i++) {
    if(i==N-1){
      scanf("%d\n", &tmp);
    }
    else{
      scanf("%d ",&tmp);
    }
    judgecolor(tmp);
  }

  for (size_t i = 0; i < 8; i++) {
    if(exist[i]){
      ans++;
    }
  }
  ansmax=ans+numofAHO;
  if(ans==0&&numofAHO!=0){
    ans=1;
  }
  printf("%d %d\n", ans,ansmax);
  return 0;
}


Measured memory_bytes: 128
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<list>
#include<vector>//可変長配列
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second


string s;

int main() {
    cin >> s;
    if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi")
        cout << "Yes" << endl;
    else
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include<cstdlib>
using namespace std;
struct Node
{
	int key;//??°?????¬????????´??°key
	Node *next, *prev;//???????????????????´??????????next?????????????????????????´???????prev
};
Node *nil;//??´??????
Node* listSearch(int key)
{
	Node *cur = nil->next;//?????´???????????¢???????´?????§???????
	while (cur != nil&&cur->key != key)
	{
		cur=cur->next;
	}
	return cur;//?????????????????????????????????
}
void init()
{
	//malloc???C????¨?????????????????????°?????¨?????¨?????????????????§?°???????????????´???sizeof???Node????????????Node?±???????????????´?????§?°?
	nil = (Node*)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}
void printList()
{
	Node *cur = nil->next;
	int isf = 0;
	while (1)
	{
		if (cur == nil) break;
		if (isf++ > 0)
			cout << " ";
		cout << cur->key;//?????°????????????
		cur = cur->next;//?????????????????????
	}
	cout << endl;
}
void deleteNode(Node *t)
{
	if (t == nil) return;//???t?????´????????¶????????????
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}
void deleteFirst()
{
	deleteNode(nil->next);
}
void deleteLast()
{
	deleteNode(nil->prev);
}
void deleteKey(int key)
{
	deleteNode(listSearch(key));//??????????´¢??°?????????
}
void insert(int key)
{
	Node *x = (Node*)malloc(sizeof(Node));
	x->key = key;
	//??¨??´???????????????????´?
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}
int main()
{
	int key, n;//n???????????°
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	cin >> n;
	init();
	for (int i = 0; i < n; i++)//????????????????°±???????¬???????
	{
		cin >> com;
		if (com[0] == 'i')
		{
			cin >> key;
			insert(key);
			np++;
			size++;
		}
		else if (com[0] == 'd')
		{
			if (strlen(com) > 6)
			{
				if (com[6] == 'F')
					deleteFirst();
				else if (com[6] == 'L')
					deleteLast();
			}
			else
			{
				cin >> key;
				deleteKey(key); 
				nd++;
			}
			size--;
		}
	}
	printList();
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,K;

int main(){
	cin >> n >> K;
	vector<ll> vl(n);
	rep(i,n)cin >> vl[i];
	bool f = 1;
	ll ans = 0;
	rep(i,51){
		ll cnt = 0;
		rep(j,n)if(vl[j] & (1LL << (50-i)))cnt++;
		// cout << i+1 << ":" << cnt << endl;
		if(cnt >= n-cnt){//0
			if((K & (1LL << (50-i))))f = 0;
			ans += (1LL << (50-i))*cnt;
		}
		else{//1
			if((K & (1LL << (50-i))) == 0){
				if(f)ans += (1LL << (50-i))*cnt;
				else ans += (1LL << (50-i))*(n-cnt);
			}
			else ans += (1LL << (50-i))*(n-cnt);
		}
	}
	// rep(i,52){
	// 	cout << i << ":" << dp[i][0] << " " << dp[i][1] << endl;
	// }
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 
 using namespace std;
 
 int main()
 {
   int x,h;
   while(cin>>x>>h&&(x||h))
   {
     double S_base=1.0*x*x;
     double hh=sqrt(1.0*pow(h,2)+1.0*(pow(1.0*x/2,2)));
     double S_side=1.0/2*hh*x;
     double result=S_base+4*S_side;
     printf("%.6lf\n",result);                
   }
   //while(1);
   return 0;
 }

 
  

Measured memory_bytes: 3124
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main()
{
    string s;
    cin >> s;
    if (s == "SUN")
        cout << 7;
    else if (s == "MON")
        cout << 6;
    else if (s == "TUE")
        cout << 5;
    else if (s == "WED")
        cout << 4;
    else if (s == "THU")
        cout << 3;
    else if (s == "FRI")
        cout << 2;
    else if (s == "SAT")
        cout << 1;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

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

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

    string T = "CODEFESTIVAL2016";

    int ans = 0;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] != T[i]) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


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


int main(void) {
	long long N;
	cin >> N;
	
	for (int h = 1; h <= 3500; h++) {
		for (int n = 1; n <= 3500; n++) {
			long long a = h*n*N;
			long long b = 4*h*n-h*N-n*N;
			if (b<=0) continue;
			if ((a%b)==0) {
				cout << h << " " << n << " " << a/b << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    for(int i=0;i<3000;i++){cin>>x>>y;
        if(x==0&&y==0){break;}
        if(x<y){cout<<x<<" "<<y<<endl;}else{cout<<y<<" "<<x<<endl;}
    }
}



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

const int NILL = -1;

typedef long int lint;

typedef struct node
{
  lint key;
  struct node* parent;
  struct node* left;
  struct node* right;
  
}TREE;

TREE* root = NULL;

void insert(TREE* t)
{
  TREE* x;
  TREE* y;

  y = NULL;
  x = root;

  while(x != NULL)
  {
    y = x;
    if(t->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  
  if(y == NULL) root = t;
  else if(t->key < y->key){
    y->left = t;
  }
  else{
    y->right = t;
  }
}

void PreOrder(TREE* n)
{
  if(n == NULL) return;
  printf(" %ld",n->key);
  PreOrder(n->left);
  PreOrder(n->right);
}

void InOrder(TREE* n)
{
  if(n == NULL) return;
  InOrder(n->left);
  printf(" %ld",n->key);
  InOrder(n->right);
}

void print()
{
  InOrder(root);
  printf("\n");
  PreOrder(root);
  printf("\n");
}

int main()
{
  int m;
  int i;
  char order[20];
  lint key;
  
  scanf("%d",&m);

  for(i = 0; i < m;i++){
    scanf("%s",order);
    
    if(order[0] == 'i'){
      scanf("%ld", &key);

      //if(i == 0) root = tree;
      TREE* t = (TREE *)malloc(sizeof(TREE));
      t->right = t->left = NULL;

      t->key = key;
      insert(t);
    }
    else if(strcmp(order,"print") == 0){
      print();
    }
  }
  return 0;
}



Measured memory_bytes: 25172
// depends on: -

/*
usage:

tools::square(5) => 25
*/

namespace tools {
  template <typename T> constexpr T square(const T x) {
    return x * x;
  }
}
namespace tools {
  template <typename T> constexpr T pow(const T base, const T exponent) {
    return exponent == 0
      ? 1
      : exponent % 2 == 0
        ? square(pow(base, exponent / 2))
        : pow(base, exponent - 1) * base;
  }
}
#include <iostream>
#include <cstdint>

int main() {
  std::int_fast64_t n, k;
  std::cin >> n >> k;
  std::cout << k * tools::pow(k - 1, n - 1) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int x[5], ans;
    rep(i, 5){
        cin >> x[i];
        if(x[i] != i+1)ans = i+1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3672
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    int time=0;
    int n;
    ll ans=0;
    while(cin>>n){
        ans=0;
        if(n==0)break;
        time=0;
        
        for(int i=9;i>=1;i--){
            time=0;
            while(n>=pow(8,i)){
                time++;
                if( time!=4 && time!=6 )
                    n-=pow(8,i);
                ans+=pow(10,i);
            }
        }
        for(int i=1;i<=9;i++){
            if(n==0)break;

            if(i!=4 && i!=6){
                n--;
            }
            ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1204