akhauriyash/Code-Regression huggingface dataset:
/*
    ____       ____                 _
   |  _ \ _ __|  _ \  ___ _ __   __| |_ __ ___
   | | | | '__| | | |/ _ \ '_ \ / _` | '__/ _ \ 
   | |_| | |_ | |_| |  __/ | | | (_| | | | (_) |
   |____/|_(_)|____/ \___|_| |_|\__,_|_|  \___/
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define db1(x) cout << #x << "=" << x << '\n'
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << '\n'
#define db3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << '\n'
#define rep(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(x) scanf("%s", x)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(x) printf("%s\n", x)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define F first
#define S second
#define pb push_back
#define ll long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N, OO = 1e9 + 7;
const ll LLOO = 1e18 + 7;
//=======================

vi g[N];
ll a[N];
int n;

void solve()
{
    si(n);
    rep(i,0,n) sl(a[i]);
    
    ll ans = 0;
    
    rep(i,1,n)
    {
		ll d = max(a[i-1]-a[i],0LL);
		ans += d;
		a[i] += d;
	}
	
	pl(ans);
}

int main()
{
    // uncomment if file :
    // freopen("in","r",stdin);
    // freopen("out","w",stdout);
    int t = 1;
    // si(t); // uncomment if testcases
    while (t--)
        solve();
    return 0;
}

int mpow(int base, int exp)
{
    base %= mod;
    int result = 1;
    while (exp > 0)
    {
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m)
{
    int u, v;
    while (m--)
    {
        scanf("%d %d", &u, &v);
        g[u - 1].pb(v - 1);
        g[v - 1].pb(u - 1);
    }
}

void dfs(int u, int par)
{
    for (int v : g[u])
    {
        if (v == par)
            continue;
        dfs(v, u);
    }
}


Measured memory_bytes: 12440
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
#define MAXNUM 150
using namespace std;

int main(){
    int W, H, N;
    cin >> W >> H >> N;
    
    int masu[MAXNUM][MAXNUM]={};
    
    int x, y, a;
    for (int i = 0; i < N; i++) {
        cin >> x >> y >> a;
        if (a==1) {
            for (int yax = 0; yax < H ; yax++) {
                for (int xax = 0; xax < x; xax++) {
                    masu[yax][xax]=1;
                }
            }
        } else if (a==2) {
            for (int yax = 0; yax < H ; yax++) {
                for (int xax = x; xax < W; xax++) {
                    masu[yax][xax]=1;
                }
            }
        } else if (a==3) {
            for (int xax = 0; xax < W ; xax++) {
                for (int yax = 0; yax < y; yax++) {
                    masu[yax][xax]=1;
                }
            }
        } else if (a==4){
            for (int xax = 0; xax < W ; xax++) {
                for (int yax = y; yax < H; yax++) {
                    masu[yax][xax]=1;
                }
            }
        }
    }
    
    int total = 0;
    for (int yax = 0; yax < H; yax++) {
        for (int xax = 0; xax < W; xax++) {
            if(masu[yax][xax]==0) total++;
        }
    }
    
    cout << total << endl;
    return 0;
}



Measured memory_bytes: 384
import sys
import queue

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n, m = tin()
	#s = input()
	al = [-1]+lin()
	bb=[[] for _ in range(n+1)]
	for _ in range(m):
		a, b = tin()
		bb[a].append(b)
		bb[b].append(a)
		
	ll=[]
	is_open = [0] *(n+1)
	for i in range(n+1):
		q=queue.Queue()
		q.put(i)
		t=[]
		while not q.empty():
			pp=q.get()
			if is_open[pp] != 0:
				continue
			is_open[pp]=1
			t.append(pp)
			for v in bb[pp]:
				q.put(v)
		ll.append(t)
	
	ret = 0
	#pa(ll)
	for t in ll:
		st=set(t)
		for v in t:
			if al[v] in st:
				ret += 1
	print(ret)
				
		
		
	
	
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 127228
#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 RREP(i,n) for(int i = (n); i >= 0; i--)
#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 N, M, Q;
vector<vector<int>> q;
int ans = 0;

void dfs(vector<int> v,int x) {
    v.push_back(x);
    if (v.size() == N) {
        int tmp = 0;
        REP(i,Q) {
            if (v[q[i][1]] - v[q[i][0]] == q[i][2]) tmp += q[i][3];
        }
        ans = max(ans,tmp);
        return;
    }
    FOR(i,x,M+1) {
        dfs(v,i);
    }
}


int main(void)
{
    IOS
    cin >> N >> M >> Q;
    
    REP(i,Q) {
        vector<int> abcd(4);
        REP(j,4) cin >> abcd[j];
        abcd[0]--;
        abcd[1]--;
        q.push_back(abcd);
    }

    FOR(i,1,M+1) dfs(vector<int>(0),i);

    cout << ans << '\n';

    return 0;
}


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

using namespace std;

int a[200005], b[200005];

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

    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < n; i++) scanf("%d", &b[i]);

    reverse(b, b + n);

    int l = 0;
    int r = n - 1;

    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) continue;

        if (l < i && a[l] != b[i] && b[l] != a[i]) {
            swap(b[i], b[l]);
            l++;
        }
        else if (r > i && a[r] != b[i] && b[r] != a[i]) {
            swap(b[i], b[r]);
            r--;
        }
        else return 0 * printf("No\n");
    }

    printf("Yes\n");
    for (int i = 0; i < n; i++) {
        if (i == 0) printf("%d", b[i]);
        else printf(" %d", b[i]);
    }
    printf("\n");
}


Measured memory_bytes: 5376
s = gets.chomp.split("")
s.length.times do |i|
  if s[i] == "B"
    s[i] = nil
    j = 1
    while i >= j
      if s[i-j]
        s[i-j] = nil
        break
      end
      j += 1
    end
  end
end
s.length.times do |i|
  print s[i]
end
print "\n"

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
signed main() {
	double n, m, a = 0, b = 0, cnt = 0, ans = 0; cin >> n;
	string s, t;
	for (int h = 0; h < n; h++) {
		cin >> a >> s;
		if (s == "JPY") { ans += a; }
		else {
			ans += a * 380000;
		}
	}
	printf("%.10f\n", ans);
	cin >> n; return 0;
}

Measured memory_bytes: 256
#!/bin/bash
read N A B
if [ "$A" -eq 0 ];then 
  echo 0
  exit
fi;
W="$(( A + B ))"
M="$((N%W))"
_M="$((M-A))"

M2="$([ "$_M" -lt 0 ] && echo "$_M" || echo 0)"

echo "$(((N/W*A)+(A+M2)))"


Measured memory_bytes: 504
#define NDEBUG 1
#include <cmath>
#include <complex>
#include <algorithm>
#include <cassert>
using namespace std;

typedef long double Real;
typedef complex<Real> Point;
#define PCR Point const &
#define X real()
#define Y imag()

const Real EPS = 1e-10;
const Real INF = 1e100;
const Real PI = acos(-1);

struct Segment {
    Point p[2];
    Segment (PCR a = Point(), PCR b = Point()){
        p[0] = a, p[1] = b;
    }
    Point & operator [] (int k) { return p[k]; }
    Point const & operator [] (int k) const { return p[k]; }
};
typedef vector<Point> Polygon;
struct Circle { Real radius; Point center; };

Real dot(PCR a, PCR b){
    return a.X*b.X + a.Y*b.Y;
}
Real cross(PCR a, PCR b){
    return a.X*b.Y - a.Y*b.X;
}

Point pSP(Segment const & s, PCR p){
    Point base = s[1] - s[0];
    Real r = dot(p - s[0], base) / norm(base);
    return s[0] + base * r;
}

Point rSP(Segment const & s, PCR p){
    Point v = pSP(s,p) - p;
    return p + v * Real(2);
}

enum { LEFT = 1, RIGHT = -1, BACK = 2, FRONT = -2, ON = 0 };
// Includes end-points. Comment in to exclude.
int ccw(PCR x, PCR p, PCR q){
    Point a = p - x, b = q - x;
    if(cross(a,b) > EPS) return LEFT;
    if(cross(a,b) < -EPS) return RIGHT;
    if(/* abs(a) < EPS || */ dot(a,b) < -EPS) return BACK;
    if(/* abs(b) < EPS || */ norm(a) < norm(b)) return FRONT;
    return ON;
}

