akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

long long n, m, adj[101][101], dst[101][101], pre[101][101];

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m;
	set<pair<long long, long long>> st;
	for(long long i = 0; i < m; i++){
		long long a, b, c;
		cin >> a >> b >> c;
		adj[a][b] = c, adj[b][a] = c;
		if(a > b) swap(a, b);
		st.insert({a, b});
	}
	for(long long i = 1; i <= n; i++)
		for(long long j = 1; j <= n; j++){
			if(i == j) dst[i][j] = 0;
			else if(adj[i][j]) dst[i][j] = adj[i][j];
			else dst[i][j] = 1e14;
			pre[i][j] = i;
		}
	for(long long k = 1; k <= n; k++)
		for(long long i = 1; i <= n; i++)
			for(long long j = 1; j <= n; j++)
				if(dst[i][k] + dst[k][j] < dst[i][j]){
					dst[i][j] = dst[i][k] + dst[k][j];
					pre[i][j] = pre[k][j];
				}
	for(long long i = 1; i < n; i++)
		for(long long j = 1; j <= n; j++)
			st.erase({pre[i][j], j});
	cout << st.size() << "\n";
	return 0;
}

Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize; n - 1],
    }

    let mut immediate_subordinates_count: Vec<usize> = Vec::with_capacity(n);

    for _ in 0..n {
        immediate_subordinates_count.push(0);
    }

    for boss_number in a.iter() {
        immediate_subordinates_count[*boss_number - 1] += 1;
    }

    for count in immediate_subordinates_count {
        println!("{}", count);
    }
}


Measured memory_bytes: 6364
#include <iostream>
#include <stdio.h>
using namespace std;

int swap(int& a, int& b){
	int c;
	c=a;a=b;b=c;
	return 1;
}

int main(){
	int cup[3] = {1,0,0};
	unsigned char s1='A', s2='A';

	while( scanf("%c,%c\n", &s1, &s2) != EOF){
		swap( cup[s1-'A'] , cup[s2-'A'] ) ;
		
	}
	printf("%c\n", cup[0]*'A' + cup[1]*'B' + cup[2]*'C');
	

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#define H 500000
int h;

void maxHeapify(int *A,int i){
  int temp;
  int l,r,largest;
  l = 2*i;
  r = 2*i+1;

  if(l<=h && A[l] > A[i]) largest = l;
  else largest = i;
  if(r<=h && A[r]>A[largest]) largest = r;
  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(A,largest);
  } 
}

void buildMaxHeap(int *A){
  int i;

  for(i=h/2;i>=1;i--) maxHeapify(A,i);
}

int main(){
  int heap[H+1];
  int i;

  scanf("%d",&h);
  for(i=1;i<=h;i++) scanf("%d",&heap[i]);
  buildMaxHeap(heap);

  for(i=1;i<=h;i++) printf(" %d",heap[i]);
  printf("\n");

  return 0;
}



Measured memory_bytes: 3696
#include <iostream>

using namespace std;

typedef long long LL;

LL gcd(LL x, LL y) {
  while (y != 0) {
    LL r = x % y;
    x = y;
    y = r;
}
  return x;
}

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

  for (int i = 0; i < n; i++) {
      LL a; cin >> a;
      if (i == 0) { ans = a; }
      else { ans = gcd(ans, a); }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n=[int(i) for i in input().split()]
a=n[0]
b=n[1]
if(a==b):
  print("1")
elif(b==1):
  print("0")
else:
  count=0
  i=0
  while(count!=b):
    i+=1
    if((count+a)>=b):
      count+=a
      print(i)
      break
    else:
      count+=a-1
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int a, b;
  int x, y;
  cin >> a >> b;
  if(a==2)x=1;
  else if(a==4||a==6||a==9||a==11){x=2;}
  else{x=3;}
  
  if(b==2)y=1;
  else if(b==4||b==6||b==9||b==11){y=2;}
  else{y=3;}
  
  if(x==y)cout << "Yes" << endl;
  else{cout<<"No" << endl;}
 
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  long long x, currnet=100;
  long long int year=1;

  cin >> x;

  while(100){
    currnet *= 1.01;
    if(currnet >= x){
      break;
    }
    year++;
  }

  cout << year << endl;
}

Measured memory_bytes: 3188
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<i32>();
    let K = read::<i32>();
    let X = read::<i32>();
    let Y = read::<i32>();

    let mut fee = 0;

    if K < N {
        fee = X*K + Y*(N-K);
    } else {
        fee = X*N;
    }
    println!("{}", fee);
}


Measured memory_bytes: 4352
n = int(input())
l = []
for i in range(1,n):
    sur = n%i
    ans = n/i
   # print(i,ans,sur)
    if ans < i:
        break
    elif sur == 0:
        l.append(i)
l.sort(reverse=True)
max = l[0]
max_op = n/max
ite = max-1+max_op-1
print(int(ite))

