akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    LL n,k;cin >> n >> k;
    vector<LL> a(n),f(n);
    LL sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    if(sum<=k){
        puts("0");
        return 0;
    }
    for (int i = 0; i < n; i++) {
        cin >> f[i];
    }
    sort(ALL(a));
    sort(RALL(f));
    LL l = 0,r = 1e13;
    while(abs(r-l)>1){
        LL m = (r + l) / 2;
        LL s = 0;
        for (int i = 0; i < n; i++) {
            if(a[i]*f[i]<=m) continue;
            s += (a[i]*f[i] - m + f[i] - 1) / f[i];
        }
        if(s<=k) r = m;
        else l = m;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
   
    ll k,x;
    cin >> k >> x;
    if(k*500 >= x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Csharp練習
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b,c;
            string[] str;
            int ans;

            str=Console.ReadLine().Split(' ');

            a=int.Parse(str[0]);
            b=int.Parse(str[1]);
            c=int.Parse(str[2]);

            if(a+b>=c){
                Console.Write("Yes");
            } else {
                Console.Write("No");
            }
        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt();
            var b = cin.nextInt();
            var c = cin.nextInt();

            Console.WriteLine(a + b + c >= 22? "bust" : "win");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int n ;
	cin >> n ;
	vector<int> a(n),p(n),q(n);
	rep(i,n){
		a[i] = i + 1;
		cin >> p[i] ;
	}rep(i,n) cin >> q[i];
	int i = 0 ;
	int P , Q;
	do {
		if(a == p){
			P = i ;
		} 
		if(a ==  q){
			Q = i;
		}
		i++;

	} while(next_permutation(a.begin(),a.end()));
	int ans = abs(P-Q);
	cout << ans << endl;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			int count = 0;
			for (int i = 0; i < s.length; i++) {
				if (s[i] == '1') count++;
			}
			out.println(count);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public int[] nextIntArray1Index(int n) {
			int[] res = new int[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public long[] nextLongArray1Index(int n) {
			long[] res = new long[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextLong();
			}
			return res;
		}

		public double[] nextDoubleArray(int n) {
			double[] res = new double[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextDouble();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}
	
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    int a;
    vector<int> S;
    cin >> N;
    REP(i,(1<<N)){
        cin >> a;
        S.push_back(a);
    }
    sort(S.begin(),S.end(),greater<>());
    //REP(i,S.size()){cout << S[i] << " ";}cout << endl;
    priority_queue<pair<int,int>> Q;
    multiset<int> T;
    REP(i,S.size()){
        if(i==0)continue;
        T.insert(S[i]);
    }
    RREP(i,N){
        Q.push({i,S[0]});
    }
    while(!Q.empty()){
        pair<int,int> q=Q.top();
        Q.pop();
        //cout << q.first MM q.second << endl;
        auto it = T.lower_bound(q.second);
        it--;
        if(it==T.end())GOODBYE;
        int r = *it;
        it = T.erase(it);
        //cout << "!? " MM r << endl;
        if(r>=q.second)GOODBYE;
        RREP(i,q.first){
            Q.push({i,r});
            //cout << "! " MM i MM r << endl;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}



Measured memory_bytes: 17648
import numpy as np

h, n = map(int, raw_input().split())
a = np.zeros(n, dtype=int)
b = np.zeros(n, dtype=int)
for i in range(n):
    a[i], b[i] = map(int, raw_input().split())
dp = np.zeros(10001, dtype=int)
for i in range(1, 10001):
    dp[i] = (dp[i - a] + b).min()
print(dp[h])


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

void push(int x);
int pop(void);

int top=0;
int S[100];

int main(){
    int x;
    char s[100];
    
    while(scanf("%s",s) != EOF){
        if(s[0] == '+'){
            push(pop() + pop());
        }
        else if(s[0] == '-'){
            x = pop();
         push(pop() - x);   
        } 
        else if(s[0] == '*'){
            push(pop() * pop());
        }
        else{
            x = atoi(s);
            push(x);
        }
}
printf("%d\n",pop());

return 0;
}

void push(int x){
    top++;
    S[top] = x;
}

int pop(void){
    top--;
    return S[top+1];
}



Measured memory_bytes: 2108
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);

  auto m = n, s = 0;
  while (m > 0) {
    s += m%10;
    m /= 10;
  }

  writeln(n%s == 0 ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using std::vector;
using std::min;
const int INF = 1e9 + 5;
int main(){
  int n ,k;
  scanf("%d",&n);
  scanf("%d",&k);
  vector<int> h(n);
  for(int &x : h) {scanf("%d",&x);}
  vector<int> dp(n,INF);
  dp[0] = 0;
  for(int i = 0 ; i < n;++i) {
    for(int j=i+1; j <=i+k ; ++j ){
      if(j < n){
        dp[j] = min( dp[j] , dp[i] + abs( h[i]-h[j] ));
      }
    }
  }

  printf( "%d", dp[n-1]);
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
const int MaxN=100010,inf=1<<30;
int N;
struct edge{int to,cap;edge*rev,*next;}E[MaxN*8],*ne=E,*fir[MaxN*2],*cur[MaxN*2];
void link(int a,int b,int c){
	*ne=(edge){b,c,ne+1,fir[a]};fir[a]=ne++;
	*ne=(edge){a,0,ne-1,fir[b]};fir[b]=ne++;
}
int Q[MaxN*2],D[MaxN*2];
int dfs(int i,int c){
	if(i==1||!c)return c;
	int fl=0,f;
	for(edge*&e=cur[i];e&&c;e=e->next)
		if(e->cap&&D[e->to]==D[i]-1&&(f=dfs(e->to,c<e->cap?c:e->cap)))
			fl+=f,e->cap-=f,e->rev->cap+=f,c-=f;
	return fl;
}
int u[MaxN],v[MaxN];
int mf(){
	for(int f=0;;f+=dfs(0,inf)){
		for(int i=0;i<=N*2;i++)D[i]=0,cur[i]=fir[i];
		for(int*h=Q,*t=Q+(D[*h=1]=1);h<t;h++)
			for(edge*e=fir[*h];e;e=e->next)
				if(e->rev->cap&&!D[e->to]){
					D[*t++=e->to]=D[*h]+1;
					if(f==N-1)*h<=N?u[*h]=e->to-N:v[e->to]=*h-N;
				} 
		if(!*D)return f;
	}
}
int main(){
	scanf("%d",&N);
	for(int i=2;i<=N;i++){
		int c,w;
		scanf("%d",&c);
		link(0,i,1);
		while(c--)scanf("%d",&w),link(i,N+w,inf);
	}
	for(int i=N+1;i<=N*2;i++)link(i,1,1);
	if(mf()<N-1)return puts("-1"),0;
	for(int i=2;i<=N;i++)if(!D[i])return puts("-1"),0;
	for(int i=2;i<=N;i++)printf("%d %d\n",u[i],v[i]);
}

Measured memory_bytes: 25984
# ABC137 C

def resolve():
    n = int(input())
    table = {}
    for _ in range(n):
        s = input()
        arr = [c for c in s]
        arr.sort()
        ss = "".join(arr)
        if ss in table:
            table[ss] += 1
        else:
            table[ss] = 1

    ans = 0
    for k, v in table.items():
        if v > 1:
            ans += int((v * (v-1)) // 2)
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 17892
N,L = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
cmax = 0
ind = -1
for i in range(1,N):
    if A[i]+A[i+1]>cmax:
        cmax = A[i]+A[i+1]
        ind = i
if cmax>=L:
    print("Possible")
    for i in range(1,ind):
        print(i)
    for i in range(N-1,ind-1,-1):
        print(i)
else:
    print("Impossible")

Measured memory_bytes: 86000
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf=1e18;

struct edge{
	int to,cst;
};

vector<vector<edge>> g;
vector<int> d;

void add_edge(int a,int b,int c){
	g[a].push_back(edge({b,c}));
	g[b].push_back(edge({a,c}));
};



void calc_d(int cur,int pre){
	for(auto&& w:g[cur]){
		if(w.to!=pre){
			d[w.to]=d[cur]+w.cst;
				calc_d(w.to,cur);
		}
    }
};

signed main(){
	int n;cin>>n;
	g.resize(n);
	for(int i=0;i<n-1;i++){
		int a,b,c;cin>>a>>b>>c;a--;b--;
		add_edge(a,b,c);
	}
//	for(int i=0;i<n;i++){
//	cerr<<i+1<<" ";
//	for(auto&& w:g[i])cerr<<w.to+1<<" ";
//    cerr<<endl;
//	}
//	cerr<<endl;

	int q,k;cin>>q>>k;k--;
	d.resize(n,-1);
	d[k]=0;
	calc_d(k,-1);
//	for(auto&& w:d)cerr<<w<<" "<<endl;
//	cerr<<endl;
	for(int i=0;i<q;i++){
		int x,y;cin>>x>>y;x--;y--;
		cout<<d[x]+d[y]<<endl;
	}	
}

Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> t;

int main(){
  int N, M;
  long long p, cnt;
  long long ans;

  cin >> N >> M;
  t.push_back(0);
  for(int i = 0; i < N; ++i){
    int a;
    cin >> a;
    t.push_back((t.back() + a) % M);
  }
  sort(t.begin(), t.end());
  t.push_back(-1);
  ans = 0;
  cnt = 0;
  for(int i = 1; i < t.size(); ++i){
    if(t[i] == t[i - 1]){
      ++cnt;
    }else{
      if(cnt > 0){
        ans += cnt * (cnt + 1) / 2;
        cnt = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
#include<iostream>
using namespace std;
#define MAX 1000
#define LIMIT 13
 
bool state[MAX+1];
int ans[MAX+1], target;
 
void dfs(int depth, int pre, int maxv ){
  if ( pre == target ){
    ans[target] = min( ans[target], depth );
    return;
  }
  if ( depth >= ans[target] ) return;
 
  int next, d = 0, p = maxv;
 
  while( p < target ){d++; p *= 2;}
  if ( depth + d >= ans[target] ) return;
 
  for ( int i = 1; i <= maxv; i++ ){
    if ( !state[i] ) continue;
    next = pre + i;
    if ( next <= MAX && !state[next] ){
      state[next] = true;
      dfs(depth+1, next, max(maxv, next));
      state[next] = false;
    }
    next = ( pre > i ) ? ( pre - i ) : (i - pre);
    if ( !state[next] ){
      state[next] = true;
      dfs(depth+1, next, max(maxv, next));
      state[next] = false;
    }
  }
}
 
main(){
  for ( int i = 0; i <= MAX+1; i++ ) ans[i] = LIMIT;
  while(cin >> target && target){
    for ( int i = 0; i <= MAX+1; i++ ) state[i] = false;
    state[1] = true;
    dfs(0, 1, 1);
    cout << ans[target] << endl;
  }
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 500000;

int heap[MAX+1], h;

int buildHeap(int k){
  int left = 2*k, right = 2*k+1,large = 0;
  if  (right <= h && heap[left] < heap[right]){
    large = right;
  }else if (left <= h){
    large = left;
  }

  if (heap[k] < heap[large] && large != 0){
    swap(heap[k],heap[large]);
    buildHeap(large);
  }


}

int main(void){
  cin >> h;

  for (int i = 1; i<h+1; i++) cin >> heap[i];
  for (int i = h/2; i >= 1; i--) buildHeap(i);

  for (int i = 1; i<h+1; i++) cout << " " << heap[i];
  cout << endl;

  return 0;
}

Measured memory_bytes: 3116
#include<cstdio>
using namespace std;
int main()
{
	int i,cnt;
	char s[3],t[3];
	scanf("%s",s);
	scanf("%s",t);
	cnt=0;
	for(i=0;i<3;i++){
		if(s[i]==t[i]){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int cal(string str){
    int sum=0;
    stack<char> c;
    c.push('e');
    for(int i=0;i<str.size();i++){
        c.push(str[i]);
    }
    while(c.size()!=1){
        //cout<<c.size()<<endl;
        if(c.top()=='i' || c.top()=='x' || c.top()=='c' || c.top()=='m'){
            char tmp=c.top();
            c.pop();
            int tmp2=1;
            for(char j='2';j<='9';j++){
                if(j==c.top()){
                    tmp2=j-'0';
                    c.pop();
                    break;
                }
            }
            if(tmp=='i'){
                sum+=tmp2*1;
            }
            else if(tmp=='x'){
                sum+=tmp2*10;
            }
            else if(tmp=='c'){
                sum+=tmp2*100;
            }
            else if(tmp=='m'){
                sum+=tmp2*1000;
            }
        }
    }
    return sum;
}

void cal2(int a,int b){
    int sum=a+b;
    vector<char> ans;
    if(sum/1000>1) cout<<sum/1000<<"m";
    if(sum/1000==1) cout<<"m";
    sum%=1000;
    if(sum/100>1) cout<<sum/100<<"c";
    if(sum/100==1) cout<<"c";
    sum%=100;
    if(sum/10>1) cout<<sum/10<<"x";
    if(sum/10==1) cout<<"x";
    sum%=10;
    if(sum>1) cout<<sum<<"i";
    if(sum==1) cout<<"i";
    cout<<endl;
    return ;
}
int main(){
    int n;
    cin>>n;
    string mcxl1,mcxl2;
    for(int i=0;i<n;i++){
        cin>>mcxl1>>mcxl2;
        //cout<<cal(mcxl1)<<" "<<cal(mcxl2)<<endl;
        cal2(cal(mcxl1),cal(mcxl2));
    }
    return 0;
}





Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include<limits.h>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace  std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
// #define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
const int LIM = 1e5+5, MOD =  1e9;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); }
ll mod=1e9+7;
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }

ll fact[200004];
void compfact ()
{
	fact[0]=1;
	for (ll i=1;i<=200002;i++)
		fact[i]=(fact[i-1]%mod*i%mod)%mod;
}
vp64 v;
ll dp[2002][2002];

void solve (ll ind,ll l , ll r)
{
	if (dp[l][r]!=-1)
		return;
	else if (l>r)
		return;
	else if (l==r)
	{
		dp[l][r]=v[ind].fi*abs(v[ind].se-l);
	}
	else
	{
		solve(ind+1,l+1,r);
		solve(ind+1,l,r-1);
		dp[l][r]=max(dp[l][r],dp[l+1][r]+v[ind].fi*abs(v[ind].se-l));
		dp[l][r]=max(dp[l][r],dp[l][r-1]+v[ind].fi*abs(v[ind].se-r));

	}

}
int main()
{
	fast;
	ll n,m;
	cin>>n>>m;
	priority_queue <ll> q;
	for (ll i=0;i<n;i++)
	{
		ll x;
		cin>>x;
		q.push(x);
	}
	while (!q.empty()&&m)
	{
		ll temp=q.top();
		q.pop();
		m--;
		q.push(temp/2);
	}
	ll ans=0;
	while (!q.empty())
	{
		ans+=(q.top());
		q.pop();
	}
	cout<<ans;

}

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

int main()
{
	int a, b;
	int x = 0,ans=0;
	cin >> a >> b;

	for (int i = 0; i < 2; i++) {
		if (a > b) {
			x = a;
			a--;
		}
		else {
			x = b;
			b--;
		}
		ans += x;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    int a, b, c; cin >> a >> b >> c;
    if((c - a) * (b - c) > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



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

template <typename T>
auto make_vector(size_t sz, T t) {
  return std::vector<T>(sz, t);
}
template <size_t N, typename T, typename U, std::enable_if_t<
  N == 1, std::nullptr_t> = nullptr>
auto make_higher_vector(size_t sz, U u) {
  return make_vector(sz, T(u));
}
template <size_t N, typename T, std::enable_if_t<
  N == 1, std::nullptr_t> = nullptr>
auto make_higher_vector(size_t sz) {
  return std::vector<T>(sz);
}
template <size_t N, typename T, typename... Args, std::enable_if_t<
  N != 1, std::nullptr_t> = nullptr>
auto make_higher_vector(size_t a, Args... args) {
  return make_vector(a, make_higher_vector<N - 1, T>(args...));
}
template <typename T, typename Size_t>
auto& at(T& t, Size_t i) {
  return t.at(i);
}
template <typename T, typename Size_t, typename... Args>
auto& at(T& t, Size_t i, Args... args) {
  return at(t.at(i), args...);
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; long long k; std::cin >> n >> k;
  std::vector<int> a(n);
  for (auto& x : a) {std::cin >> x; x--;}
  constexpr int max = 2e5;
  auto m = make_higher_vector<2, int>(max, 0);
  for (int i = 0; i < n; i++) {
    m.at(a.at(i)).push_back(i);
  }
  constexpr int lg = 64;
  auto table = make_higher_vector<2, long long>(lg, n);
  for (auto& v : m) {
    if (v.empty()) continue;
    int sz = v.size();
    v.push_back(n + v.front());
    for (int i = 0; i < sz; i++) {
      auto crr = v.at(i), nxt = v.at(i + 1);
      assert(0 <= crr && crr < n && crr < nxt);
      at(table, 0, crr) = nxt - crr + 1;
    }
  }
  constexpr long long inf = 3e17;
  for (int i = 0; i < lg - 1; i++) {
    auto& crr = table.at(i);
    auto& nxt = table.at(i + 1);
    for (int j = 0; j < n; j++) {
      auto a = crr.at(j);           if (a == inf) nxt.at(j) = inf;
      auto b = crr.at((j + a) % n); if (b == inf) nxt.at(j) = inf;
      nxt.at(j) = std::min(inf, a + b);
    }
  }
  auto moved = [&] (auto i, auto x) {
    return x + at(table, i, x % n);
  };
  long long crr = 0, goal = n * k;
  for (int i = lg - 1; i >= 0; i--) {
    auto nxt = moved(i, crr);
    if (nxt < goal) crr = nxt;
  }
  std::vector<int> ans;
  while (crr < goal) {
    auto nxt = moved(0, crr);
    if (nxt <= goal) {
      crr = nxt;
      continue;
    }
    ans.push_back(a.at((crr++ % n)));
  }
  int sz = ans.size();
  for (int i = 0; i < sz; i++) {
    std::cout << (i > 0 ? " " : "") << ans.at(i) + 1;
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 115172
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

  
int main() {
	
	while (1) {
		int x; cin >> x;


		if (x == 0)break;

		
		int cnt = 0;
		for (int i = 1; i < x; i++) {
			int sum = 0;
			for (int j = i; j <= x; j++) {
				sum += j;
				if (sum == x) {
					cnt++;
				}
			}

			
		}

		cout << cnt << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3108
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args) throws java.lang.Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		while(line!=null&&!"0".equals(line)){
			int cnt = Integer.parseInt(line);
			Dice dice = new Dice();
			for(int i=0;i<cnt;i++){
				line = br.readLine();
				dice.move(line);
			}
			System.out.println(dice.getAns());
			line = br.readLine();
		}
	}
	
	public static class Dice{
		int top,south,east,west,north,down;
		int topSum=1;
		Dice(){
			top=1;
			south=2;
			east=3;
			west=4;
			north=5;
			down=6;
		}
		public int getAns(){
			return topSum;
		}
		void move(String move){
			int tmp;
			if("North".equals(move)){
				tmp = top;
				top   = south;
				south = down;
				down  = north;
				north = tmp;
			}else if("East".equals(move)){
				tmp = top;
				top  = west;
				west = down;
				down = east;
				east = tmp;
			}else if("West".equals(move)){
				tmp = top;
				top  = east;
				east = down;
				down = west;
				west = tmp;
			}else if("South".equals(move)){
				tmp = top;
				top  = north;
				north = down;
				down = south;
				south = tmp;
			}else if("Right".equals(move)){
				tmp = south;
				south  = east;
				east = north;
				north = west;
				west = tmp;
			}else if("Left".equals(move)){
				tmp = south;
				south  = west;
				west = north;
				north = east;
				east = tmp;
			}
			topSum+=top;
		}
		
		
	}
}

Measured memory_bytes: 25344
import sys
input=sys.stdin.readline
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())
 
def ss_raw():
    return input().split()
 
def ints_raw():
    return tuple(map(int, ss_raw()))

def main():
    N,M = ints_raw()
    SS =[0]*(N+1)
    for midx in range(M):
        ks = ints_raw()
        for j in ks[1:]:
            SS[j-1] += 1<<midx
    p = 0
    pis = ints_raw()
    for midx in range(M):
        pi = pis[midx]
        if pi>=2:
            return 0
        if pi ==1:
            p+=1<<midx
    ans = 0
    for dbit in range(2**N):
        tmp = 0
        for j in range(N):
            if (dbit & (1<<j)):
                tmp = tmp^SS[j]
        if tmp == p:
            ans+=1
    return ans

print(main())


Measured memory_bytes: 41072
a=[]
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
a=a1+a2+a3
n = int(input())
numlist=set(a)
# print(numlist)
for i in range(n):
    b = int(input())
    if b in numlist:
        for j in range(len(a)):
            if a[j]==b:
                a[j]=0
                break
# print(a)
flag=False
if a[0]==0:
    if a[3]==0 and a[6]==0:
        flag=True
    elif a[1]==0 and a[2]==0:
        flag=True
    elif a[4]==0 and a[8]==0:
        flag=True
elif a[4]==0:
    if a[3] ==0 and a[5]==0:
        flag=True
    if a[1]==0 and a[7]==0:
        flag=True
    if a[6]==0 and a[2]==0:
        flag=True
elif a[8]==0:
    if a[2]==0 and a[5]==0:
        flag=True
    if a[1]==0 and a[2]==0:
        flag=True
    
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
import math

params0 = list(map(lambda x: int(x), input().split(' ')))
paramA = params0[0]
paramB = params0[1]
paramN = params0[2]

a = 0
if paramN > paramB - 1:
    a = paramB - 1
else:
    a = paramN

print(math.floor(paramA * a / paramB) - (paramA * math.floor(a / paramB)))

Measured memory_bytes: 9188
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let _n = get!(usize);
    let aa = get!(String).split_whitespace().map(|t| t.parse::<i32>().unwrap()).collect::<Vec<_>>();

    let mut r = 1000000000;
    for i in -100..101 {
        let mut rr = 0;
        for a in aa.iter() {
            rr += (a - i).abs().pow(2);
        }
        r = if r > rr { rr } else { r };
    }

    println!("{}", r);
}

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

int s[100001];
int main() {
	int n; scanf("%d", &n);
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		int a; scanf("%d", &a);
		if (s[a] == i)cnt++;
		s[i] = a;
	}
	printf("%d\n", cnt);
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    int n, x[128], sum, avl, min;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> x[i];
    }
    sum = 0;
    for (int i = 0; i < n; i++){
        sum += x[i];
    }
    avl = sum / n;sum = 0;
    for (int i = 0; i < n; i++){
        sum += (x[i] - avl) * (x[i] - avl);
    }
    min = sum;sum = 0;avl++;
    for (int i = 0; i < n; i++){
        sum += (x[i] - avl) * (x[i] - avl);
    }
    if (min > sum){
        min = sum;
    }
    cout << min;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[200005];
int b[200005];
int main(void)
{
    int n,mx1,mx2;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    mx1=b[n-1];
    mx2=b[n-2];
    for(int i=0;i<n;i++)
    {
        if(a[i]==mx1)
            cout << mx2 << '\n';
        else cout << mx1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++)
struct P{int x,y;P(){}P(int a,int b){x = a , y = b;}};
int operator -(P a, P b){
	return abs(a.x - b.x) + abs(a.y - b.y);
}
int dp[1<<5][5][1000];
#define INF (1<<21)
int main(){	
	int W,H;
	while(cin >> W >> H , W){
		P s , g ;
		vector<P> v[6];
		rep(i,H)rep(j,W){
			char c; cin >> c;
			if(c == 'S') s = P(j,i);
			else if(c == 'G') g = P(j,i);
			else if(c != '.') v[c-'1'].push_back(P(j,i));
		}
		rep(i,1<<5)rep(k,5)rep(j,1000)dp[i][k][j] = INF;
		rep(i,5)rep(j,v[(i+1)%5].size()){
			dp[(1<<i) | (1<<((i+1)%5))][(i+1)%5][j] = s - v[(i+1)%5][j];
		}
		rep(bit,(1<<5)-1)rep(x,5){
			int y = (x+1)%5;
			rep(i,v[x].size()){
				if( dp[bit][x][i] == INF ) continue;
				rep(j,v[y].size()){
					dp[bit|(1<<y)][y][j] = min( dp[bit|(1<<y)][y][j] , dp[bit][x][i] + (v[x][i]-v[y][j]) );
				}
			}
		}
		int ans = INF , cho = -1;
		rep(i,5) rep( j , v[i].size() ){
			int cst = dp[(1<<5)-1][i][j] + (g - v[i][j]);
			int w = (i+1)%5;
			if(ans >= cst){
				if(ans == cst){
					cho = min(cho, w );
				}else{
					cho = w;
					ans = cst;
				}
			}
		}
		if(ans == INF) cout << "NA" << endl;
		else cout << cho+1 << " " << ans << endl;
		
		
	}
	
}

Measured memory_bytes: 1592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>
#define Matd vector<vector<ld>>
#define Arrd vector<ld>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m;
    cin >> n >> m;
    Arr a(n), b(n);
    forn(i, n) cin >> b[i] >> a[i], b[i] = m - b[i];
    ll ans = 0;
    vector<vector<ll>> s(2e5);
    forn(i, n)
    {
        if (b[i] >= 0)
            s[b[i]].push_back(a[i]);
    }
    forn(i, 2e5) sort(allele(s[i]), greater<ll>());
    priority_queue<ll> pq;
    forr(i, 2e5 - 1, 0)
    {
        for (ll ovpfsa : s[i])
            pq.push(ovpfsa);
        if (!pq.empty())
            ans += pq.top(), pq.pop();
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define int long long
#define pb push_back
#define mod 1000000007



int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int> arr(n);
    for(auto &x:arr)
        cin>>x;
    // int ans=0;
    // stack<int> st;
    multiset<int> st;
    // st.push(-1);
    // st.clear();
    int ans=0;
    for(auto x:arr)
    {
        if(st.empty())
        {
            st.insert(x);
            continue;
        }
        auto it=st.lower_bound(x);
        if(it==st.begin())
        {
            st.insert(x);
            continue;
        }
        it--;
        st.erase(it);
        st.insert(x);
       // ans=max(ans, (int)st.size());
    }
    // if(st.size())
    //     ans++;
    cout<<st.size();
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;
struct ssss{
  int64_t s1;
  int64_t s2;
  int64_t s3;
  int64_t s4;
};
int64_t func(int64_t x){
  int64_t k = (x+1)/2;
  if(x % 2 == 1){
    return k % 2;
  }else{
    return (k % 2)^x;
  }
}

int main(){
  int64_t a,b;
  cin >> a >> b;
  cout << (func(max(0L,a-1))^func(b)) << endl;
  
  
          
        
}

Measured memory_bytes: 256
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();
        int b = sc.nextInt();
        if (b - a <= 0) {
            System.out.println("delicious");
        } else if (b - a <= x) {
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }
    }
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int K;
    string S;
    cin >> K;
    cin >> S;
    if (S.size() <= K)
    {
        cout << S << endl;
    }else
    {
        for (int i = 0; i < K; i++)
        {
            cout << S[i];
        }
        cout << "..." << endl;
    }
    
    return 0;

}

Measured memory_bytes: 3124
#include <iostream>
#include <complex>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>
#include <map>

using namespace std;

int main() {
    map<int, int> solved;
    map<int, bool> rank;
    while(1) {
        int no, ac;
        scanf("%d,%d", &no, &ac);
        if (no == 0)break;
        solved[no] = ac;
        rank[ac] = true;
    }
    int no;
    while(scanf("%d", &no) != EOF) {
        int res = 1;
        for (int i = 30; i > solved[no]; i--) {
            if (rank[i])res++;
        }
        cout << res << endl;
    }
    return 0;
}

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

int main(){
	string s;
	cin >> s;
	int n = s.size();
	bool ok = true;
	for (int i = 0; i < n /2 ; ++i) {
		if(s[i] != s[n-1-i]) ok = false;
	}
	
	for (int i = 0; i < (n-1)/2; ++i) {
		if(s[i] != s[(n-1)/2-1-i]) ok = false;
	}
	
	for (int i = (n+3)/2-1; i < n; ++i) {
		if(s[i] != s[n-1-i]) ok = false;
	}
	
	if(ok){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

ll t0;
int f0;

struct Graph {
    struct Vertex { int n; };
    struct Edge { int i, n, k; };
    Graph(int n, int m) : v(n, { -1 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j, int k) {
        e[m] = { j, v[i].n, k };
        v[i].n = m;
        m++;
    }
    void dfs(int i, int g, int p) {
        if (i == g) {
            f0 = 1;
            return;
        }
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge &o = e[j];
            if (o.i == p) continue;
            dfs(o.i, g, i);
            if (f0) {
                t0 ^= 1LL << o.k;
                break;
            }
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    Graph g(n, (n - 1) * 2);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b, i);
        g.add_edge(b, a, i);
    }

    int m;
    cin >> m;
    vector<ll> x(m);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;

        t0 = 0; f0 = 0;
        g.dfs(u, v, -1);
        x[i] = t0;
        //cout << x[i] << endl;
    }

    ll r = 0;
    for (int k = 1; k < 1 << m; k++) {
        ll e = 0;
        int c = 0;
        for (int i = 0; i < m; i++) {
            int t = k >> i & 1;
            c += t;
            if (t) {
                e |= x[i];
            }
        }
        ll sgn = c % 2 == 0 ? -1 : 1;
        
        int d = 0;
        for (int i = 0; i < n - 1; i++) {
            int t = e >> i & 1;
            d += t;
        }

        d = (n - 1) - d;
        r += sgn << d;
    }

    r = (1LL << (n - 1)) - r;
    cout << r << endl;

    //否定 1個でも全部白なパスがある
    //パスをビットで表す 条件は2^20通り 残りの辺がいくつあるか

    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    
    if (x <= K - x) {
      sum += x * 2;
    }
    else {
      sum += (K - x) * 2;
    }
  }
  cout << sum << endl;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    string str1 = "", str2 = "";
    for (int i = 0; i < b; i++) {
        str1 += to_string(a);
    }
    for (int i = 0; i < a; i++) {
        str2 += to_string(b);
    }
    if (str1 > str2) cout << str2 << endl;
    else cout << str1 << endl;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

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

  ll maxa = -1;
  for (int i = 0; i < 5; ++i) {
    maxa = max(maxa, (ll)ceil(N/a[i]));
  }

  cout << 4+maxa << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string str,S[3]={"Sunny","Cloudy","Rainy"};
  cin >> str;
  for(int i=0;i<3;i++){
    if(str==S[i])cout << S[(i+1)%3] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define MAX_N 100
#define MAX_M (MAX_N * MAX_N)
 
typedef struct EDGE {
    int to;
    struct EDGE *next;
} edge;
 
int size;
edge buff[MAX_M];
edge *adj[MAX_N];
 
void add_edge(int u, int v) {
    edge *e = buff + size++;
    e->to = v;
    e->next = adj[u];
    adj[u] = e;
}
 
int t;
int d[MAX_N];
int f[MAX_N];
 
void dfs(int u) {
    edge *e;
    d[u] = t++;
    for(e = adj[u]; e != NULL; e = e->next) {
        if(d[e->to] == 0) dfs(e->to);
    }
    f[u] = t++;
}
 
int main() {
    int n;
    int u, k;
    int i, j;
    int v[MAX_N];
 
    scanf("%d", &n);
    for(i = 0; i < n; ++i) {
        scanf("%d %d", &u, &k);
        for(j = 0; j < k; ++j) {
            scanf("%d", v + j);
        }
        for(j = k - 1; j >= 0; --j) {
            add_edge(u - 1, v[j] - 1);
        }
    }
 
    t = 1;
    for(u = 0; u < n; ++u) {
        if(d[u] == 0) dfs(u);
        printf("%d %d %d\n", u + 1, d[u], f[u]);
    }
 
    return EXIT_SUCCESS;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  int total = 0;
  rep(i, N) total += A[i];
  int cnt = 0;
  rep(i, N) {
    if (A[i] * 4 * M >= total) cnt++;
  }
  bool bl = cnt >= M;
  puts(bl ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, L;
    cin >> n >> L;

    vector<string> v;
    rep(i, n) {
        string s;
        cin >> s;
        v.pb(s);
    }
    sort(all(v));

    for(auto s : v) {
        cout << s;
    }
    
    cout << endl;
    re0;
}

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

int main(){
	int n, p;
	int stone[55];
	long long int count = 0;
	while(cin >> n >> p, n){
		fill(stone, stone+50, 0);
		for(count = 0; ; count++){
			if(p != 0){
				if(p == 1){
					bool isExist = false;
					for(int i=0; i < n; i++){
						if(i == count%n) continue;
						else if(stone[i] != 0) isExist = true;
					}
					if(!isExist) break;
				}
				stone[count%n]++;
				p--;
			}else{
				p += stone[count%n];
				stone[count%n] = 0;
			}
		}
		cout << count%n << endl;
	}
}

Measured memory_bytes: 1156
import std.stdio,  std.string,  std.conv,  std.ascii,  std.array;

void main()
{
    foreach(_; 0 .. readln.chomp.to!int)
    {
        line = readln.chomp;
        add.writeln;

    }
}

string line;

int add()
{
    int lhs  =  mul;
    loop:
    while(true)
    {
        switch(line[0])
        {
            case '+':
                line.popFront;
                lhs += mul;
                break;
            case '-':
                line.popFront;
                lhs -= mul;
                break;
            default:
                break loop;
        }
    }
    return lhs;
}

int mul()
{
    int lhs = prim;
    loop:
    while(true)
    {
        switch(line[0])
        {
            case '*':
                line.popFront;
                lhs *= prim;
                break;
            case '/':
                line.popFront;
                lhs /= prim;
                break;
            default:
                break loop;
        }
    }
    return lhs;
}

int prim()
{
    int r;
    if(line[0] == '(')
    {
        line.popFront;
        r = add;
        line.popFront;
    }
    else if(line[0] == '-')
    {
        line.popFront;
        r = -mul;

    }
    else while(line[0] != '=')
    {
        if(line[0].isDigit)
        {
            r  =  r * 10 + (line[0] - '0');
            line.popFront;
        } 
        else break;
    }
    return r;
}

Measured memory_bytes: 1044
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
typedef long long LL;
const LL N=1000;
inline int read()
{
    int x=0,t=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-') t=-1,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return x*t;
}
int n,m;
int p[1005];
int c[1005];
int d[1<<16];
int main()
{
	memset(d,0x3f,sizeof d);
	n=read(),m=read();
	for(register int i=1;i<=m;i++)
	{
		p[i]=read();
		int k,v;
		k=read();
		for(register int j=1;j<=k;j++)
		{
			v=read();
			c[i] |= 1<<(v-1);
		}
	}
	int Max=d[1];
	d[0]=0;
	for(register int s=0;s<(1<<n);s++)
		for(register int i=1;i<=m;i++)
			if(d[s]!=Max)
				d[s|c[i]]=min(d[s|c[i]],d[s]+p[i]);
	if(d[(1<<n)-1]!=Max) printf("%d\n",d[(1<<n)-1]);
	else printf("-1\n");
	return 0;
}

Measured memory_bytes: 512