bool isParallel(Segment const & s, Segment const & t){
    return abs(cross(s[1]-s[0],t[1]-t[0])) < EPS;
}

bool isOrthogonal(Segment const & s, Segment const & t){
    return abs(dot(s[1]-s[0],t[1]-t[0])) < EPS;
}

// Includes end-points. Modify CCW to exclude
bool iSS(Segment const & s, Segment const & t){
    bool f1 = ccw(s[0],s[1],t[0]) * ccw(s[0],s[1],t[1]) <= 0;
    bool f2 = ccw(t[0],t[1],s[0]) * ccw(t[0],t[1],s[1]) <= 0;
    return f1 && f2;
}

bool iSP(Segment const & s, PCR p){
    return ccw(s[0],s[1],p) == ON;
}

Point cSS(Segment const & s, Segment const & t){
    assert(iSS(s,t));
    assert(!isParallel(s,t));
    Real d = cross(t[1]-t[0], s[1]-s[0]);
    return s[0] + (s[1] - s[0]) * cross(t[1]-t[0], t[1]-s[0]) * (1.0 / d);
}

Real dSP(const Segment & s, PCR p) {
    const Point r = pSP(s, p);
    if(iSP(s,r)) return abs(r-p);
    return min(abs(s[0]-p), abs(s[1]-p));
}

Real dSS(Segment const & s, Segment const & t){
    if(iSS(s,t)) return Real(0);
    return min(min(dSP(s,t[0]), dSP(s,t[1])), min(dSP(t,s[0]), dSP(t,s[1])));
}

#include <iostream>
#include <cstdio>