Measured memory_bytes: 3188
import heapq
n, m = map(int, input().split())
a = [int(x)*(-1) for x in input().split()]
# for _ in range(n):
#     x = int(input())
#     a.append(-1*x)
# print(a)
heapq.heapify(a)
# print(heapq.heappop(a)*(-1))  # 最大値の取り出し
# print(a)
for i in range(m):
    v = heapq.heappop(a)*(-1)
    heapq.heappush(a, (v//2)*(-1))

ans = 0
for i in range(n):
    ans += heapq.heappop(a)*(-1)
print(ans)

Measured memory_bytes: 14180
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;

bool compare_by_b(pair<ll,ll> a,pair<ll,ll> b){
    return a.second>b.second;
}

int main(){
    
    int n,m;
    vector<vector<ll>> v(maxn+1);
    ll ans=0;
    
    cin >> n>>m;
    
    rep(i,n){
        ll a,b;
        cin >> a>>b;
        v[a-1].push_back(b);
    }
    
    
    priority_queue<ll> nmax;
    
    for(int d=0;d<m;d++){
        rep(i,v[d].size()){
            nmax.push(v[d][i]);
        }
        ll a;
        if(nmax.size()>0){
            a=nmax.top();
            ans+=a;
            nmax.pop();
        }
    }
    
    cout << ans<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

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

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

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

struct RMQ
{
	int N;
	ll gt;
	ll a[N_SIZE];
	ll seg[N_SIZE * 2];
	void init(int n) {
		N = n;
		gt = 1;
		while (gt < n)gt *= 2;
		REP(i, N)a[i] = (1LL << 31) - 1;
		REP(i, N_SIZE * 2)seg[i] = (1LL << 31) - 1;
		REP(i, N)seg[i + gt] = a[i];
	}
	void update(int k, int x) {
		k += gt - 1;
		seg[k] = x;
		while (k) {
			k = (k - 1) / 2;//???????????????
			seg[k] = min(seg[k * 2 + 1], seg[k * 2 + 2]);
		}
	}
	ll query(int a, int b) {
		return query(a, b, 0, 0, gt);
	}
	ll query(int a, int b, int k, int l, int r) {//[a,b)????????????????°????,k=0,l=0,r=gt
		if (r <= a || b <= l) return (1LL << 31) - 1;

		if (a <= l && r <= b)return seg[k];
		else {
			return min(query(a, b, k * 2 + 1, l, (l + r) / 2),
				query(a, b, k * 2 + 2, (l + r) / 2, r));
		}
	}
	void print() {
		REP(i, 2 * gt)cout << "!" << i << " " << seg[i] << endl;
	}
};

RMQ rmq;

int n, q;

int main() {
	cin >> n >> q;
	rmq.init(n);
	REP(i, q) {
		int x, y;
		bool f;
		cin >> f >> x >> y;
		if (f) {
			cout << rmq.query(x, y + 1) << endl;
		}
		else {
			rmq.update(x, y);
		}
	}
}

Measured memory_bytes: 20272
#include<bits/stdc++.h>	
#define int long long int
using namespace std;
bool dp[100005];
main()
{	
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	for(int i=0;i<=k;i++){
		for(int j=0;j<n;j++){
			if(i>=arr[j] && !dp[i-arr[j]])
				dp[i]=true;
		}
	}
	if(dp[k])
		cout<<"First";
	else cout<<"Second";
}

Measured memory_bytes: 384
class Coodinate (object):
    """Coodinate object
    This class contains infomation about the coodinates.
    Each instance can have up to 3-dimensional(x,y,z) space coodinates.
    
    params
    ------------------------------
    x : int or floot ,default 0
    y : int or floot ,default 0
    z : int or floot ,default 0


    This class have following methods.
    ------------------------------
    distance : Calculate the straight-line distance between 2 points in Euclidean space.
    midpoint : Calculate the midpoint(halfway) between 2 points.
    manhattan_distance : Calculate the distance between 2 points that is sum of the absolute values their Cartesian coordinates.
    """

    def __init__(self,x=0,y=0,z=0):
        self.x=x
        self.y=y
        self.z=z
    
    def distance(self,other):
        """Calculate the straight-line distance between 2 points in Euclidean space.

        params
        ----------
        self : Coodinate object
        other : Coodinate object

        return
        ----------
        distance : floot

        """
        x_diff_sq=(self.x-other.x)**2
        y_diff_sq=(self.y-other.y)**2
        z_diff_sq=(self.z-other.z)**2
        return (x_diff_sq + y_diff_sq +z_diff_sq)**0.5
    

    def midpoint(self,other):
        """Calculate the midpoint(halfway) between 2 points.

        params
        ----------
        self : Coodinate object
        other : Coodinate object

        return
        ----------
        midpoint : tupul
        
        """
        x_midpoint=(self.x+other.x)/2
        y_midpoint=(self.y+other.y)/2
        z_midpoint=(self.z+other.z)/2
        if self.z == other.z ==0 :
            if self.y == other.y==0:
                return(x_midpoint)
            else:
                return(x_midpoint,y_midpoint) 
        return(x_midpoint,y_midpoint,z_midpoint)

    def manhattan_distance(self,other):
        """Calculate the distance between 2 points that is sum of the absolute values their Cartesian coordinates.

        params
        ----------
        self : Coodinate object
        other : Coodinate object

        return
        ----------
        manhattan_distance : floot

        """

        x_diff_abs=abs(self.x - other.x)
        y_diff_abs=abs(self.y - other.y)
        z_diff_abs=abs(self.z - other.z)
        return(x_diff_abs + y_diff_abs + z_diff_abs)




N,M=map(int,input().split())
S=[]
for i in range(N):
    a,b=map(int,input().split())
    S.append(Coodinate(a,b))

C=[]
for j in range(M):
    c,d=map(int,input().split())
    C.append(Coodinate(c,d))

for k in range (N):
    t1=10**9
    t2=-1
    for l in range (M):
        temp=Coodinate.manhattan_distance(S[k],C[l])
        if temp<t1:
            t1=temp
            t2=l+1
    print(t2)

Measured memory_bytes: 9272
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  string s;
  cin>>s;
  long long int ans=0;
  for(int i=0; i<s.length()-1; i++){
    if(s[i]!=s[i+1]){
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

int main()
{
    int K, A, B;
    cin >> K >> A >> B;
    for (int j = A; j <= B; j++)
    {
        if (j % K == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	ll n, p, in, e = 0, o = 0;
	cin >> n >> p;
	rep(i, n) {
		cin >> in;
		if (in % 2 == 0)e++;
		else o++;
	}
	if (o == 0) {
		if (p) cout<< 0 << endl;
		else {
			ll ans = 1;
			rep(i, n) {
				ans *= 2;
			}
			cout << ans << endl;
		}
	}
	else {
		ll  ans = 1;
		rep(i, n-1) {
			ans *= 2;
		}
		cout << ans << endl;
	}

}

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

int N;
int L;
long long A[2000] = {0};

int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> L;
		A[L]++;
	}
	long long ans = 0;
	for(int i = 1; i <= 1000; i++){
		if(A[i] == 0) continue;
		for(int j = i+1; j <= 1000; j++){
			if(A[j] == 0) continue;
			for(int k = j+1; k < i+j && k <= 1000; k++){
				ans += A[i] * A[j] * A[k];
			}
		}
	}
	// isosceles triangle
	for(int i = 1; i <= 1000; i++){
		if(A[i] >= 2){
			for(int j = 1; j < i+i && j <= 1000; j++){
				if(A[j] > 0 && i != j){
					ans += A[i]*(A[i]-1)/2 * A[j];
				}
			}
		}
	}
	// equilateral triangle
	for(int i = 1; i <= 1000; i++){
		if(A[i] >= 3){
			ans += A[i]*(A[i]-1)*(A[i]-2)/6;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>


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

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
constexpr long long mod = 998244353LL;

using namespace std;
typedef long long ll;


int dh[] = { 1,0,-1,0 };
int dw[] = { 0,1,0,-1 };

vector<int> BFS01(int start, vector<vector<pair<int, int>>>& g) {
	vector<int> d(g.size(), inf);
	d[start] = 0;
	deque<int> dq; dq.emplace_back(start);
	vector<bool> used(g.size());
	while (!dq.empty()) {
		int cur = dq.front();
		dq.pop_front();
		if (used[cur]) continue;
		used[cur] = true;
		for (auto nxt : g[cur]) {
			int to, cost; tie(to, cost) = nxt;
			if (chmin(d[to], d[cur] + cost)) {
				if (cost == 0) dq.emplace_front(to);
				else dq.emplace_back(to);
			}
		}
	}
	return d;
}

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W; cin >> H >> W;
	int sh, sw; cin >> sh >> sw; sh--; sw--;
	int th, tw; cin >> th >> tw; th--; tw--;
	vector<string> vs(H); for (int i = 0; i < H; i++) cin >> vs[i];
	vector<vector<pair<int, int>>> g(H * W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (vs[i][j] == '#') continue;
			for (int k = 0; k < 4; k++) {
				int nh = i + dh[k];
				int nw = j + dw[k];
				if (nh < 0 or nh >= H or nw < 0 or nw >= W) continue;
				if (vs[nh][nw] == '#') continue;
				g[i * W + j].emplace_back(nh * W + nw, 0);
			}
			for (int k = -2; k <= 2; k++) {
				for (int l = -2; l <= 2; l++) {
					int nh = i + k;
					int nw = j + l;
					if (nh < 0 or nh >= H or nw < 0 or nw >= W) continue;
					if (vs[nh][nw] == '#') continue;
					g[i * W + j].emplace_back(nh * W + nw, 1);
				}
			}
		}
	}
	auto d = move(BFS01(sh * W + sw, g));
	int res = d[th * W + tw];
	if (res == inf) res = -1;
	cout << res << endl;
}


Measured memory_bytes: 120616
def main():
  x, y, _a, _b, _c = map(int, input().split())
  p = sorted(map(int, input().split()))[-x:]
  q = sorted(map(int, input().split()))[-y:]
  r = sorted(map(int, input().split()), reverse=True)[:x + y]

  arr = sorted(p + q)
  new_num = 0

  for i, nc_apple in enumerate(r):
    if arr[i] >= nc_apple: break

    new_num += nc_apple - arr[i]

  print(sum(arr) + new_num)


main()


Measured memory_bytes: 22524
#include<iostream>
#include<vector>
#include<map>
using namespace std;

#define ll long long


int v;
ll depth[100001]={};
bool vis[100001] = {};
map<int,vector<pair<int,int>>> adjList;

void dfs(int root){

    vis[root]=1;
    for(auto i : adjList[root]){
        if(!vis[i.first]){
            depth[i.first]=depth[root]+i.second;
            dfs(i.first);
        }
    }

}

int main(){

    cin>>v;
    int from,to,wt;

    for(int i=0;i<v-1;i++){
        cin>>from>>to>>wt;
        adjList[from].push_back({to,wt});
        adjList[to].push_back({from,wt});
    }

    int q,k;
    cin>>q>>k;

    dfs(k);

    for(int i=0;i<q;i++){
        cin>>from>>to;
        cout<<depth[from]+depth[to]<<endl;
    }

}


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

using namespace std;

int n,a,b;

void solve(){

	cout << min(n*a,b) << endl;

}

int main(){


/*
	cin >> n;

	cin.ignore();

	while(n--){

		map<char,int> m;

		string s;

		getline(cin,s);

		for(int i=0;i<s.size();i++){
			if(s[i] != ' ') m[s[i]]++;
		}

		if(m['M'] == m['F'] and m['M'] != 1)cout << "LOOP\n";
		else cout << "NO LOOP\n";
	}
*/
	cin >> n >> a >> b;

	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int mod = 1e9 + 7;

int main()
{
  int a, b;
  cin >> a >> b;
  if(a >= 13)
    cout << b << endl;
  else if(a >= 6)
    cout << b / 2 << endl;
  else 
    cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * 1040.c: Chocolate with Heart Marks
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* constant */

#define MAX_INT	(1 << 29)

#define MAX_H	(12)
#define MAX_W	(12)
#define MAX_NTS	(6)

/* typedef */

typedef int mat_t[MAX_H * MAX_W][MAX_H * MAX_W];
typedef int opt_t[1 << MAX_NTS][MAX_H * MAX_W];

/* global variables */

static int ts[MAX_NTS];
static mat_t gmat, dmat;
static opt_t opt;

/* subroutines */

int minimum_steiner_tree(int nts, int h, int w) {
  int ans, d, e, i, j, k, n, p, q, s;

  if (nts <= 1) return 0;

  n = h * w;

  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      dmat[i][j] = (i == j) ? 0 : gmat[i][j];

  for (k = 0; k < n; k++)
    for (i = 0; i < n; i++)
      for (j = 0; j < n; j++) {
	d = dmat[i][k] + dmat[k][j];
	if (dmat[i][j] > d) dmat[i][j] = d;
      }

  for (s = 0; s < (1 << nts); s++)
    for (p = 0; p < n; p++)
      opt[s][p] = MAX_INT;

  for (p = 0; p < nts; p++)
    for (q = 0; q < n; q++)
      opt[1 << p][q] = dmat[ts[p]][q];

  for (s = 1; s < (1 << nts); s++) {
    if ((s & (s - 1)) == 0) continue;

    for (p = 0; p < n; p++)
      for (e = 0; e < s; e++)
        if ((e | s) == s) {
	  d = opt[e][p] + opt[s - e][p];
          if (opt[s][p] > d) opt[s][p] = d;
	}

    for (p = 0; p < n; p++)
      for (q = 0; q < n; q++) {
	d = opt[s][q] + dmat[q][p];
        if (opt[s][p] > d) opt[s][p] = d;
      }
  }

  ans = MAX_INT;

  for (s = 0; s < (1 << nts); s++)
    for (q = 0; q < n; q++) {
      d = opt[s][q] + opt[(1 << nts) - 1 - s][q];
      if (ans > d) ans = d;
    }

  return ans;
}

/* main */

int main(int argc, char **argv) {
  int d, id, i, j, h, w, hw, nts, x, y;

  for (;;) {
    scanf("%d", &h);
    scanf("%d", &w);
    if (h == 0 && w == 0) break;

    hw = h * w;
    nts = 0;

    for (i = 0; i < hw; i++)
      for (j = 0; j < hw; j++)
	gmat[i][j] = MAX_INT;

    for (y = 0; y < h; y++)
      for (x = 0; x < w; x++) {
	id = y * w + x;

	scanf("%d", &d);
	if (d == 1)
	  ts[nts++] = id;

	if (x > 0)
	  gmat[id][id - 1] = gmat[id - 1][id] = 1;
	if (x < w - 1)
	  gmat[id][id + 1] = gmat[id + 1][id] = 1;
	if (y > 0)
	  gmat[id][id - w] = gmat[id - w][id] = 1;
	if (y < h - 1)
	  gmat[id][id + w] = gmat[id + w][id] = 1;
      }

    printf("%d\n", hw - minimum_steiner_tree(nts, h, w) - 1);
  }

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  ll res = 0;
  rep(i,N) {
    int a;
    cin >> a;
    if(a % 2 == 0) {
      while(a % 2 == 0) {
        res++;
        a /= 2;
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import math
import itertools

(d, g) = map(int, input().split(" "))

p = []
c = []

for i in range(d):
    (_p, _c) = map(int, input().split(" "))
    p.append(_p)
    c.append(_c)

ans = 114514
for order in itertools.permutations(range(d)):
    point = 0
    cnt = 0
    for i in order:
        if g - point <= 100 * (i + 1) * p[i]:
            cnt += math.ceil((g - point) / (100 * (i + 1)))
            break
        elif g - point <= 100 * (i + 1) * p[i] + c[i]:
            cnt += p[i]
            break
        else:
            point += 100 * (i + 1) * p[i] + c[i]
            cnt += p[i]         

    ans = min([ans, cnt])

print(ans)

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

int main(){
    int n;
    cin >> n;
    int a[n];
    vector<int> pos[5];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        pos[2+a[i]].push_back(i);
    }
    vector<int> use;
    for(int i = 0; i + 1 < pos[0].size(); i+=2){
        use.push_back(pos[0][i]);
        use.push_back(pos[0][i+1]);
    }
    if(pos[0].size()%2 && pos[1].size()){
        use.push_back(pos[0][pos[0].size()-1]);
        use.push_back(pos[1][0]);
    }
    for(int i = 0; i < pos[4].size(); i++){
        use.push_back(pos[4][i]);
    }

    sort(use.begin(), use.end());
    cout << use.size() << endl;
    for(int x : use)    cout << x+1 << endl;
    return 0;
}


Measured memory_bytes: 3148
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename T> ll min(ll a, const T&& b) { return a < b ? a : b; }
template<typename T> ll min(const T&& a, ll b) { return a < b ? a : b; }
template<typename T> ll max(ll a, const T&& b) { return a > b ? a : b; }
template<typename T> ll max(const T&& a, ll b) { return a > b ? a : b; }
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n, K; cin >> n >> K;
  vector<P> edges;
  rep(i, 1, n+1) {
    ll k = i & -i;
    ll v = i;
    while (k <= v) {
      if (v & k) {
        v ^= k;
        if (v > 0) {
          edges.eb(v, i);
        }
      }
      k <<= 1;
    }
  }
  cout << edges.size() << endl;
  each(e, edges) {
    cout << e.first << " " << e.second << endl;
  }
  rep(t, K) {
    ll v = 0;
    rrep(i, 10) {
      string result;
      ll nv = v | (1LL<<i);
      if (nv <= n) {
        cout << nv << endl;
        cin >> result;
      }
      else {
        result = "No";
      }
      if (result == "No") {
        continue;
      }
      else if (result == "Near") {
        v = nv;
      }
      else {
        break;
      }
    }
  }
}



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

ll N;
vector<vector<ll>> edges;
vector<ll> A;
ll root;

ll dfs(ll now, ll pre){
    bool leaf = 1;
    vector<ll> num;
    for(ll next : edges[now]){
        if(next == pre) continue;
        leaf = 0;
        num.push_back(dfs(next, now));
    }
    if(leaf) return A[now];
    sort(num.begin(), num.end());
    if(num[0] == -1) return -1;
    reverse(num.begin(), num.end());
    ll sum = accumulate(num.begin(), num.end(), 0);
    ll ret = 2 * A[now] - sum;
    ll to_child = A[now] - ret;
    if(ret < 0 || to_child < 0) return -1;
    ll possible;
    if(num[0] >= sum - num[0]) possible = sum - num[0];
    else if(num.size() == 2) possible = min(num[0], num[1]);
    else possible = sum / 2;
    if(to_child <= possible) return ret;
    else return -1;
}

void init(){
    cin >> N;
    A.resize(N);
    edges.resize(N);
    for(ll &a : A) cin >> a;
    for(ll i = 1; i < N; i++){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    for(ll i = 0; i < N; i++){
        if(edges[i].size() > 1){
            root = i;
            break;
        }
    }
}

void solve(){
    cout << ((N == 2 && A[0] == A[1]) || !dfs(root, -1) ? "YES" : "NO") << endl;
}

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


Measured memory_bytes: 14464
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int day = sc.nextInt();

		System.out.print("Christmas");
		for(int i = 0; i < (25 - day); i ++) {
			System.out.print(" Eve");
		}
		System.out.println();
	}
}

Measured memory_bytes: 21204
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


# https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_b
N = a_int()
XY = read_tuple(N)
XY.sort()
if N == 1:
    print(1)
    exit()
# q,pは何通りありえる？N**2//2通りぐらい
# p,qを決定したらあとは直線に乗っているか確かめれば良い
# 点に当たるたびにO(N)かけて調べれば良い
# 以下のO(n**4)のプログラムが可能
# for q,p全通り
#     while ある点を選択
#        その点の+p+qを見てボールを消す
#     コストをmin
# と思ったけど、ただ単純にp,qで拾えるボールの個数を数えればいいかも

PQcandi = []
for po1, po2 in combinations(XY, r=2):
    dx = po1[0] - po2[0]
    dy = po1[1] - po2[1]
    if dx < 0:
        dx *= -1
        dy *= -1
    elif dx == 0:
        dy = abs(dy)

    PQcandi.append((dx, dy))


def del_ball(p, q, XYtmp):
    ret = []
    # x軸にソートしてあるので左から拾っていく
    x, y = XYtmp[0]
    for xx, yy in XYtmp[1:]:
        if xx == x + p and yy == y + q:
            x += p
            y += q
        else:
            ret.append((xx, yy))

    return ret


from copy import deepcopy
ans = INF
for p, q in PQcandi:
    XYtmp = deepcopy(XY)
    anstmp = 0
    while XYtmp:
        anstmp += 1
        XYtmp = del_ball(p, q, XYtmp)
    # print(p, q, anstmp)
    ans = min(ans, anstmp)
print(ans)


Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define deb(x) cout<<#x<<" "<<x<<endl;
const ll INF = 1e9 + 7;

int main(){
  ll n;
  cin>>n;
  vector<ll> h(n+1);
  for (ll i = 1; i <= n; i++) {
    cin>>h[i];
    //deb(i);
  }

  vector<vector<ll> > dp(3,vector<ll>(n+1,0) );
  dp[1][1] = 0;
  dp[2][1] = 0;
  for (ll i = 2; i <= n; i++) {
    dp[1][i] = abs(h[i] - h[i-1]) + dp[1][i-1];
  }

  for (ll i = 2; i <= n; i++) {
    ll diff = INF;
    if(i-2 > 0) diff = abs(h[i] - h[i-2]) + dp[2][i-2];
    dp[2][i] = min(dp[1][i] , diff );

    ll diff_1 = INF;
    if(i-1 > 0) diff_1 = abs(h[i] - h[i-1]) + dp[2][i-1];
    dp[2][i] = min(dp[2][i] , diff_1 );
  }

  // for (ll i = 1; i <= 2; i++) {
  //   for (ll j = 1; j <= n; j++) {
  //     std::cout << dp[i][j] << " ";
  //   }
  //   std::cout << '\n';
  // }

  std::cout << dp[2][n] << '\n';


}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	if (n == 0) {
		cout << 0 << endl;
		return 0;
	}

	string res = "";
	while (abs(n) > 0) {
		int mod = n % 2;
		if (mod < 0)
			mod += 2;

		n = (n - mod) / (-2);
		res += (mod == 0) ? '0' : '1';
	}

	reverse(res.begin(), res.end());
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = INT_MAX;
const ll INF = 1e18;
const ld EPS = 1e-10;

const int MAX_V = 1e5;
vector<pii> es[MAX_V];
int pos[MAX_V];
bool used[MAX_V], able;

void dfs(int now){
    used[now] = true;
    for(auto &e: es[now]){
        int to = e.first, d = e.second;
        if(pos[to] == inf){
            pos[to] = pos[now]+d;
            dfs(to);
        }
        else if(pos[to] != pos[now]+d) able = false;
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    rep(i, M){
        int L, R, D;
        cin >> L >> R >> D;
        L--, R--;
        es[L].pb(pii(R, D));
        es[R].pb(pii(L, -D));
    }
    fill(used, used+N, false);
    fill(pos, pos+N, inf);
    able = true;
    rep(i, N){
        if(!used[i]) pos[i] = 0, dfs(i);
    }
    if(able) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll unsigned long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

const ll lim = 1e18;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	ll ans = 1;
	bool fail{false},abs = false;
	while(n--){
		ll term;
		cin >> term;
		if(term == 0){
			abs = true;
		}
		if(term != 0 && ans > lim / term){
			fail = true;
		}
		ans *= term;
	}
	if(abs){
		cout << 0;
	}
	else if(fail){
		cout << -1;
	}
	else{
		cout << ans;
	}
	return 0;
}




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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;

int main()
{
  string a, b;
  cin >> a >> b;
  int na = a.size(), nb = b.size();
  if (a == b) { printf("EQUAL\n"); }
  else if (na < nb) {
    printf("LESS\n");
  }
  else if (na > nb) {
    printf("GREATER\n");
  }
  else {
    printf("%s\n", a < b ? "LESS" : "GREATER");
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int N;
	scanf("%d",&N);

	int tmp;
	vector<int> V;

	for(int loop = 0; loop < N; loop++){
		scanf("%d",&tmp);
		V.push_back(tmp);
	}

	int num_query;
	scanf("%d",&num_query);

	int left,right;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d %d",&left,&right);
		reverse(V.begin()+left,V.begin()+right);
	}

	printf("%d",V[0]);
	for(int i = 1; i < V.size(); i++){
		printf(" %d",V[i]);
	}
	printf("\n");

	return 0;
}



Measured memory_bytes: 3240
program main
  implicit none
  integer(16) i, N, ans, lim, frag, frag2
  integer(16),allocatable :: A(:)
  read(*, *)N
  allocate(A(N))
  read(*, *) (A(i), i = 1,N)
  ans = 1
  lim = 1
  frag = 0
  frag2 = 1
  do i = 1,18
    lim = lim * 10
  end do
  !lim = 10**18
  do i = 1,N
    ans = ans*A(i)
    if (ans > lim) then
      frag = 1
    endif
    if (A(i) == 0) then
      frag2 = 0
    endif
  end do
  !frag = frag * frag2
  if (frag == 1) then
    ans = -1
  end if
  if (frag2 == 0) then
    ans = 0
  end if
  write(*, *) ans
end program main

Measured memory_bytes: 4676
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);

		String line = sc.nextLine();
		int count = 0;
		for (int i = 0; i < line.length(); i++) {
			if (line.charAt(i) == '1') {
				count++;
			}
		}
		System.out.println(count);
	}

	static class FastScanner {

		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;

	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

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

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

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

	}


}


Measured memory_bytes: 20820
#include<bits/stdc++.h>
using namespace std;
vector<string>v;
int main(){
 string s;
 int n ,  m ;
 cin >> n >> m ;
 for(int i=1;i<=n;i++){
    cin >> s ;
    v.push_back(s);
 }
 sort(v.begin(),v.end());
 for(int i=0;i<v.size();i++){
    cout << v[i];
 }
 cout << endl;
 return 0;
}



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

int main() {

  while( true ) {

    long long int n;
    cin >> n;
    if ( n == 0 ) break;

    pair< vector< long long int >, vector< long long int > > p;

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

      long long int m;
      cin >> m;

      vector< long long int > x, y;

      for ( long long int re = 0; re < 2; re++ ) {

	if ( re == 0 ) {
	  for ( long long int j = 0; j < m; j++ ) {
	    long long int in_x, in_y;
	    cin >> in_x >> in_y;
	    if ( j > 0 ) {
	      in_x -= x[0];
	      in_y -= y[0];
	    }
	    x.push_back( in_x );
	    y.push_back( in_y );
	  }
	}else {
	  vector< long long int > z;
	  for ( long long int a = 0; a < m; a++ ) {
	    z.push_back( x[m-a-1] - x[m-1] );
	  }
	  x.swap( z );
	  z.clear();
	  for ( long long int a = 0; a < m; a++ ) {
	    z.push_back( y[m-a-1] - y[m-1] );
	  }
	  y.swap( z );
	}
	x[0] = 0;
	y[0] = 0;
      if ( y[1] > 0 ) {
	for ( long long int j = 1; j < m; j++ ) {
	  long long int k = x[j];
	  x[j] = y[j];
	  y[j] = -k;
	}
      }
      if ( y[1] < 0 ) {
	for ( long long int j = 1; j < m; j++ ) {
	  long long int k = x[j];
	  x[j] = -y[j];
	  y[j] = k;
	}
      }
      if ( x[1] < 0 ) {
	for ( long long int j = 1; j < m; j++ ) {
	  x[j] = -x[j];
	  y[j] = -y[j];
	}
      }
      /*
      cout << " i = " << i << endl;
      for ( long long int j = 0; j < m; j++ ) {
	cout << x[j] << " " << y[j] << endl;
      }
      */
      if ( i == 0 ) {
	p = make_pair( x, y );
      }else {
	if ( x == p.first && y == p.second ) {
	  cout << i << endl;
	  break;
	}
      }
      }
    }

    cout << "+++++" << endl;

  }

  return 0;

}

Measured memory_bytes: 1220
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int n,k;
    cin >> n>>k;
    double cnt = 0;
    for(int i = 1;i<=n;i++) {
        int now = i;
        double tmp = 1.0/n; 
        while(now<k) {
            now *= 2;
            tmp /= 2;
        }
        cnt += tmp;
    }
    
    printf("%.10f\n",cnt);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  std::string S; int N, K; std::cin >> N >> K >> S;
  S[K-1] += 'a' - 'A';
  fin(S);
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    int N, K;
    cin >> N >> K;

    ll answer = 1;

    FOR(i, 0, N){
        if(answer < K){
            answer *= 2;
        }else{
            answer += K;
        }
    }

    p(answer);

    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
  
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
const ll inf=1ll<<29;
int main(){
      int X,Y,N;
      cin>>X>>Y>>N;
      vector<P> ob;
      rep0(i,N){
            int x,y;
            cin>>x>>y;
            if(x>=y) ob.push_back({x,y});
      }
      sort(ob.begin(),ob.end());
      vector<P> obb;
      int i=0;
      for(auto p:ob){
            int x=p.first;
            int y=p.second;
            if(x>y+i){
                  cout<<x-1<<endl;
                  return 0;
            }
            if(x==y+i){
                  i++;
            }
      }
      cout<<X<<endl;
      return 0;
}


Measured memory_bytes: 6384
a,b = input().split()

List = [a,b]
List.sort()

if  List[0] == a:
    combinea = ''
    for i in range(int(b)):
        combinea += a
    print(combinea)

else:
    combineb = ''
    for i in range(int(a)):
        combineb += b
    print(combineb)


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

typedef ostringstream OSS;
typedef istringstream ISS;

typedef long long LL;
typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define Y first
#define X second
#define fst first
#define snd second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const char NONE = '.';
const char BAD = '*';
const char WALL = 'x';
const char ROBOT = 'o';

int W, H;
VS ts;

map<PII, int> p2idx;
VPII ps;
int PN;
int s;

VVI es;

void find_ps() {
	PN = 0;
	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) {
			if (ts[y][x] == BAD || ts[y][x] == ROBOT) {
				if (ts[y][x] == ROBOT) {
					s = PN;
				}
				p2idx[MP(y, x)] = PN;
				ps.EB(y, x);

				++PN;
			}
		}
	}
}

void calc_distance(int pi) {
	VVB done(H, VB(W));

	queue<pair<PII, int>> q;
	q.push(MP(ps[pi], 0));

	while (q.size()) {
		PII p = q.front().fst;
		int cost  =q.front().snd;
		q.pop();

		if (done[p.Y][p.X]) continue;
		done[p.Y][p.X] = true;

		if (p2idx.count(p)) {
			int idx = p2idx[p];
			es[pi][idx] = cost;
		}


		for (int di = 0; di < 4; di++) {
			PII np(p.Y + DY[di], p.X + DX[di]);
			if (RANGE(np.X, np.Y, W, H) && ts[np.Y][np.X] != WALL) {
				q.push(MP(np, cost + 1));
			}
		}
	}
}

int solve() {
	// ????????§?¨?????????????
	p2idx.clear();
	ps.clear();
	find_ps();

	// ?????¨???????????¢????????????
	es.clear();
	es.resize(PN, VI(PN, INF));
	for (int i = 0; i < PN; i++) {
		calc_distance(i);
	}

	// ???????????????????????¨??????????????£?????? -1
	for (int i = 0; i < PN; i++) {
		for (int j = 0; j < PN; j++) {
			if (es[i][j] == INF) {
				return -1;
			}
		}
	}

	// ???????????¢????±???????
	// dp[pattern][v]
	VVI dp(1 << PN, VI(PN, INF));
	dp[1 << s][s] = 0;
	for (int pt = 0; pt < 1 << PN; pt++) {
		for (int cur = 0; cur < PN; cur++) {
			if (dp[pt][cur] == INF) continue;

			for (int next = 0; next < PN; next++) {
				if (1 << next & pt) continue;

				int npt = pt | (1 << next);
				int ncost = dp[pt][cur] + es[cur][next];

				if (dp[npt][next] > ncost) {
					dp[npt][next] = ncost;
				}
			}
		}
	}

	return *min_element(ALL(dp.back()));
}

int main(void) {
	while (cin >> W >> H, W) {
		ts.resize(H);
		for (auto &l : ts) {
			cin >> l;
		}
		cout << solve() << endl;
	}	

	return 0;
}

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

using namespace std;

const int MAX = 2*10e5+1;
const int MOD = 1000000007;

long long finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    long long res = 1;
    for (int i = n; i >= n - k + 1; i--){
        res = res * i % MOD;
    }
    return res * finv[k] % MOD;
}

// a^n % m
long long modpow(long long a, long long n, long long m){
    long long res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
}

void solve() {
    COMinit();
    int n, a, b;
    cin >> n >> a >> b;
    long long ans;
    ans = (modpow(2, n, MOD) - 1 - COM(n, a) - COM(n, b)) % MOD;
    ans = (ans + MOD) % MOD;
    cout << ans << endl;
}
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 31488
n=int(input())
A=[]
for i in range(n):
  for _ in range(int(input())):
    x,y=map(int,input().split())
    A+=[(i,x-1,y)]
a=0
for i in range(2**n):
  if all(i>>j&1<1 or i>>x&1==y for j,x,y in A):
    a=max(a,sum(map(int,bin(i)[2:])))
print(a)

Measured memory_bytes: 9208