akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

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

    cout << N * 800 - 200 * (N / 15) << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

n = int(input())

graph = [[] for _ in range(n)]
d = [[float("inf")]*n for i in range(n)]

for i in range(n):
    s = input()
    for j, sj in enumerate(s):
        d[i][i] = 1
        if sj == '1':
            graph[i].append(j)
            d[i][j] = 1
            d[j][i] = 1

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

#2部グラフならTrue, そうでなければFalse
def is_bipartite():
    stack = [(0,1)] # (頂点、色)のタプルをスタックする。最初は(頂点0, 黒(1))
    while stack:
        #スタックから最後に追加された(頂点, 色)をpop
        v,color = stack.pop()
        #今いる点を着色
        colors[v] = color
        #今の頂点から行けるところをチェック
        for to in graph[v]:
            #同じ色が隣接してしまったらFalse
            if colors[to] == color:
                return False
            #未着色の頂点があったら反転した色と共にスタックに積む
            if colors[to] == 0:
                stack.append((to, -color))
    #調べ終わったら矛盾がないのでTrue
    return True

# ワーシャルフロイド法
# 全頂点間最短路
# d[i][j]は2頂点間i, j間の移動コストを格納, Mは頂点数

def warshall_floyd(d, M):
    for k in range(M):
        for i in range(M):
            for j in range(M):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    return d #d[i][j]に頂点i, j間の最短距離を格納

##############################


if is_bipartite():
    ret = 0
    for a in warshall_floyd(d,n):
        ret = max(ret, max(a))
    print(ret+1)
else:
    print(-1)


Measured memory_bytes: 74628
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

class Point {
	int x;
	int y;
	Point(int a,int b){
		x = a;
		y = b;
	}
}

class MyComparator implements Comparator<Point> {
	public int compare(Point p1,Point p2) {
		if(p1.x > p2.x) {
			return 1;
		}else if(p1.x == p2.x && p1.y > p2.y) {
			return 1;
		}else {
			return -1;
		}
	}
}

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Point> L = new ArrayList<>();
		
		
		for(int i=0;i<n;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			Point p = new Point(a,b);
			L.add(p);
			
		}
		Collections.sort(L,new MyComparator());
		
		for(int i=0;i<L.size();i++) {
			System.out.println(L.get(i).x + " " + L.get(i).y);
		}
	}
}


Measured memory_bytes: 112652
from itertools import product
H, W, K = map(int, input().split())
black = 0
C = []
for _ in range(H):
    s = input()
    black += s.count("#")
    C.append(s)

ans = 0
row = tuple(product(range(2), repeat=H))
col = tuple(product(range(2), repeat=W))

for r in row:
    for c in col:
        cnt = 0
        for i in range(H):
            for j in range(W):
                if r[i] or c[j]:
                    cnt += int(C[i][j] == "#")
        if black - cnt == K:
            ans += 1

print(ans)

Measured memory_bytes: 9220
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
#define MOD 1000000007
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const LL INF = 1LL << 60;

int main(void) {
	
	LL S;
	cin >> S;

	LL x2 = 1000000000LL;
	LL y3 = (((S)+(x2)-1) / (x2));
	LL x3 = x2 * y3 - S;

	cout << 0 << " ";//x1
	cout << 0 << " ";//y1
	cout << x2 << " ";//x2
	cout << 1 << " ";//y2
	cout << x3 << " ";//x3
	cout << y3 << endl;//y3

	return 0;
}


Measured memory_bytes: 256
N = int(input())
isopen = [list(map(int,input().split())) for i in range(N)]
gain = [list(map(int,input().split())) for i in range(N)]
 
ans = -float('inf')
for i in range(1,2**10):
    tmp = 0
    for n in range(N):
        c = 0
        for b in range(10):
            if (i >> b) & isopen[n][b]:
                c += 1
        tmp += gain[n][c]
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, functools, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = inf ; count = 0; pro = 1

n=int(input())
count=0
# @functools.lru_cache(maxsize=None)
memo=[0]*(n+1)
memo[0]=0
def func(n):
    if memo[n] or n==0:return memo[n]
    # print(n)
    # global count
    # count+=1
    # if count%10==0:print(count)
    if n==0:
        return 0
    re=inf
    k=s=1
    while 6**k<=n:
      re=min(re,func(n-6**k)+1)
      k+=1
    while 9**s<=n:
      re=min(re,func(n-9**s)+1)
      s+=1

    re=min(re,func(n-1)+1)
    memo[n]=re
    return re
    