int main(){
    Segment s,t;
    Real x,y;
    int n; cin >> n;
    for(int i=0;i<n;i++){
        cin >> x >> y;
        s[0] = Point(x,y);
        cin >> x >> y;
        s[1] = Point(x,y);
        cin >> x >> y;
        t[0] = Point(x,y);
        cin >> x >> y;
        t[1] = Point(x,y);
        Real d = dSS(s,t);
        printf("%.10Lf\n", d);
    }
}

Measured memory_bytes: 1252
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

int main(){
    int n, t;
    int N[10000], T[500];
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> N[i];
    }
    cin >> t;
    for(int i=0; i<t; i++){
        cin >> T[i];
    }
    int cnt = 0;
    for(int i=0; i<t; i++){
        for(int j=0; j<n; j++){
            if(N[j] == T[i]) {
                cnt++;
                break;
            }
        }
    }
    cout << cnt;
    cout << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string a,b;
    cin >> a >> b;
    string c = a + b;
    int N = stoi(c);
    bool square = false;
    rep(i,1000){
        if(i * i == N){
            square = true;
        }
    }
    if(square) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] light = new int[m];
        for(int i = 0; i < m; i++){
            int k = Integer.parseInt(sc.next());
            for(int j = 0; j < k; j++){
                int s = Integer.parseInt(sc.next());
                light[i] |= (1 << s-1);
            }
        }
        int[] p = new int[m];
        for(int i = 0; i < m; i++){
            p[i] = Integer.parseInt(sc.next());
        }
        
        int count = 0;
        for(int i = 0; i < Math.pow(2, n); i++){
            boolean allLightUp = true;
            for(int j = 0; j < m; j++){
                if((Integer.bitCount(light[j] & i) % 2) != p[j]){
                    allLightUp = false;
                    break;
                }
            }
            if(allLightUp){
                count++;
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <vector>
#include <list>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <climits>
#include <map>
#include <math.h>

using namespace std;

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

	vector<int> d1 = {0,1,2,3,4,5,6,7,8,9};
	vector<int> dd;

	for (int i = 0; i < k; i++)
	{
		int t;
		cin >> t;
		d1[t] = -1;
	}
	for (int i = 0; i <10; i++)
	{
		if (d1[i] != -1){ dd.push_back(d1[i]); }
	}

	int digit[5] = { 0 };
	digit[0] = dd[0];
	int a = 0,b=-1,c=-1,d=-1,e=-1;
	int size = dd.size();
	bool f = false;
	
	while (1){

		int ans = digit[4] * 10000;
		ans += digit[3] * 1000;
		ans += digit[2] * 100;
		ans += digit[1] * 10;
		ans += digit[0];

		if (ans >= n){ cout << ans << endl; return 0; }
		a++;digit[0] = dd[a%size];
		if (a%size == 0){ f = true; }
		int tmp = b;
		if (f == true){ b++; digit[1] = dd[b%size]; if (b%size != 0 || tmp < 0){ f = false; } else{ f = true; tmp = c; } }
		if (f == true){ c++; digit[2] = dd[c%size]; if (c%size != 0 || tmp <0){ f = false; } else { f = true; tmp = d; } }
		if (f == true){ d++; digit[3] = dd[d%size]; if (d%size != 0 || tmp <0){ f = false; } else { f = true; tmp = e; } }
		if (f == true){ e++; digit[4] = dd[e%size]; if (e%size != 0 || tmp <0){ f = false; } else { f = true;  } }
		
	}


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(){
        int N, K;
        scanf("%d %d",&N,&K);
        int cnt_modKzero;
        int cnt_modKhalf;

        cnt_modKzero = N/K;
        cnt_modKhalf = 0;
        if(K%2 == 0){
                if(N>=K/2) cnt_modKhalf = 1+(N-K/2)/K;
        }
        printf("%lld\n",(ll)cnt_modKzero*(ll)cnt_modKzero*(ll)cnt_modKzero
                      + (ll)cnt_modKhalf*(ll)cnt_modKhalf*(ll)cnt_modKhalf);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define INF 999999

int x,y,t,n,m,route[2][20][20];
int i,j,k,l;

int main(){
	while(scanf("%d",&m)*m){
		n=0;
		for(i=0;i<11;i++){
			for(j=0;j<11;j++){
				if(i!=j)route[0][i][j]=INF;
			}
		}

		for(i=0;i<m;i++){
			scanf("%d %d %d",&x,&y,&t);
			if(x+1>n)n=x+1;
			if(y+1>n)n=y+1;
			route[0][x][y]=t;
			route[0][y][x]=t;
		}

		for(l=1;pow(2.0,l-1)<n-1;l++){
			for(i=0;i<n;i++){
				for(j=0;j<n;j++){
					route[l%2][i][j]=route[(l+1)%2][i][j];
					for(k=0;k<n;k++){
						if(route[l%2][i][j]>route[(l+1)%2][i][k]+route[(l+1)%2][k][j]){
							route[l%2][i][j]=route[(l+1)%2][i][k]+route[(l+1)%2][k][j];
						}
					}
				}
			}
		}

		l=(l-1)%2;

		x=INF;
		for(i=0;i<n;i++){
			k=0;
			for(j=0;j<n;j++){
				if(route[l][i][j]==INF)fprintf(stderr,"ERROR\n");
				k+=route[l][i][j];
			}
			if(k<x){
				x=k;
				y=i;
			}
		}

		printf("%d %d\n",y,x);

	}
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            long[] v = new long[5];

            for (int i = 0; i < N; i++)
            {
                string s = Console.ReadLine();

                switch(s[0])
                {
                    case 'M': v[0]++; break;
                    case 'A': v[1]++; break;
                    case 'R': v[2]++; break;
                    case 'C': v[3]++; break;
                    case 'H': v[4]++; break;
                }
            }

            long ans = 0;

            ans = v[0] * v[1] * v[2];
            ans += v[0] * v[1] * v[3];
            ans += v[0] * v[1] * v[4];
            ans += v[0] * v[2] * v[3];
            ans += v[0] * v[2] * v[4];
            ans += v[0] * v[3] * v[4];

            ans += v[1] * v[2] * v[3];
            ans += v[1] * v[2] * v[4];
            ans += v[1] * v[3] * v[4];
            ans += v[2] * v[3] * v[4];

            Console.WriteLine(ans);
        }
    }
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


ll rec(int N, ll X){
    if(N==0) return 1;
    ll len = (1LL<<(N+1)) - 3;//N-1の最大長
    ll num = (1LL<<N) - 1;//N-1のパティ数

    if(X==1) return 0;
    else if(X<=len+1) return rec(N-1, X-1);
    else if(X==len+2) return num + 1;
    else if(X<=2*len + 2) return num + 1 + rec(N-1, X-len-2);
    else return num*2 + 1;
}

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

    cout << rec(N,X) << endl;

    return 0;
}

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

int main(){
  int s = 0;
  int a[9][2];
  for(int i = 0; i < 9; i++){
    cin >> a[i][0];
    a[i][1] = 0;
  }
  int n, t;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> t;
    for(int j = 0; j < 9; j++){
      if(t == a[j][0])
        a[j][1] = 1;
    }
  }
  s = s + a[0][1] * a[1][1] * a[2][1];
  s = s + a[3][1] * a[4][1] * a[5][1];
  s = s + a[6][1] * a[7][1] * a[8][1];
  s = s + a[0][1] * a[3][1] * a[6][1];
  s = s + a[1][1] * a[4][1] * a[7][1];
  s = s + a[2][1] * a[5][1] * a[8][1];
  s = s + a[0][1] * a[4][1] * a[8][1];
  s = s + a[2][1] * a[4][1] * a[6][1];
  if(s != 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

typedef long long ll;

vector<int> v;
int k, cnt = 0;

int Pow(int a, int b)
{
    int ans = 1;
    for(int i = 0; i < b; i++){
        ans *= 10;
    }
    return ans;
}

bool check(int val)
{
    bool flag3 = 0, flag5 = 0, flag7 = 0;
    while(val){
        int rem = val % 10;
        if(rem == 3)
            flag3 = 1;
        if(rem == 5)
            flag5 = 1;
        if(rem == 7)
            flag7 = 1;
        val /= 10;
    }

    if(flag3 && flag5 && flag7)
        return true;
    return false;
}

int solve(int pos, int val)
{
    if(pos >= k){
        if(check(val)){
            //cout<<val<<endl;
            v.push_back(val);
            cnt++;
        }
        return 0;
    }    
    int ret1 = solve(pos + 1, 3 * Pow(10, pos) + val);
    int ret2 = solve(pos + 1, 5 * Pow(10, pos) + val);
    int ret3 = solve(pos + 1, 7 * Pow(10, pos) + val);
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    for(int i = 3; i <= 9; i++){
        k = i;
        solve(0, 0);
    }
    int n;
    cin>>n;
    sort(v.begin(), v.end());
    int idx = upper_bound(v.begin(), v.end(), n) - v.begin();

    cout<<idx<<endl;

    return 0;
}

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

int main(){
    int n;cin>>n;
    vector<int> v;
    double xy[2][10000];
    double x,y;
    for(int i=0;i<n;++i){
        v.push_back(i);
        cin>>x>>y;
        xy[0][i]=x;
        xy[1][i]=y;
    }
    int k=1;
    for(int i=1;i<=n;++i)k*=i;
    double sum=0;
    do{
        for(int i=1;i<n;++i){
            sum+=sqrt(pow(xy[0][v[i]]-xy[0][v[i-1]],2)+pow(xy[1][v[i]]-xy[1][v[i-1]],2));
        }
    }while(next_permutation(v.begin(),v.end()));
    double ans=sum/(double)k;
    printf("%.10f\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *x, int *y){ int t = *x; *x = *y; *y = t;}

int partition(int *a, int p, int r){
  int x , i, j;
  x = a[r];
  i = p - 1;
  for(j = p; j < r; ++j)
    if(a[j] <= x)
      swap(&a[++i], &a[j]);
  swap(&a[++i], &a[r]);
  return i;
}

int main(){
  int  n, a[100001], i, r, q;

  scanf("%d", &n);
  for(i = 0;i < n; ++i) scanf("%d", a + i);
  q = partition(a, 0, n - 1);

  for(i = 0; i < n; i++){
    if(i != 0) putchar(' ');
    printf(i != q ? "%d" : "[%d]", a[i]);
  }
  puts("");
  return 0;
} 

Measured memory_bytes: 1008
#include<stdio.h>
//Regular 069 C
int main(){

    long long int n, m;
    scanf("%lld %lld", &n, &m);

    long long int N;
    if(n*2<=m){
	N = n;
	m = m - n*2;
	N = N + m/4;
    }else{
	N = m/2;
    }

    printf("%lld\n", N);
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;

void main() {
	int n;
	scanf("%d\n", &n);
	auto a = readln.chomp.split.to!(double[]);
	writef("%.20f", 1.0 / a.map!(x => 1.0 / x).reduce!"a+b");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
using  INT = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

using namespace std;
/*...................................DEFINE GLOBAL VARIABLES ............ ...........................*/

vector<string> maze;
int dh[] = {1, 0, -1, 0};
int dw[] = {0, 1, 0, -1};
int H, W;
/*.....................................DEFINE FUNCTIONS................................................*/

bool check(int i, int j) {

	bool res = true;

	REP(k, 4) {
		int nh = i + dh[k];
		int nw = j + dw[k];
		if (nh < 0 || nw < 0 || nh >= H || nw >= W)continue;
		else if(maze[nh][nw] == '.')res=false;
		else if (maze[nh][nw] == '#') {
			res=true;
			break;
		}
	}

	return res;
}


/*...........................................kemkemG0..................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);



	cin >> H >> W;

	REP(i, H) {
		string s; cin >> s;
		maze.push_back(s);
	}

	bool ok = true;

	REP(i, H)REP(j, W) {
		if(maze[i][j]!='#')continue;
		if (!check(i, j)) {ok = false; break;}
	}
	YesNo(ok)





	return 0;
}













Measured memory_bytes: 3628
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	int n;
	cin >> n;
	int ans=0;
	for(int i=1;i<=n;++i)
	{
		int t;
		cin >> t;
		if(t&1 && i&1)
		ans++;
	}
	cout << ans << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 3608
program ABC162A
    implicit none
    integer(8)::i,flg
    character(3)::N
    read*,N
    flg=0
    do i=1,3
        if(N(i:i)=="7")flg=1
    end do

    if(flg==0)print'(A)',"No"
    if(flg==1)print'(A)',"Yes"
end program ABC162A

Measured memory_bytes: 2928
n = int(input())
x_str = input().split()
xs = [int(c) for c in x_str]

xs_len = len(xs)
center = (xs_len - 1)//2

c_xs = xs[:]
c_xs.sort()

for x in xs:
    print(c_xs[center+1] if x <= c_xs[center] else c_xs[center])


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

int main() {
  int D;
  cin >> D;
  if ( D==25 )
    cout << "Christmas" << endl;
  if ( D==24 )
    cout << "Christmas Eve" << endl;
  if ( D==23 )
    cout << "Christmas Eve Eve" << endl;
  if ( D==22 )
    cout << "Christmas Eve Eve Eve" << endl;
  
  return 0;
}


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

int main(void) {
    int n, m, count=0;
    cin >> n >> m;
    vector<long long int> h(n);
    vector<pair<int, int>> ab(m);
    vector<int> good(n, 1);
    for (int i=0; i<n; i++) {
        cin >> h.at(i);
    }
    for (int i=0; i<m; i++) {
        cin >> ab.at(i).first >> ab.at(i).second;
        if (h.at(ab.at(i).first - 1) >= h.at(ab.at(i).second - 1)) {
            good.at(ab.at(i).second - 1) = 0;
        }
        if (h.at(ab.at(i).first - 1) <= h.at(ab.at(i).second - 1)) {
            good.at(ab.at(i).first - 1) = 0;
        }
    }
    for (int i=0; i<n; i++) {
        if (good.at(i)==1) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 5108
#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int n,m,a[501],b[501],cost[501],i,j,temp,root[101],size[101],x,y,sum;
	while(1){
		cin>>n>>m;
		if(n==0) break;
		for(i=0;i<n;i++){
			size[i]=1;
			root[i]=i;
		}
		for(i=0;i<m;i++) cin>>a[i]>>b[i]>>cost[i];
		for(i=0;i<m-1;i++){
			for(j=i+1;j<m;j++){
				if(cost[i]>cost[j]){
					temp=cost[i]; cost[i]=cost[j]; cost[j]=temp;
					temp=a[i]; a[i]=a[j]; a[j]=temp;
					temp=b[i]; b[i]=b[j]; b[j]=temp;
				}
			}
		}
//		for(i=0;i<m;i++)cout<<cost[i]<<endl;
		sum=0;
		for(i=0;i<m;i++){
			x=a[i]; y=b[i];
			while(root[x]!=x) x=root[x];
			while(root[y]!=y) y=root[y];
			if(x!=y){
				sum+=cost[i];
				if(size[x]>size[y]) root[y]=x;
				else if(size[x]<size[y]) root[x]=y;
				else {
					root[x]=y;
					size[y]++;
				}
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
int main(){
    string a,b;
    cin >> a >> b;
    map<char,char> mp1;
    map<char,char> mp2;
    int i;
    for(i=0;i<a.size();i++){
      auto itr1 = mp1.find(a[i]);
      auto itr2 = mp2.find(b[i]);
      if(itr1==mp1.end()){
        mp1[a[i]]=b[i];
      }
      if(itr2==mp2.end()){
        mp2[b[i]]=a[i];
      }
      if((mp1[a[i]]!=b[i])|(mp2[b[i]]!=a[i])){
          cout << "No" <<endl;
          return 0;
      }
    }
    cout << "Yes" <<endl;
    return 0;
}


Measured memory_bytes: 776
import sys

n, q = map(int, sys.stdin.readline().split())
s = '$' + sys.stdin.readline().rstrip()
lr = zip(*[map(int, sys.stdin.read().split())] * 2)

def main():
    res = [None] * (n + 1); res[0] = 0
    prev = '$'
    for i in range(1, n+1):
        res[i] = res[i-1]
        res[i] += (prev == 'A' and s[i] == 'C') & 1
        prev = s[i]
    
    for l, r in lr:
        yield res[r] - res[l]

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 23776
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.1415926535

int main() 
{
    FAST;
    ll n,k,c;
    string s;
    cin>>n>>k>>c>>s;
    ve<ll> v1,v2;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='o')
        {
            v1.pb(i);
            i=i+c;
        }
    }
    for(int i=n-1;i>=0;i--)
    {
        if(s[i]=='o')
        {
            v2.pb(i);
            i=i-c;
        }
    }
    reverse(v2.begin(),v2.end());
    if(v1.size()==k && v2.size()==k)
    {
        for(int i=0;i<k;i++)
            if(v1[i]==v2[i])
                cout<<v1[i]+1<<'\n';
    }
    return 0;
}

Measured memory_bytes: 5128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    string s;
    cin >> s;

    if(s.size()%2!=0){
        cout << "No" << endl;
        return 0;
    }

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

    for(int i = 0; i < s.size()-1; i+=2){
        if(s.at(i)==s.at(i+1)){
            continue;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

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

  int len = S.length();
  int ans = 0;
  for(int i = 0;i < len-2;i++){
    if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C')
      ans++;
  }

  cout << ans << endl;
}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int h,n,a,i,sum=0;
    vector<int>v;
    cin>>h>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        sum=sum+a;
    }

    if(sum>=h)
    cout<< "Yes"<<endl;
    else
    cout<< "No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define inf 100000
using namespace std;
using P = pair<int, int>;

int n, m;
vector<vector<int>> edge;
vector<int> ans;

void solve();

int main() {
  cin >> n >> m;
  edge.resize(n, vector<int>());
  for(int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    edge[--x].push_back(--y);
  }
  solve();
  if(ans.size() != 0) {
    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); ++i)
      cout << ans[i] + 1 << endl;
  }
  else
    cout << -1 << endl;
  return 0;
}

void solve() {
  for(int i = 0; i < n; ++i) {
    ans.clear();
    vector<int> dis(n, inf), bf(n, -1);
    queue<P> qu;
    qu.push({i, 0});
    while(!qu.empty()) {
      P now = qu.front();
      qu.pop();
      for(int j = 0; j < edge[now.fi].size(); ++j) {
        P nextp = make_pair(edge[now.fi][j], now.se + 1);
        if(dis[nextp.fi] > nextp.se) {
          bf[nextp.fi] = now.fi;
          dis[nextp.fi] = nextp.se;
          qu.push(nextp);
        }
      }
    }
    if(dis[i] == inf) continue;
    set<int> st;
    int np = bf[i];
    st.insert(i);
    ans.push_back(i);
    while(np != i) {
      ans.push_back(np);
      st.insert(np);
      np = bf[np];
    }
    vector<int> cnt(n, 0);
    bool ch = 1;
    for(int i = 0; i < ans.size(); ++i) {
      int nowcnt = 0;
      np = ans[i];
      for(int j = 0; j < edge[np].size(); ++j)
        if(st.find(edge[np][j]) != st.end()) {
          ++nowcnt;
          ++cnt[edge[np][j]];
          if(nowcnt > 1 || cnt[edge[np][j]] > 1) ch = 0;
        }
    }
    if(ch) return;
  }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>


main()
{
int h,w;
while(1){
	scanf("%d %d",&h,&w);
	if((h|w)==0)break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("%c",j==0||j==w-1||i==0||i==h-1?'#':'.');
		}
		printf("\n");
	}
	printf("\n");
}
}


Measured memory_bytes: 2028
#116 B
s =int(input())
lists=[]
lists.append(s)
for i in range(2,1000001):
    if lists[-1]%2==0:
        tmp=int(lists[-1]/2)
        lists.append(tmp)
        if lists.count(tmp)==2:
            print(i)
            exit()
    else:
        tmp=(3*lists[-1])+1
        lists.append(tmp)
        if lists.count(tmp)==2:
            print(i)
            exit()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            if(i * 4 + j * 7 == N){
                Yes(true);
                return 0;
            }
        }
    }
    Yes(false);
}


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

bool isPrime(int n) {
  if ( n == 2 ) return true;
  for(int d = 2; d * d <= n; d++)
    if( n % d == 0 ) return false;
  return true;
}

int main() {
  for(int n; cin >> n; ) {
    int small = n;
    int large = n;
    while( !isPrime(--small) );
    while( !isPrime(++large) );
    cout << small << ' ' << large << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int q1=a/d,q2=c/b;
  if(a%d!=0)
    q1++;
  if(c%b!=0)
    q2++;
  if(q1>=q2)
    cout<<"Yes\n";
  else
    cout<<"No\n";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), gcd_l(n, 0), gcd_r(n, 0);
    cin >> a;
    for(int i = 1; i < n; i++) {
        gcd_l[i] = __gcd(gcd_l[i - 1], a[i - 1]);
    }
    for(int i = n - 2; i >= 0; i--) {
        gcd_r[i] = __gcd(gcd_r[i + 1], a[i + 1]);
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        ans = max(ans, __gcd(gcd_l[i], gcd_r[i]));
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    using namespace std;
    unsigned long X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<unsigned long> A(X), B(Y), C(Z);
    for(auto &i : A)cin >> i;
    for(auto &i : B)cin >> i;
    for(auto &i : C)cin >> i;
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    auto def = A.back() + B.back() + C.back();

    for(unsigned long i = 0; i + 1 < X; ++i)A[i] = A[i + 1] - A[i];
    for(unsigned long i = 0; i + 1 < Y; ++i)B[i] = B[i + 1] - B[i];
    for(unsigned long i = 0; i + 1 < Z; ++i)C[i] = C[i + 1] - C[i];
    A.pop_back();
    B.pop_back();
    C.pop_back();
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());
    reverse(C.begin(), C.end());

    unordered_map<unsigned long, bool> mp;
    priority_queue<pair<unsigned long, unsigned long>> pq;
    pq.emplace(def, 0);
    mp[0] = true;

    unsigned long cnt{0};
    while(cnt != K){
        ++cnt;
        auto tmp = pq.top();
        cout << tmp.first << endl;
        pq.pop();
        auto x = tmp.second & 1023, y = (tmp.second >> 10) & 1023, z = (tmp.second >> 20) & 1023;
        if(x + 1 != X && !mp[tmp.second + 1]){
            pq.emplace(tmp.first - A[x], tmp.second + 1);
            mp[tmp.second + 1] = true;
        }
        if(y + 1 != Y && !mp[tmp.second + 1024]){
            pq.emplace(tmp.first - B[y], tmp.second + 1024);
            mp[tmp.second + 1024] = true;
        }
        if(z + 1 != Z &&!mp[tmp.second + 1048576]){
            pq.emplace(tmp.first - C[z], tmp.second + 1048576);
            mp[tmp.second + 1048576] = true;
        }
    }

    return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
typedef long long LL;
LL ans,a;
bool Query(LL q){
	printf("? %lld\n",q);
	fflush(stdout);
	char str[10];
	scanf("%s",str);
	if(str[0]=='Y') return true;
	else return false;
}
LL query(LL x,int t){
	LL y=x;
	for(int i=1;i<=t;++i) y=y*10+9;
	return y;
}
void GetFirst(){
	int l=1,r=9,mid;
	while(l<=r){
		mid=((l+r)>>1);
		LL q=query((LL)mid,10);
		if(Query(q)) r=mid-1;
		else l=mid+1;
	}
	a=r+1;
}
int GetNewbit(int len){
	int l=0,r=9,mid;
	while(l<=r){
		mid=((l+r)>>1);
		LL q=query(a*10+mid,len);
		if(Query(q)) r=mid-1;
		else l=mid+1;
	}
	return r+1;
}		
void JUDGE(){
	GetFirst();
	int len=9;
	while(1){
		int x=GetNewbit(len); --len;
		a=a*10LL+x;
		if(x==0){
			int cnt=0;
			for(LL y=a;y;y/=10) cnt+=y%10;
			LL y=a-1;
			if(cnt==1){
				if(Query(y)){
					ans=a/10;
					return;
				}
			}
			else{
				if(!Query(y)){
					ans=a/10;
					return;
				}
			}
		}
	}
}
int main(){
	JUDGE();
	printf("! %lld\n",ans);
	fflush(stdout);
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1e18
int main(){
  ll N,W;
  cin>>N>>W;
  ll w[N],v[N];
  for(int i=0;i<N;i++) cin>>w[i]>>v[i];
  vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(j<w[i]) dp[i+1][j]=dp[i][j];
      else dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
    }
  }
  cout<<dp[N][W];
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  vii arr(5);
  REP(i, 0, 5){
      int t, r;
      cin >> t;
      r = (t % 10 != 0) ? (10 - t % 10) : 0;
      arr[i] = {r, t};
  }
  sort(all(arr));
  
  int ans = 0;
  REP(i, 0, 5){
      ans += arr[i].second;
      if(ans % 10 != 0 && i != 4)
        ans += 10 - ans % 10;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,k;
cin>>n>>k;
int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
double dp[n]={};
for(int i=0;i<n;i++)
{
    int x=arr[i];
    dp[i]=(x*(x+1))/2;
    dp[i]/=(arr[i]*1.);
}
double ans=0;
double c=0;
for(int i=0;i<k;i++)
    {
        c+=dp[i];
    }
    ans=c;
    for(int i=k;i<n;i++)
    {
        int j=i-k;
        c-=dp[j];
        c+=dp[i];
        ans=max(ans,c);
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    int n=0;
    string s;
    cin>>s;
    if(s[0]=='A'){
        if(s[1]=='C' || s[s.size()-1]=='C'){
            cout<<"WA"<<endl;
            return 0;
        }
        rrep(i,s.size()-1) if(isupper(s[i]) && s[i]!='C'){
        cout<<"WA"<<endl;
        return 0;
        }
        for(int i=2;i<s.size()-1;i++){
            if(s[i]=='C') n++;
        }
        if(n==1) cout<<"AC"<<endl;
        else cout<<"WA"<<endl;
    }else cout<<"WA"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  string A,B,C;
  cin>>A>>B>>C;
  string ans;
  ans.push_back(toupper(A.at(0)));
  ans.push_back(toupper(B.at(0)));
  ans.push_back(toupper(C.at(0)));
  cout<<ans<<endl;
  }


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

const int base = 1000000007;

int inv(long long p)
{
  int q = base - 2, r = 1;
  while (q)
  {
    if (q & 1) r = r * p % base;
    
    p = p * p % base;
    q >>= 1;
  }
  
  return r;
}

int main()
{
  int n, k; cin >> n >> k;
  if (k == 1) { cout << 0 << endl; return 0; }
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  
  sort(a.begin(), a.end());
  for (int i = 1; i < n; ++i)
    a[i] = (a[i] + a[i-1]) % base;
  
  long long combi = 1;
  long long total = 0;
  for (int i = k; i <= n; ++i)
  {
    int total_i = ( (a[n-1] - a[i-2]) % base - a[n-i] ) % base * combi % base;
    total = (total + total_i) % base;
    
    combi = combi * (i-1) % base * inv(i-k+1) % base;
  }
  
  if (total < 0) total += base;
  cout << total << endl;
}

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

using namespace std;

int main(){
	int K;
	cin >> K;
	int A[] = {1,1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << A[K-1] << endl; //配列は0から始まるのでK-1を入力
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
	int count[123];
	for(int i = 97; i < 123; i++){
		count[i] = 0;
	}

	char c;
	while(scanf("%c", &c) != EOF){
		if(c > 96){
			count[c] += 1;
		}else{
			count[c + 32] += 1;
		}
	}

	for(int i = 97; i < 123; i++){
		printf("%c : %d\n", i, count[i]);
	}
	return 0;
}

Measured memory_bytes: 968
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int a[MAX_N];
int n;

const int N = 1 << 17;

int n_;
ll dat[2*N-1];

void init(int x)
{
	n_=1;
	while(n_<x){
		n_*=2;
	}
	rep(i,2*n_-1){
		dat[i] = 0;
	}
}

void update(int k,ll a)
{
	//????????????
	k += n_-1;
	dat[k] = a;
	//?????????????????´??°
	while(k>0){
		k = (k-1)/2;
		dat[k] = max(dat[2*k+1],dat[2*k+2]);
	}
}

//[a,b)???????°????????±??????????
//k??????????????????
//????????????query(a,b,0,0,n_)??¨???????????¶???(n_??¨???????????¨?????¨???)
ll query(int a,int b,int k,int l,int r)
{
	if(r <= a || b <= l){
		return 0;
	}
	if(a <= l && r <= b){
		return dat[k];
	}else{
		ll vl = query(a,b,2*k+1,l,(l+r)/2);
		ll vr = query(a,b,2*k+2,(l+r)/2,r);
		return max(vl,vr);
	}
}


int main()
{
	scanf("%d",&n);
	init(n+1);
	rep(i,n){
		scanf("%d",&a[i]);
	}
	rep(i,n){
		update(a[i],a[i] + query(1,a[i]+1,0,0,n_));
	}
	cout << accumulate(a,a+n,0LL) - query(1,n+1,0,0,n_) << "\n";
	return 0;
}

Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;
const int MAX = 510000;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long PER(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return (fac[n] * finv[n-k]) % MOD;
}

int main() {
    int n, k;
    cin >> n >> k;
    vec g[100010];
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    COMinit();

    vec chs(n, -1);
    vec dist(n, INF);
    dist[0] = 0;

    queue<int> que;
    que.push(0);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        int cnt = 0;

        for (auto&& c : g[v]) {
            if (dist[c] == INF) {
                dist[c] = dist[v] + 1;
                cnt++;
                que.push(c);
            }
        }
        chs[v] = cnt;
    }

    lint res = k;

    rep(i, n) {
        if (i == 0) {
            res *= PER(k-1, chs[i]);
        }
        else {
            res *= PER(k-2, chs[i]);
        }
        res %= MOD;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 19320