print(func(n))
# print(memo)



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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,m,q;  cin >> n >> m >> q;
  vector<int> v[501];
  for(int i = 0; i < m; ++i){
    int l,r; cin >> l >> r;
    v[r].push_back(l);
  }
  vector<P<int,int>> qry[501];
  for(int i = 0; i < q; ++i){
    int l,r; cin >> l >> r;
    qry[r].emplace_back(l,i);
  }
  vector<int> ans(q);
  vector<int> fnd;
  fnd.reserve(m);
  for(int i = 0; i <= n; ++i){
    for(auto e:v[i])
      fnd.insert(upper_bound(fnd.begin(),fnd.end(),e),e);
    for(auto e:qry[i]){
      ans[e.second] = distance(lower_bound(fnd.begin(),fnd.end(),e.first),fnd.end());
    }
  }
  for(auto e:ans)cout << e << endl;
}


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

#define fori(i,a,b)    for(int i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(c,x)       ((c).find(x) != (c).end())
#define isp(c,x)      (find(all(c),x) != (c).end())
#define pb             push_back
#define ppb            pop_back
#define sz(x)          (int)x.size()
#define fill(a,v)      memset(a, v, sizeof a)
#define fs first
#define sc second
#define ub upper_bound
#define lb lower_bound
#define en '\n'

typedef long long int lli;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair< int, int > pii;
typedef pair< lli, lli > plli;
typedef list<int> li;
typedef map<int, int> mi;
typedef map<lli, lli> mlli;
lli gcd(lli a,lli b){return (!b)?a:gcd(b,a%b);}
int t = 1; int ti;


lli md = 1e9 + 7;
const int N = 1e5 + 3;
lli n, mem[N][2];
li adj[N];

lli dfs(int s, int c, int p){
    if(mem[s][c] != -1)
    return mem[s][c];


    int ff = 0;
    lli ans = 1;

    for(auto x:adj[s]){
        if(x != p){
            ff = 1;

            if(c == 0){
                ans *= (dfs(x, 0, s) + dfs(x, 1, s));
                ans %= md;
            } else {
                ans *= dfs(x, 0, s);
                ans %= md;
            }
        }
    }


    if(!ff){
        return 1;
    }

    return mem[s][c] = ans;
}


void solve(){
    cin>>n;

    fill(mem, -1);

    fori(i, 1, n-1){
        int x, y; cin>>x>>y;

        adj[x].pb(y);
        adj[y].pb(x);
    }    

    lli ans = 0;
    ans += dfs(1, 0, -1);
    ans %= md;

    ans += dfs(1, 1, -1);
    ans %= md;

    cout<<ans;
}
//THINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL

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

    // cin>>t;

    // for(ti= 1; ti <= t; ti++)
    solve();

//    cout<<"\nTHINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL";
}

Measured memory_bytes: 18048
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

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

	int n,m;
	cin>>n>>m;
	vi in(n);
	rep(i,n)cin>>in[i];
	int out=0;
	int use=0;
	for(int i=50;i>=0;i--){
		int c=0;
		rep(j,n)if(1ll<<i&in[j])c++;
		if(c<n-c&&use+(1ll<<i)<=m){
			c=n-c;
			use+=1ll<<i;
		}
		out+=c*(1ll<<i);
	}
	cout<<out<<endl;
}
/*
001
110
011

*/





Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n,m,count = 0;
    cin >> n >> m;

    vector<int>v(m,0);

    for(int i = 0;i < n;i++){
        int k;
        cin >> k;
        for(int j = 0;j < k;j++){
            int num;
            cin >> num;
            v[num-1]++;
        }
    }

    for(int i = 0;i < m;i++)
        if(v[i] == n)count++;
    
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int R = sc.nextInt();
        int[] Z = new int[N];
        for(int n = 0; n < N; n++) {
            Z[n] = sc.nextInt();
        }
        int i = 0;
        
        for (int n = 0; n < N; n++) {
            if (Z[n] >= R) {
                i++;
            }
        }
        System.out.println(i);
    }
}

Measured memory_bytes: 49160
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define pll  pair<ll,ll>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1000000000+7;
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
ll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans.sz+1;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

void solve()
{
	int r,g,b;
	cin>>r>>g>>b;
	int x=r*100+g*10+b;
	// cout<<x;
	if(x%4==0)
		cout<<"YES";
	else
		cout<<"NO";
	return;
}            
int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//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 SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD
#define ADD(a,b) (a + b) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code
int n;
string S = "ACGT";

bool contain(string s) {
	if (s.substr(0, 3) == "AGC") {
		return true;
	}
	if (s.substr(1, 3) == "AGC") {
		return true;
	}
	return false;
}

string add(string s, char c) {
	string res = s+c;
	if (contain(res)) {
		return "";
	}
	for (int i = 0; i < 4; i++) {
		string tes = res;
		swap(tes[i], tes[i+1]);
		if (contain(tes)) {
			return "";
		}
	}
	return res.substr(1);
}

int main(int argc, char const* argv[])
{
	cin >> n;
	map<string, LL> dp;
	dp["###"] = 1;

	for (int i = 0; i < n; i++) {
		map<string, LL> pd;
		for (auto p : dp) {
			for (auto c : S) {
				string nxt = add(p.first, c);
				if (nxt != "") {
					//pd[nxt] += p.second;
					pd[nxt] = ADD(pd[nxt], p.second);
				}
			}
		}
		swap(dp, pd);
	}
	LL ans = 0;
	for (auto p : dp) {
		//ans += p.second;
		ans = ADD(ans, p.second);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

enum NoOfDaysTillSunday
{
	SUN(7),
	MON(6),
	TUE(5),
	WED(4),
	THU(3),
	FRI(2),
	SAT(1);
		
	int numberOfDaysTillSunday;
	NoOfDaysTillSunday(int numberOfDaysTillSunday) {this.numberOfDaysTillSunday = numberOfDaysTillSunday;};
}

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		// get day of week		
		String day = sc.next();
		System.out.println(NoOfDaysTillSunday.valueOf(day).numberOfDaysTillSunday);	
	}
}


Measured memory_bytes: 22612
#include <cstdio>
#define ll long long

int main() {
  ll a, b, c, k;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &k);
  if(a - b < -1000000000000000000 || 1000000000000000000 < a - b)
    printf("Unfair\n");
  else
    printf("%lld\n", (a - b) * (1 - k % 2 * 2));
}

Measured memory_bytes: 128
using System;

namespace Question1
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Run();
        }

        void Run(){
            var s = Console.ReadLine();
            var containsA = s.Contains("A");
            var containsB = s.Contains("B");

            var result = ( containsA && containsB ) ? "Yes" : "No";

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
n=int(input())
jun=list(map(int,input().split()))
lis=list(map(int,input().split()))
add=list(map(int,input().split()))
ans=0
for i in range(n):
    ans+=lis[i]
for i in range(n-1):
    if jun[i]+1==jun[i+1]:
        ans+=add[jun[i]-1]

print(ans)


Measured memory_bytes: 3060
# 0≦X,Y,Z≦K
# S = x + y + z

K, S = map(int, input().split())

cnt = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - (x + y)
        if 0 <= z <= K:
            cnt += 1

print(cnt)


Measured memory_bytes: 2940
// ------------------------------------
// Date:2018/ 3/12
// Problem:ABC 071 NotFound b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

bool state[26];

int main()
{

  memset(state, true, sizeof(state));
  string S;
  cin >> S;
  REP(i, S.size()) {
    state[S[i] - 97] = false;
  }

  REP(i, 26) {
    if (state[i]) {
      printf("%c\n", i + 97);
      return 0;
    }
  }
  printf("None\n");
  return 0;
}



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


using namespace std;
#define rep(i,n) for(int i=0; i<n; i++) 

int main() {
	string S; cin >> S;
	int cnt = 0,max=0;
	for (int i = 0;i < S.size();i++) {
		if (S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G') {
			cnt++;
			max = max < cnt ? cnt:max;

		}
		else {
			cnt = 0;

		}



	 }

	cout << max;

	
}

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

int main(){
    int n,k;
    while(cin >> n >> k){
        int m;
        set<int> v[50];
        bool f[50];
        fill(f,f+50,false);
        for(int i=0;i<k;i++){
            cin >> m;
            for(int j=0;j<m;j++){
                int a;
                cin >> a;
                v[i].insert(a);
            }
        }
        int r,ans = 0;
        cin >> r;
        for(int i=0;i<r;i++){
            int a,b;
            cin >> a >> b;
            for(int j=0;j<k;j++){
                if(v[j].find(a) != v[j].end() && v[j].find(b) != v[j].end()){
                    if(!f[a-1]) ans++;
                    if(!f[b-1]) ans++;
                    f[a-1] = true; 
                    f[b-1] = true;

                    break;
                }
            }
        }
        cout << ans << endl;
    }
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,k;cin>>n>>k;
  string s;cin>>s;

  int same=0,dif=0;
  for(int i=0;i<n-1;i++){
    if(s[i]==s[i+1])same++;
    else dif++;
  }

  cout<<same + min(dif, k*2)<<endl;

  return 0;
}


Measured memory_bytes: 512
import sys


def _nextstep(s):
    retval=[0 for i in range(len(s))]
    for i,si in enumerate(s):
        retval[i]=s.count(si)
    return retval

def fudouten(s):
    count=0
    while True:
        next=_nextstep(s)
        if next==s:
            return count,s
        else:
            s=next
            count+=1

while True:
    n=int(input())
    if n==0:
        sys.exit()
    s=[int(i) for i in input().split(" ")]
    count,ans=fudouten(s)
    print(count)
    print(" ".join([str(s) for s in ans]))



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll ans,minb=2e9;
bool ok;
int main(){
	scanf("%d",&n);
	while(n--){
		ll a,b;
		scanf("%lld%lld",&a,&b);
		ans+=b;
		if(a!=b)ok=1;
		if(b<a)minb=min(minb,b);
	}
	if(ok)printf("%lld",ans-minb);
	else puts("0");
	return 0;
} 

Measured memory_bytes: 3824
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long

bool comp(pair<int, int> a, pair<int, int> b) {
    return a.first < b.first;
}

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

    vector<pair<int, int>> v;
    for (int i=0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }

    sort(v.begin(), v.end(), comp);

    LL ans = 0;
    for (int i=0; i < n; i++) {
        if (m - v[i].second > 0) {
            m -= v[i].second;
            ans += (LL)v[i].first * v[i].second;
        } else {
            ans += (LL)v[i].first * m;
            break;
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector <pair <int,int> > v(N);
  for(int i = 0; i < N; i++){
    cin >> v[i].first;
    v[i].second = i + 1;
  }
  sort(v.begin(), v.end());
  for(int i = 0; i < N; i++){
    cout << v[i].second << " ";
  }
}

Measured memory_bytes: 1536
#include<iostream>
#include<cstdlib>
#include<vector>
#include<unordered_map>
#include<climits>
#include<string>
#include<algorithm>
#include<unordered_set>
//#include<>

using namespace std;

long long unsigned int sum(vector<long long unsigned int>vec, int n)
{
	const unsigned int M = 1000000007;
	vector<long long unsigned int>vecsum(n);
	long long unsigned int ans=0;
	for (int i = n-1; i >-1; i--) {
		ans = ( ans + ( vec[i] % M) ) % M;
		vecsum[i] = ans;
	}
	ans = 0;
	for (int i = 0; i < n-1; i++) {
		vecsum[i] = ((vec[i] % M) * (vecsum[i + 1])) % M ;
		ans = (ans + (vecsum[i] % M)) % M;
	}
	return ans;
}

		

// Driver code 
int main()
{
	int n;
	cin >> n;
	vector<long long unsigned int>vec(n);

	for (int i = 0; i < n; i++)
		cin >> vec[i];

	cout << sum(vec, n);
	return 0;
}



Measured memory_bytes: 7892
S = str(input())
j_count = 0
X = []

for s in S:
    X.append(s)

if X[0] == 'A':
    j_count += 1
    if X[2:len(X)-1].count('C') == 1:
        j_count += 1
        X.remove('A')
        X.remove('C')
        S_n = ''.join(X)
        if S_n.islower():
            j_count += 1

if j_count == 3:
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    set<int> s{1,2,3};
    int a, b;
    cin >> a >> b;
    s.erase(a);
    s.erase(b);
    cout << *s.begin() << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,x;
    cin >> N >> x;
    vector<int> childrenNumber(N);
    for (int i = 0; i < N; ++i) {
        cin >> childrenNumber.at(i);
    }
    for (int i = 0; i < N; ++i) {
        sort(childrenNumber.begin(), childrenNumber.end());
    }
    int k = 0;
    for (int i = 0; i < N; ++i) {
        x -= childrenNumber.at(i);
        k++;
        if(x==0){
            break;
        }else if(x < 0){
            k--;
            break;
        }
    }
    if(x > 0) k--;
    cout << k;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int a[3];
int b[3];
int c[5];
int main(){
	REP(i,3){
		cin>>a[i]>>b[i];
		c[a[i]-1]++;
		c[b[i]-1]++;
	}
	int aa=0;
	int bb=0;
	REP(i,4){
		//cout<<c[i]<<endl;
		if(c[i]==1){
			aa++;
		}else if(c[i]==2){
			bb++;
		}
	}
	//cout<<aa<<bb<<endl;
	if(aa==2&&bb==2){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
main()
{
    int N=0,out=0;
    string ashi1,ashi2;
 
    while(1)
    {
        cin >> N;
        if(N==0) break;
        for(int i=0;i<N/2;i++)
        {
            cin >> ashi1 >> ashi2;
            if((ashi1=="lu"&&ashi2=="ru")||(ashi1=="ru"&&ashi2=="lu")||(ashi1=="ld"&&ashi2=="rd")||(ashi1=="rd"&&ashi2=="ld")) out++;
        }
        if( N%2==1 )cin >> ashi1;
        cout << out << endl;
        out=0;
    }
    return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
signed main(){
    int n,t;cin>>n>>t;
    vector<pair<int,int>> x(n);
    rep(i,n)cin>>x[i].first>>x[i].second;
    sort(x.begin(),x.end());
    rep(i,n){
        if(x[i].second<=t){
            cout<<x[i].first<<endl;
            goto FINE;
        }
    }
    cout<<"TLE"<<endl;
    FINE:
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func duplicate(a []int) bool {
	m := make(map[int]bool)
	for i := 0; i < len(a); i++ {
		if _, ok := m[a[i]]; ok {
			return true
		}
		m[a[i]] = true
	}
	return false
}

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

	a := []int{s}

	for i := 0; !duplicate(a); i++ {
		if a[i]%2 == 0 {
			a = append(a, a[i]/2)
		} else {
			a = append(a, a[i]*3+1)
		}
	}
	fmt.Println(len(a))
}


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

void solve(long long N, std::vector<std::string> S){
    map<string,int> count;
    for (ll i=0;i<N;i++){
        if (count.count(S[i])==0 ){
            count[S[i]] = 0;
        }else{
            count[S[i]]+=1;
        }
    }
    vector<string> maximum_strs;
    int maximum = 0;
    for (const auto& kv : count){
        string key = kv.first;
        int value = kv.second;
        if (value>maximum){
            maximum_strs.clear();
            maximum_strs.push_back(key);
            maximum = value;
        }else if (value == maximum){
            maximum_strs.push_back(key);
        }
    }
    for (const auto &str : maximum_strs){
        cout << str << endl;
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 28404
#include<iostream>
#include<algorithm>
using namespace std;
//Strongly Connected Components
#include<vector>
struct SCC{
	int n;
	vector<int>comp,order;
	vector<bool>used;
	vector<vector<int> >G,RG;
	SCC(int _n=0):n(_n),comp(_n,-1),used(_n,false),G(_n),RG(_n){}
	void add_edge(int from,int to)
	{
		G[from].push_back(to);
		RG[to].push_back(from);
	}
	void copy(const vector<vector<int> >&H)
	{
		for(int i=0;i<H.size();i++)
		{
			for(int j=0;j<H[i].size();j++)
			{
				G[i].push_back(H[i][j]);
				RG[H[i][j]].push_back(i);
			}
		}
	}
	int operator[](int u)const{return comp[u];}
	void dfs(int u)
	{
		used[u]=true;
		for(int i=0;i<G[u].size();i++)if(!used[G[u][i]])dfs(G[u][i]);
		order.push_back(u);
	}
	void rdfs(int u,int cnt)
	{
		comp[u]=cnt;
		for(int i=0;i<RG[u].size();i++)if(comp[RG[u][i]]==-1)rdfs(RG[u][i],cnt);
	}
	int build()
	{
		for(int i=0;i<n;i++)if(!used[i])dfs(i);
		int cnt=0;
		for(int i=n-1;i>=0;i--)if(comp[order[i]]==-1)rdfs(order[i],cnt++);
		return cnt;
	}
	int build(vector<vector<int> >&H)
	{
		int ret=build();
		H.assign(ret,vector<int>());
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<G[i].size();j++)
			{
				if(comp[i]!=comp[G[i][j]])
					H[comp[i]].push_back(comp[G[i][j]]);
			}
		}
		return ret;
	}
};
int N,D;
int X[1000],Y[1000];
main()
{
	cin>>N>>D;
	SCC P(2*N);
	for(int i=0;i<N;i++)cin>>X[i]>>Y[i];
	for(int i=0;i<N;i++)for(int j=i+1;j<N;j++)
	{
		if(abs(X[i]-X[j])<D)
		{
			P.add_edge(2*i,2*j+1);
			P.add_edge(2*j,2*i+1);
		}
		if(abs(Y[i]-X[j])<D)
		{
			P.add_edge(2*i+1,2*j+1);
			P.add_edge(2*j,2*i);
		}
		if(abs(X[i]-Y[j])<D)
		{
			P.add_edge(2*i,2*j);
			P.add_edge(2*j+1,2*i+1);
		}
		if(abs(Y[i]-Y[j])<D)
		{
			P.add_edge(2*i+1,2*j);
			P.add_edge(2*j+1,2*i);
		}
	}
	P.build();
	bool ok=true;
	for(int i=0;i<N;i++)if(P[2*i]==P[2*i+1])ok=false;
	if(ok)
	{
		cout<<"Yes"<<endl;
		for(int i=0;i<N;i++)
		{
			cout<<(P[2*i]>P[2*i+1]?X[i]:Y[i])<<endl;
		}
	}
	else
	{
		cout<<"No"<<endl;
	}
}


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

int main(){
  string s;
  cin >> s;
  if(s[0] == '9' || s[1] == '9'){
    puts("Yes");
  }
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
bool Q=true;
struct Line{
      mutable int M,N;
      mutable long double pt;
      Line(int a,int b,int c){
            M=a;
            N=b;
            pt=c;
      }
      bool operator<(const Line&X)const{
            if(Q)return M>X.M;
            else return pt<=X.pt;
      }
};
struct Hull : multiset<Line> {
      long double get_point(iterator X,iterator Y){
            long double A=X->M,B=X->N,C=Y->M,D=Y->N;
            if(A==C){
                  if(D>B)return INF;
                  else return -INF;
            }
            return (D-B)/(A-C);
      }
      bool isect(iterator X,iterator Y){
            if(Y==end()){
                  X->pt=INF;
                  return false;
            }
            X->pt=get_point(X,Y);
            return X->pt>=Y->pt;
      }
      void add(int m,int n){
            iterator curr=insert(Line(m,n,INF));
            while(isect(curr,next(curr)))erase(next(curr));
            if(curr==begin())return;
            if(isect(prev(curr),curr))curr=erase(curr);
            isect(prev(curr),curr);
            curr--;
            while(curr!=begin()&&isect(prev(curr),curr)){
                  isect(prev(curr),curr=erase(curr));
                  curr--;
            }
      }
      int query(int x){
            Line W(0,0,x);
            Q=false;
            iterator itr=lower_bound(W);
            Q=true;
            return itr->M*x+itr->N;
      }
};

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n,c;
      cin>>n>>c;
      vector<int>H(n+1);
      Hull data;
      vector<int>dp(n+1,0);
      for(int i=1;i<=n;i++)cin>>H[i];
      data.add((-2*H[1]),H[1]*H[1]);
      for(int i=2;i<=n;i++){
            dp[i]=H[i]*H[i]+c+data.query(H[i]);
            data.add(-2*H[i],H[i]*H[i]+dp[i]);
      }
      cout<<dp[n];
}


Measured memory_bytes: 19072
def main():
    n, a, b = map(int, input().split())
    ans_max = min(a, b)
    if n >= a + b:
        ans_min = 0
    else:
        ans_min = (a + b) - n
    print(str(ans_max) + " " + str(ans_min))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
from copy import deepcopy

h,w,k=map(int,input().split())
b=[list(i[::-1]) for i in zip(*[input() for _ in range(h)])]
b=[[int(s) for s in strs] for strs in b]
fans=0
for x in range(w):
  for y in range(h):
    a=deepcopy(b)
    a[x].pop(y)
    a[x].append(0)
    q=[]
    ans=0
    d=-1
    m=0
    while True:
      if d==ans:break
      d=ans
      for i in range(h):
        cnt=0
        for j in range(w-1):
          if a[j][i]==a[j+1][i]:cnt+=1
          else:
            if cnt>=k-1:
              q.append((j-cnt,i,cnt+1))
            cnt=0
        if cnt>=k-1:
          q.append((w-cnt-1,i,cnt+1))      
      while q:
        j,i,cnt=q.pop()
        for c in range(cnt):
          ans+=2**m*a[j+c].pop(i)
          a[j+c].append(0)
      m+=1
    fans=max(fans,ans) 
print(fans)

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

void solve() {
    long long h;
    cin >> h;
    int count = 0;
    while(h!=0) {
        h = h/2;
        count++;
    }
    long long sum = 0;
    for(int i=0;i<count;i++) {
        sum+= (long long)pow(2,i);
    }
    cout << sum << endl;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(0);
    // freopen("a.txt","r",stdin);
    solve();
    return 0;
}


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

int main(){
    ll h, n;
    cin >> h >> n;
    ll sum = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        sum += a;
    }
    if ( sum >= h ) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


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

#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for(int i=a; i<b; i++)

#define PB push_back
#define MP make_pair
typedef pair<int, int> pii;

int n;
vector<int> rods[200];
bool visited[200];
int nw;

bool chk(int pl){
	visited[pl]=true;
	REP(i, rods[pl].size()){
		int k = rods[pl][i];
		if(k==nw) return true;
		if(visited[k]) continue;
		if(chk(k)) return true;
	}
	return false;
}

int main(){
	scanf("%d", &n);
	REP(i, n){
		int u, d;
		char s[5];
		scanf("%d%s%d", &u, s, &d);
		u--; d--;
		if(s[0]=='l')
			rods[d+100].PB(u);
		else
			rods[u].PB(d+100);
	}
	REP(i, 100){
		nw = i;
		fill(visited, visited+200, false);
		if(chk(nw)){
			printf("1\n");
			return 0;
		}
	}
	printf("0\n");
}

Measured memory_bytes: 3164
#include <stdio.h>

int main (void)
{
  char map[2][3];

  scanf("%s", map[0]);
  scanf("%s", map[1]);

  if (map[0][0] == map[1][2] && map[0][1] == map[1][1] && map[0][2] == map[1][0]) {
    printf("YES");
  } else {
    printf("NO");
  }

  return 0;
}

Measured memory_bytes: 128
n = int(input())
s = [input() for i in range(n)]

import collections
c = collections.Counter(s)
ans = []
most = c.most_common()
word,count = most[0]
ans.append(word)
for i in range(1,len(c)):
    wordi,counti = most[i]
    if counti == count:
        ans.append(wordi)
    else:
        break
ans.sort()
print(*ans, sep = "\n")

Measured memory_bytes: 151544
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(6) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;


signed main(){
    while(1){
        int m,f,r;
        cin >> m >> f >> r;
        if(m==-1&&f==-1&&r==-1){
            break;
        }
        if(m==-1 || f==-1){
            print("F");
        }
        else{
            int t = m+f;
            if(t>=80){
                print("A");
            }
            else if(t>=65){
                print("B");
            }
            else if(t>=50){
                print("C");
            }
            else if(t>=30&&r>=50){
                print("C");
            }
            else if(t>=30){
                print("D");
            }
            else{
                print("F");
            }
        }


    }


    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 3092
/*
	Nishant Singh
	nishant.ns19@gmail.com
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 
// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********
// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ook order_of_key    //count of strictly smaller elements
// #define fbo find_by_order   //find element at an index 
// ******** Using PBDS ********
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=1e9 + 7;
ll const inf=2e18;
// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********
inline ll add(ll a,ll b) 
{ 
	return (a%mod + b%mod + mod)%mod; 
}
inline ll mul(ll a,ll b) 
{ 
	return (a%mod * b%mod + mod)%mod; 
}
inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}
ll gcd(ll a,ll b)
{
	if (b == 0) 
		return a; 
	return gcd(b, a % b);  
}
ll modexp(ll x, ll n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
ll modinv(ll n)
{
	return modexp(n,mod-2);
}
// ******** GLOBAL VARIABLES ********
// ******** GLOBAL VARIABLES ********
void solve(){
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	REP(i,k)
	c=c*2;
	if(a<b && b<c)
	{
		cout<<"Yes\n";
		return;
	}
	while(k--)
	{
		c=c/2;
		b=b*2;
		if(a<b && b<c)
		{
			cout<<"Yes\n";
			return;
		}
	}
	cout<<"No\n";
}  
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using lint = long long;

void printPrecisionRational(lint d, lint n, int k) {
    cout << d / n << '.';
    for (int c = 0; c < k; c++) {
        d = (d % n) * 10;
        cout << d / n;
    }
}

int main() {
    int n;
    lint h, t = 1;
    vector<lint> arr;
    ios_base::sync_with_stdio(false);
    cin >> n;
    arr.resize(n);
    for (lint& k : arr) cin >> k;
    sort(arr.begin(), arr.end());
    h = arr[0];
    for (int i = 1; i < arr.size(); i++, t <<= 1) h += t * arr[i];
    printPrecisionRational(h, t, 6);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;

int main() {
	string s;
	int k;
	cin >> s >> k;

	int len = s.length();

	bool isSame = true;

	for (int i = 1; i < len;i++) {
		if (s[i] != s[i - 1]) {
			isSame = false;
		}
	}

	ll ans = 0;
	if (isSame) {
		ans = (1LL * len * k) / 2;
		
	}
	else {
		
		string t(s);
		for (int i = 1; i < len;i++) {
			if (t[i] == t[i - 1]) {
				ans++;
				t[i] = ' ';
			}

		}

		ans = ans * k;
		if (t[len - 1] == t[0]) {
			int cnt = 0;
			for (int i = 0; i < len;i++) {
				if (s[i] == s[0]) {

					cnt++;
				}
				else {
					break;
				}
			}

			if (cnt % 2 != 0) {
				ans += k - 1;
			}

		}


	}

	cout << ans << endl;

}

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

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

        if (n == 0 && x == 0) break;

        int count = 0;

        int i, j, k;
        for (i = 1; i <= n - 2; i++){
            for (j = i + 1; j <= n - 1; j++){
                for (k = j + 1; k <= n; k++){
                    if (i + j + k == x) count++;
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
//const int INF = 100100100;
const int INF = (1LL<<32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

static const int MAX = 100000;

int N;
list<int>  out;
bool bV[MAX];
vector<int> G[MAX];

void dfs(int u) {
	bV[u] = true;
	rep(i, G[u].size()) {
		int v = G[u][i];
		if (!bV[v])
			dfs(v);
	}
	out.push_front(u);
}

signed main() {
	ios::sync_with_stdio(false);
	int s, t, M;
	cin >> N >> M;
	rep(i, N) bV[i] = false;
	rep(i, M) {
		cin >> s >> t;
		G[s].pb(t);
	}
	rep(i, N) {
		if (!bV[i]) dfs(i);
	}
	for (list<int>::iterator it = out.begin(); it != out.end(); it++) {
		cout << *it << endl;
	}
	//cin >> V >> E;
	//rep(i, E) {
	//	int s, t;
	//	cin >> s >> t;
	//	G[s].pb(t);
	//}
	//rep(u, V) bV[u] = false;
	//rep(i, V) {
	//	if (!bV[i])
	//		dfs(i);
	//}
	//for (auto l : out)
	//	cout << l << '\n';
	return 0;
}




Measured memory_bytes: 6416
import sys
#from math import gcd

#+++++

def gcd(a,b):
	if a < b:
		a,b=b,a
		
	while a != b:
		t=a%b
		if t == 0:
			return b
		else:
			a,b = b,t
	return a
	
def main():
	n = int(input())
	al = list(map(int, input().split()))
	
	if n == 2:
		return max(al)
	
	from_left=[0]*len(al)
	kk=al[0]
	for i, v in enumerate(al):
		kk=gcd(kk,v)
		from_left[i]=kk
	
	from_right=[0]*len(al)
	kk=al[-1]
	for i,v in enumerate(al[::-1]):
		kk=gcd(kk,v)
		from_right[i]=kk
	from_right=from_right[::-1]
	
	ans=0
	for i,_ in enumerate(al):
		if i == 0:
			vv=from_right[1]
		elif i == len(al)-1:
			vv=from_left[-2]
		else:
			a=from_right[i+1]
			b=from_left[i-1]
			#pa((a,b))
			vv=gcd(a,b)
		ans = max(ans, vv)
	print(ans)




#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 14428
n = int(input())
s_dict = {}
for i in range(n):
  add_dict = {}
  a = int(input())
  for j in range(a):
    b = list(map(int, input().split()))
    add_dict[b[0]-1] = b[1]
  s_dict[i] = add_dict
max_num = 0

def rec_get_list(i, tmp_num_list, tmp_honest, tmp_unkind):
  add_dict = s_dict[i]
  tmp_num_list.add(i)
  tmp_honest.add(i)
  for k, v in add_dict.items():
      if v:
        if k not in tmp_num_list:
        	tmp_num_list, tmp_honest, tmp_unkind = rec_get_list(k, tmp_num_list, tmp_honest, tmp_unkind)
        tmp_honest.add(k)
      else:
        tmp_unkind.add(k)
  return tmp_num_list, tmp_honest, tmp_unkind

def rec_check(i, tmp_num_list, tmp_honest, tmp_unkind):
  global max_num
  global n
  for j in range(i, n):
    if j in tmp_num_list:
      continue
    use_num_list = tmp_num_list.copy()
    use_honest = tmp_honest.copy()
    use_unkind = tmp_unkind.copy()
    use_num_list, use_honest, use_unkind = rec_get_list(j, use_num_list, use_honest, use_unkind)
    check_flg = len(use_honest & use_unkind)
    if check_flg:
      continue
    else:
      if len(use_num_list) > max_num:
        max_num = len(use_num_list)
    if j+1 < n:
      rec_check(j+1, use_num_list, use_honest, use_unkind)
  
rec_check(0, set(), set(), set()) 
    
print(max_num)




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

using namespace std;

int main(){
  int n;
  cin >> n;
  int r=n%10;
  if(r==3){
    cout << "bon" << endl;
    return 0;
  }
  else if(r==0 || r==1 || r==6 || r==8){
    cout << "pon" << endl;
    return 0;
  }
  else{
    cout << "hon" << endl;
    return 0;
  }
}



Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		// String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		for (int i = 0; i < str.length(); i++) {
			switch (str.charAt(i)) {
			case 'A':
				System.out.print("T");
				break;
			case 'T':
				System.out.print("A");
				break;
			case 'C':
				System.out.print("G");
				break;
			case 'G':
				System.out.print("C");
				break;
			}
		}
		System.out.println();
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 22612