akhauriyash/Code-Regression huggingface dataset:
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
double calcTime()
{
    struct::timespec getTime;
    clock_gettime(CLOCK_MONOTONIC, &getTime);
    return (getTime.tv_sec + getTime.tv_nsec*1e-9);
}

mt19937 mrand(random_device{}());

ll v[400];
ll days[30] = {};
ll c[30];
ll s[370][30];
ll ans[400] = {};
ll D;

ll get_score(){
    ll score = 0;
    rep(i,0,26) days[i] = 0;

    rep(i,0,D){
        score += s[i][ans[i]];
        days[ans[i]] = i+1;
        rep(j,0,26){
            score -= c[j] * (i+1 - days[j]); 
        }
    }
    return score;
}

ll update_score(ll d, ll prev_val, ll after_val, ll cur){
    cur -= s[d][prev_val];
    cur += s[d][after_val];

    ll last_d1 = 0, last_d2 = 0;
    rep(i,0,D){
        if(ans[i] == prev_val){
            last_d1 = i+1;
        }
        if(ans[i] == after_val){
            last_d2 = i+1;
        }
        cur += c[prev_val] * (i+1 - last_d1);
        cur += c[after_val] * (i+1 - last_d2);
    }
    ans[d] = after_val;
    last_d1 = 0, last_d2 = 0;
    rep(i,0,D){
        if(ans[i] == prev_val){
            last_d1 = i+1;
        }
        if(ans[i] == after_val){
            last_d2 = i+1;
        }
        cur -= c[prev_val] * (i+1 - last_d1);
        cur -= c[after_val] * (i+1 - last_d2);
    }


    return cur;
}

void solve(){
    // print(365);
    // rep(i,0,26){
    //     cout << mrand() % 100 << " ";
    // }
    // cout << endl;
    // rep(i,0,365){
    //     rep(j,0,26){
    //         cout << mrand() % 20000 << " ";
    //     }
    //     cout << endl;
    // }
    // return;
    double start = calcTime();
    cin >> D;
    rep(i,0,26) cin >> c[i];

    rep(i,0,D){
        rep(j,0,26){
            cin >> s[i][j];
        }
    }

    rep(i,0,D){
        ll r = mrand() % 26;
        ans[i] = r;
        days[r] = i+1;
    }
    ll score = get_score();
    ll iter = 0;


    while(true){
        double x = calcTime() - start;
        if(x >= 1.9) break;
        ll temp = (ll)(10 * (x - 1.9) * (x - 1.9));
        iter++;
        ll d = mrand() % D;
        ll q = mrand() % 26;
        ll prev_val = ans[d];
        // ans[d] = q;
        // ll new_score = get_score();
        ll new_score = update_score(d,prev_val, q,score);
        if(new_score > score){
            score = new_score;
            // print(x);
        }else{
            // ans[d] = prev_val;

            ll r = mrand() % 10000;
            if(r <= temp){
                score = new_score;
            }else{
                ans[d] = prev_val;
            }
        }
    }
    // print(score);
    // print(iter);
    rep(i,0,D) print(ans[i]+1);

}

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

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

using namespace std;

int main() {
    long long int n, a, b;
    cin >> n >> a >> b;
    long long int red, tmp;
    red = (n / (a+b)) * a;
    tmp = n % (a+b);
    if(tmp < a) red += tmp;
    else red += a;
    cout << red << endl;
    return 0;
    }

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

class ABC171
{
    static void Main()
    {
        string alpha = Console.ReadLine();
        char al = (char)alpha[0];
        if (Char.IsUpper(al))
        {
            Console.WriteLine("A");
        }
        else
        {
            Console.WriteLine("a");
        }
    }
}

Measured memory_bytes: 25612
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (long long i = l; i < r; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
map<pair<int, int>, int> gmemo;
int gcd(int a, int b) {
	if (gmemo[{a, b}] != 0) return gmemo[{a, b}];
	if (gmemo[{b, a}] != 0) return gmemo[{b, a}];
	if (a % b == 0)
		return gmemo[{a, b}] = b;
	else
		return gmemo[{a, b}] = gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
bool prime(int a) {
	if (a == 1) return false;
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0) return false;
	}
	return true;
}
signed main() {
	int r,g,b,n,ans=0;
	cin>>r>>g>>b>>n;
	REP(i,0,(n/r)+5){
		REP(j,0,n/g+5){
			if((n-r*i-g*j)>=0&&(n-r*i-g*j)%b==0)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

  int total = 0, s;
  while(cin >> s){
    total += s;
  }
  int m = 0;
  while(total >= 60){
    m++;
    total -= 60;
  }
  cout << m << endl << total << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<algorithm>
using namespace std;

const int inf = 100110011;

int main(void){
        int i,j;
        int h,n;
        int a[1010],b[1010];

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

        int dp[10010];
        dp[0]=0;

        for(i=1;i<=h;i++){
                dp[i]=inf;
                for(j=0;j<n;j++){
                        if(dp[max(i-a[j],0)]+b[j] < dp[i]){
                                dp[i] = dp[max(i-a[j],0)]+b[j];
                        }
                }
        }
        printf("%d\n", dp[h]);
        return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from itertools import product
from collections import Counter, defaultdict
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

H, W, K = inpl()
Ix = []
Iy = []
R = [0]*H
for h in range(H):
    s = input()
    for w in range(W):
        if s[w] == "#":
            R[h] += 1
            Ix.append(w)
            Iy.append(h)
u = 0
i = 0
ans = [[0]*W for _ in range(H)]
for h in range(H):
    if R[h] == 0:
        continue
    for d in range(h+1, H+1):
        if d == H:
            break
        if R[d] != 0:
            break
    l = 0
    for j in range(R[h]):
        if j == R[h]-1:
            r = W
            nl = 0
        else:
            r = Ix[i+1]
            nl = r*1
        for y in range(u, d):
            for x in range(l, r):
                ans[y][x] = i+1
        i += 1
        l = nl
    u = d

print(*list(" ".join(map(str, a)) for a in ans), sep="\n")

Measured memory_bytes: 49624
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// Scane Standard Input
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {

	for {
		target := nextLine()

		if target == "-" {
			return
		}

		count, _ := strconv.Atoi(nextLine())

		for i := 0; i < count; i++ {
			h, _ := strconv.Atoi(nextLine())
			a := target[:h]
			b := target[h:]
			target = b + a
		}
		fmt.Println(target)
	}
}



Measured memory_bytes: 1092
#include<bits/stdc++.h>
using namespace std;
int main(){
	int C[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>C[i][j];
		}
	}bool flag=true;int a;
	for(int i=0;i<3;i++){
		a=C[0][i]-C[0][0];
		for(int j=0;j<3;j++){
			if(C[j][i]-C[j][0]!=a){
				flag=false;
			}
		}
	}for(int i=0;i<3;i++){
		a=C[i][0]-C[0][0];
		for(int j=0;j<3;j++){
			if(C[i][j]-C[0][j]!=a){
				flag=false;
			}
		}
	}if(flag==true){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	

	

	
	for (int x = 1; x <= 9; x++){
		for (int i = 1; i <= 9; i++){
			cout << x << "x"<< i << "=" << i * x << "\n"; 
		
		}
	}
	
	return (0);
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> ivec;
const ll N = 1e9+7;
const ll M = 2019;

int main(){
    int l,r;cin >> l >> r;
    if(r-l >= 2019){
        cout << 0 << endl;
        return 0;
    }
    int middle = r-l+1;
    r %= M;
    l %= M;
    int ans = N;
    rep(i,middle){
        rep(j,middle){
            if(i >= j)continue;
            int temp = (i+l)*(l+j)%M;
            // cout << temp << endl;
            ans = min(ans,temp);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)

























int main(){
    int x;
    double p;
    cin >> x >> p;
    p /= 100.0;
    double xx = (x + 1) / 2;
    printf("%.11lf\n", xx / p);
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
    int n,t,i,maxnum=1001,gt,end=0;
    int ary[1000][2];
    scanf("%d %d",&n,&t);
    for(i=0;i<n;i++){
        scanf("%d %d",&ary[i][0],&ary[i][1]);
    }
    for(i=0;i<n;i++){
        if(ary[i][1]<=t){
            if(maxnum>=ary[i][0]){
                maxnum=ary[i][0];
                gt=i;
                end++;
            }
        }
    }
    if(end!=0){
        printf("%d\n",ary[gt][0]);
    }else{
        puts("TLE");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include "boost/multiprecision/cpp_int.hpp"
using ll = long long;
using ull = unsigned long long;
namespace mp = boost::multiprecision;

int main() {

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

	ull N; std::cin >> N;
	std::map<ull, int> map;
	for (int i = 0; i < N; i++) {
		ull tmp;
		std::cin >> tmp;
		map[tmp]++;
	}
	for (auto itr = map.begin(); itr != map.end();) {
		if (itr->second < 2)map.erase((itr++)->first);
		else ++itr;
	}
	

	ull ans = 0;

	if (!map.empty()) {
		auto front = map.rbegin();//rbegin()は逆向きのイテレータ(mapはキーの値でソートされているため)
		if ((front->second) >= 4)ans = (front->first) * (front->first);
		else if (std::next(front) != map.rend()) {
			auto next = std::next(front);
			ans = (front->first) * (next->first);
		}
	}


	std::cout << ans;

	return 0;

}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second

using namespace std;

const double INF = 1e9;

int N, M, P, A, B;
double t[10], road[35][35], dp[35][(1<<8)];
int testCnt = 0;

double dfs(int nowNode, int ticketState){
  if(nowNode == B-1) return 0;
  if(ticketState == 0) return INF;
  if(dp[nowNode][ticketState] != -1.0) return dp[nowNode][ticketState];
  double ret = INF;
  //bool flag = false;
  REP(nextNode, 0, M){
    if(road[nowNode][nextNode] == INF) continue;
    REP(ticket, 0, N){
      if(!(ticketState & (1<<ticket))) continue;
      ret = min(ret, dfs(nextNode, ticketState^(1<<ticket) ) + road[nowNode][nextNode]/t[ticket] );
    }
  }
  testCnt++;
  return dp[nowNode][ticketState] = ret;
}

int main() {
  while(1){
    cin>>N>>M>>P>>A>>B;
    if(N==0) break;
    REP(i,0,N) cin>>t[i];
    REP(i,0,M)REP(j,0,M) road[i][j] = INF;
    REP(i,0,P){
      int x, y;
      double z;
      cin>>x>>y>>z;
      x--; y--;
      road[x][y] = road[y][x] = z;
    }
    REP(i,0,M)REP(j,0,(1<<N)) dp[i][j] = -1.0;
    double ans = dfs(A-1,(1<<N)-1);
    if(ans < INF) printf("%.5lf\n", ans);
    else cout<<"Impossible"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3280
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <cmath>
//#include <iomanip>
//#include <map>
//#include <unordered_map>
//#include <cstring>
#include <queue>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
// ll INF = 1LL << 60;

int W, H;
int dh[4] = { 1, 0, -1, 0 }; // down, right, up, left
int dw[4] = { 0, 1, 0, -1 };

int main() {
	while (cin >> W >> H) {
		if (W == 0 && H == 0) break;
		vector<vector<int>> dist(H, vector<int>(W, -1));
		vector<vector<int>> vertical_wall(H, vector<int>(W - 1));
		vector<vector<int>> horizontal_wall(H - 1, vector<int>(W));

		for (int i = 0; i < (2 * H - 1); i++) {
			int h = i / 2;
			if (i % 2 == 0) {
				for (int w = 0; w < W - 1; w++) cin >> vertical_wall[h][w];
			}
			else {
				for (int w = 0; w < W; w++) cin >> horizontal_wall[h][w];
			}
		}

		queue<pint> q;
		q.push(make_pair(0, 0));
		dist[0][0] = 1;

		while (!q.empty()) {
			pint hw = q.front();
			int h = hw.first;
			int w = hw.second;
			q.pop();
			for (int dir = 0; dir < 4; dir++) {
				int nh = h + dh[dir];
				int nw = w + dw[dir];
				if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
				if (dist[nh][nw] != -1) continue;
				if (dir == 0) {
					// down
					if (horizontal_wall[h][w] == 1) continue;
				}
				if (dir == 1) {
					// right
					if (vertical_wall[h][w] == 1) continue;
				}
				if (dir == 2) {
					// up
					if (horizontal_wall[h - 1][w] == 1) continue;
				}
				if (dir == 3) {
					// left
					if (vertical_wall[h][w - 1] == 1) continue;
				}
				q.push(make_pair(nh, nw));
				dist[nh][nw] = dist[h][w] + 1;
			}
		}

		/*for (int h = 0; h < H; h++) {
			for (int w = 0; w < W; w++) cout << dist[h][w] << " ";
			cout << endl;
		}*/

		 if (dist[H - 1][W - 1] == -1) cout << 0 << endl;
		 else cout << dist[H - 1][W - 1] << endl;

	}
	return 0;
}


Measured memory_bytes: 3088
s = input()
n = len(s)

ans = 0
for i in range(1<<(n-1)):
	b = 1
	# print('')
	for j in range(n):
		# print(int(s[-1-j])*b)
		ans += int(s[-1-j])*b
		# print('i = '+str(i)+',j = '+str(j))
		if i&(1<<j):
			b *= 10
		else:
			b = 1

print(ans)

Measured memory_bytes: 39664
from math import gcd
def euler_phi(n):
    res=n
    for x in range(2,int(n**.5)+2):
        if n%x==0:
            res=(res//x)*(x-1)
            while n%x==0:
                n//=x
    if n!=1:
        res=(res//n)*(n-1)
    return res

def biggcd(n,m):
    g=gcd(n,m);res=g;count=2
    while gcd(g**count,m)>res:
        res=gcd(g**count,m)
        count+=1
    return res

def solve(a,m,n):
    if gcd(a,m)==1:
        if m==1: return 1
        phi=euler_phi(m);G=gcd(phi,m);r0=solve(a,G,n);mod=m*phi//G
        return ((((pow(a,n*r0,mod)-n*r0)%mod)//G)*pow(n*phi//G,phi-1,m)*phi+r0)%mod
    big=biggcd(a,m);k0=solve(a,m//big,n*big)
    return big*k0

for i in range(int(input())):
    A,M=map(int,input().split())
    print(solve(A,M,1))


Measured memory_bytes: 74404
macro_rules! read {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}

fn read_trim() -> String {
    read!().trim().to_owned()
}

fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
    read!().split_whitespace()
        .map(|e| e.parse::<T>().ok().unwrap())
        .collect()
}

fn main() {
    let n: i32 = read_to_vec()[0];
    let mut input: Vec<String> = Vec::new();

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

    input.sort();

    let mut output: String = String::new();

    for e in input.iter() {
        output.push_str(e)
    }

    println!("{}", output)
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

class UnionFindTrees{
	public:
		UnionFindTrees(int _n){
			n = _n;
			root = vector<int>(_n);
			rep(i,_n) root[i] = i;
		}
		int find(int x){
			if(root[x]==x) return x;
			else return root[x]=find(root[x]);			
		}
		bool same(int x, int y){
			return find(x)==find(y);
		}
		void union_tree(int x, int y){
			if(same(x,y)) return;
			int rt_x = root[x];
			int rt_y = root[y];	
			root[rt_y] = rt_x;
			n--;			
		}
		int forest_size(){return n;}
	private:
		vector<int> root;
		int n;

};

int main(void) {
	int n,m; cin >> n >> m;
	UnionFindTrees uft(n);
	rep(i,m){
		int x,y,z; cin >> x >> y >> z;
		x--; y--;
		uft.union_tree(x,y);
	}
	cout << uft.forest_size() << endl;
}




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

int main() {
    int k;
    cin >> k;
    int s = 7, ans = 1;
    while (ans <= k) {
        if (s % k == 0) {
            cout << ans << endl;
            return 0;
        }
        s = (s % k)*10 + 7;
        ans++;
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3644
import copy

def show(C):
    N=len(C)
    for i in range(N):
        if i<N-1:
            print(C[i][0]+str(C[i][1]),end=' ')
        else:
            print(C[i][0]+str(C[i][1]))
    
def BubbleSort(C,N):
    for i in range(N):
        for j in reversed(range(i+1,N)):
            if int(C[j][1])<int(C[j-1][1]):
                C[j],C[j-1]=C[j-1],C[j]
    return C

def SelectionSort(C,N):
    for i in range(N):
        minj=i
        for j in range(i,N):
            if int(C[minj][1])>int(C[j][1]):
                minj=j
        C[i],C[minj]=C[minj],C[i]
    return C

def compare(C1,C2):
    for i in range(1,10):
        l1=[]
        for c in C1:
            if int(c[1])==i:
                l1.append(c)
        l2=[]
        for c in C2:
            if int(c[1])==i:
                l2.append(c)
        for j in range(min(len(l1),len(l2))):
            if l1[j][0]!=l2[j][0]:
                return False
    return True
   
N=int(input())
l=list(input().split())
deck=[]
for c in l:
    deck.append((c[0],c[1]))

deck1=copy.copy(deck)
deck2=copy.copy(deck)

deck1=BubbleSort(deck1,N)
deck2=SelectionSort(deck2,N)

show(deck1)
compare(deck,deck1)
print('Stable' if compare(deck,deck1) else 'Not stable')
show(deck2)
print('Stable' if compare(deck,deck2) else 'Not stable')


Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

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

    ll n,i,ans=0;
    cin>>n;
    vector<ll> a(n+1), b(n+1);
    b[0] = 1e6;
    for(i=1;i<=n;i++) 
    {
        cin>>a[i];
        b[i] = min(b[i-1], a[i]);
        if(b[i] == a[i]) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3328
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in sum=0ll;
    in n;
    cin>>n;
    rep(i,n+1){
        if(i%3ll==0ll || i%5ll==0ll) continue;
        sum +=i;
    }
    cout<<sum<<endl;
}
//./problem.exe

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	int ans = INF;
	for (int i = 1; i*i <= N; i++) {
		if (N%i == 0) {
			int x = i;
			int y = N / i;
			chmin(ans, x + y - 2);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
signed main() {
    int N, M;
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        if(i % 2 == 1) {
            cout << (M + 1) / 2 - (i - 1) / 2 << ' ' << (M + 1) / 2 + (i + 1) / 2 << endl;
        } else {
            int a = (M + 1) / 2 * 2 + 1;
            cout << M / 2 - (i / 2) + a << ' ' << a + M / 2 + (i / 2) << endl;
        }
    }
}


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

int main() {
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  if (2*x == W && 2*y == H) {
    cout << W * H / 2.0 << " " << 1 << endl;
  }
  else {
    cout << W * H / 2.0 << " " << 0 << endl; 
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int X, Y;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> X >> Y;
    if (X % Y == 0) printf("-1\n");
    else printf("%d\n", X);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int n,a, k = 1;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a == k) k++;
    }
    if (k == 1) cout << -1 << endl;
    else cout << n - k+1 << endl;
}
  

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

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

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

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

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


int main()
{
  string l; cin >> l;
  int n = l.size();
  vector<vector<mint>> dp(n+1, vector<mint>(2, 0));

  dp[0][0] = 1;
  rep(i, n) {
    int x = l[i]-'0';
    rep(j, 2) {
      rep(c, (j?2:(x+1))) dp[i+1][j || c < x] += dp[i][j] * (int)pow(2, c);
    }
  }

  mint ans = dp[n][0]+dp[n][1];
  cout << ans.x << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s;
    cin >> s;
    if(s=='A'){
        cout << "T" << endl;
    }
    else if(s=='T'){
        cout << "A" << endl;
    }
    else if(s=='G'){
        cout << "C" << endl;
    }
    else cout << "G" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> P;

vector<vector<int>> edge;
vector<int> dist;
void dfs(int now, int par, int d)
{
  dist[now] = d;
  for (auto& to : edge[now]) {
    if (to != par) dfs(to, now, d + 1);
  }
}

int main()
{
  int N; cin >> N;
  edge.resize(N);
  dist.resize(N);
  vector<pair<int, int>> edge_list;
  REP(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    edge[a].PB(b);
    edge[b].PB(a);
    edge_list.PB(MP(a, b));
  }
  vector<int> c(N);
  REP(i, N) cin >> c[i];
  dfs(0, -1, 0);
  int s = 0, ma = 0;
  REP(i, N) {
    if (ma < dist[i]) {
      s = i;
      ma = dist[i];
    }
  }
  REP(i, c.size()) dist[i] = 0;
  dfs(s, -1, 0);
  s = 0, ma = 0;
  REP(i, N) {
    if (ma < dist[i]) {
      s = i;
      ma = dist[i];
    }
  }
  dfs(s, -1, 0);
  
  vector<pair<int, int>> v;
  REP(i, N) v.PB(MP(dist[i], i));
  sort(ALL(v));
  sort(ALL(c), greater<int>());

  vector<int> ans(N);
  REP(i, N) ans[v[i].SE] = c[i];

  int score = 0;
  for (auto e : edge_list) {
    score += min(ans[e.FI], ans[e.SE]);
  }
  cout << score << endl;
  REP(i, N) cout << ans[i] << ' ';
  cout << endl;

  return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>

int main(){
  long long n,a,b;
  long long sum;
  long long r;

  scanf("%lld %lld %lld", &n, &a, &b);

  sum = a + b;

  r = n % sum;

  if(r < a) printf("%lld\n", n/sum*a + r);

  else printf("%lld\n", n/sum*a + a);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    
    vector<int> L;
    for (int i=0; i < n; i++)
    {
        int val;
        cin >> val;
        L.push_back(val);
    }
    
    sort(L.begin(), L.end());

    int count = 0;
    for (int i=0; i < n-2; i++)
    {
        for (int j=i+1; j < n-1; j++)
        {
            for (int k=j+1; k < n; k++)
            {
                if (L[i] + L[j] > L[k])
                {
                    count++;
                }
            }
        }
    }
    
    cout << count;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
signed main(){
  int a;
  cin>>a;
  double b=100;
  int c;
  rep1(i,10000){
  b+=floor(b/100);
    if(b>=a){
      c=i;
      break;
      }
  }
  cout<<c;
}


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

int Check(vector<int> &b) {
	
	for (int i =b.size()-1; i >= 0; i--) {
		if (b[i] == i + 1) {
			int temp = b[i];
			if (b.size() == 1) {
				cout << temp << endl;
				return 1;
			}
			else {
				b.erase(b.begin() + i);
			}
			if (Check(b) == 1) {
				cout <<temp << endl;
				return 1;
			}
			b.insert(b.begin() + i, temp);
		}
	}
	return 0;

}

int main() {
	int n;
	cin >> n;
	vector<int> b;
	for (int i = 0; i < n; i++) {
		int tmp;

		cin >> tmp;
		b.push_back(tmp);
		if (b[i] > i + 1) {
			cout << "-1";
			return 0;
		}
	}
	if (Check(b) == 0) {
		cout << "-1";
	}


	return 0;
}


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

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define yes cout<<"Yes"<<nl
#define no cout<<"No"<<nl
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}


int main()
{
   su;
   int x;
   cin>>x;
   if(x>=30)
    yes;
   else
    no;
   return 0;
}


Measured memory_bytes: 3608
# ABC145 A
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
s=si()

if n%2==1:
    print('No')
else:
    nn = int(n/2)
    ss = s[0:nn]
    a = s.count(ss)
    if a==2:
        print('Yes')
    else:
        print('No')

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

int main() {
    int A,B,C,X;
    cin >> A >> B >> C >> X;
    int count = 0;
    for(int a=0; a <= A; a++){
        for(int b=0; b <= B; b++){
            for(int c=0; c <= C; c++){
                int total = a * 500 + b * 100 + c * 50;
                if(total == X) count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

#define BLDG_N 4
#define FLOOR_N 3
#define ROOM_N 10

using namespace std;

int main(void){
    int n;
    string input;
    vector< vector< vector< int > > > room;
    
    for(int i = 0; i < BLDG_N; i++){
        vector< vector< int > > bldg;
        room.push_back(bldg);
        for(int j = 0; j < FLOOR_N; j++){
            vector< int > floor;
            room[i].push_back(floor);
            for(int k = 0; k < ROOM_N; k++){
                room[i][j].push_back(0);
            }
        }
    }
    
    getline(cin, input);
    sscanf(input.c_str(), "%d\n", &n);
    
    for(int i = 0; i < n; i++){
        int b, f, r, v;
        
        getline(cin, input);
        sscanf(input.c_str(), "%d %d %d %d\n", &b, &f, &r, &v);
        
        room[b - 1][f - 1][r - 1] += v;
    }
    
    for(int i = 0; i < BLDG_N; i++){
        for(int j = 0; j < FLOOR_N; j++){
            for(int k = 0; k < ROOM_N; k++){
                printf(" %d", room[i][j][k]);
            }
            printf("\n");
        }
        if(i != BLDG_N - 1) printf("####################\n");
    }
    
    return(0);
    
}



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

int next_combination(int comb) {
    int x = comb & -comb, y = comb + x;
    return ((comb & ~y) / x >> 1) | y;
}

int main() {
    int n, k;
    while (cin >> n >> k, n) {
        vector<string> cards(n);
        for (int i = 0; i < n; i++) cin >> cards[i];
        sort(cards.begin(), cards.end());
        unordered_set<string> res;
        for (int bit = (1 << k) - 1; bit < 1 << n; bit = next_combination(bit)) {
            vector<string> member;
            for (int i = 0; i < n; i++) {
                if (bit & (1 << i)) member.push_back(cards[i]);
            }
            do {
                string tmp = "";
                for (int i = 0; i < k; i++) tmp += member[i];
                res.insert(tmp);
            } while (next_permutation(member.begin(), member.end()));
        }
        cout << res.size() << endl;
    }
    return 0;
}


Measured memory_bytes: 3400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#include <string>
string char_to_str(char c){string tem(1,c);return tem;}
 
typedef pair<int, int> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
int main() 
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	int a[n][3];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i][0];
		cin>>a[i][1];
		cin>>a[i][2];
	}
	int ans[n][3];
	ans[0][0] = a[0][0];
	ans[0][1] = a[0][1];
	ans[0][2] = a[0][2];
	for (int i = 1; i < n; ++i)
	{
        ans[i][0]=a[i][0]+max(ans[i-1][1], ans[i-1][2]);
        ans[i][1]=a[i][1]+max(ans[i-1][2], ans[i-1][0]);
        ans[i][2]=a[i][2]+max(ans[i-1][0], ans[i-1][1]);
	}
	cout<<max(ans[n-1][0],max(ans[n-1][1],ans[n-1][2]));
    return 0;
} 

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

vector<string>ans;
void f(string a){
    if(a.size()==3){
        ans.push_back(a);
        return;
    }
    for (int i = 0; i < 10; ++i) {
        a+=(char)('0'+i);
        f(a);
        a.pop_back();
    }
}

int main(){
    f("");
    ll n;cin >>n;
    string s;cin >>s;
    ll cnt=0;
    for(auto a:ans){
        ll k=0;
        for (int i = 0; i < n; ++i) {
            if(a[k]==s[i]){
                if(k==2){
                    cnt++;
                    break;
                }
                else k++;
            }
        }
    }
    cout <<cnt <<endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int a[100010];

int main()
{
    int n;
    int last=0;long long ans=0;
    scanf("%d",&n);

    for (int i=1;i<=n+1;i++)
        scanf("%d",&a[i]);
    for (int i=1;i<=n;i++)
    {
        int tmp;scanf("%d",&tmp);
        if (tmp<=a[i]){
            a[i]-=tmp;
            ans+=tmp;
            last=0;
        }
        else{
            ans+=a[i];
            tmp-=a[i];
            if (tmp<=a[i+1]){
                a[i+1]-=tmp;ans+=tmp;
            }
            else{
                ans+=a[i+1];a[i+1]=0;
            }
        }
    }

    printf("%lld\n",ans);
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int s = scanner.nextInt();
        int max = 0;
        int tmp = 0;
        int sum = 0;

        for(int i = 0;i<s;i++) {
        	tmp = scanner.nextInt();
        	if(max <= tmp) {
        		max=tmp;
        	}
        	sum += tmp;
        }
        System.out.println((sum-max+(max/2)));

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 21076
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, ans = 0;
	cin >> n;
	vector<int> a(n);
	rep (i, n) cin >> a[i];
	sort(all(a)/*, [](int a, int b) {return a > b;}*/);
	// rep (i, n) eprintf("%d ", a[i]); eprintf("\n");
	vector<bool> used(n);
	reprev (i, n) {
		if (used[i]) continue;
		used[i] = true;
		int k = 0, tmp = a[i];
		while (tmp != 0) {
			tmp >>= 1;
			k++;
		}
		tmp = (1 << k) - a[i];
		eprintf("%d+%d=2^n\n", a[i], tmp);
		auto p = equal_range(all(a), tmp);
		int ng = min((int)i, (int)distance(a.begin(), p.second) - 1);
		while (ng > 0 && a[ng - 1] == tmp && used[ng]) ng--;
		if (ng >= 0 && a[ng] == tmp && !used[ng]) {
			eprintf("(%lld,%d)\n", i, ng);
			ans++;
			used[ng] = true;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
char str[200005];
int main() {
	int n;
	scanf("%d%s", &n, str);
	int numr = 0, numw = 0;
	for (int i = 0; i < n; ++i) {
		numr += str[i] == 'W';
		numw += str[i] == 'R';
	}
	int r = 0, w = 0, ans = n;
	for (int i = 0; i <= n; ++i) {
		int rr = numr - r;
		int ww = numw - w;
		int mn = min(r, ww);
		int need = r + ww - mn;
		ans = min(ans, need);
		if (i == n) break;
		r += str[i] == 'W';
		w += str[i] == 'R';
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3972
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;
int n;
vector<int> al[100005];
vector<int> v[100005];
bool visited[100005];
const int mod=1000000007;
int memo[100005];
void dfs(int i){
    visited[i]=true;
    for (vector<int>::iterator it=al[i].begin();it!=al[i].end();it++){
        if (!visited[*it]){
            dfs(*it);
            v[i].push_back(*it);
        }
    }
}
int dp1(int i);
int dp2(int i);
int dp1(int i){ //white
    if (memo[i]!=-1) return memo[i];
    long long ans=1;
    for (vector<int>::iterator it=v[i].begin();it!=v[i].end();it++){
        ans*=dp1(*it)+dp2(*it);
        ans%=mod;
    }
    return memo[i]=ans;
}
int dp2(int i){ //black
    long long ans=1;
    for (vector<int>::iterator it=v[i].begin();it!=v[i].end();it++){
        ans*=dp1(*it);
        ans%=mod;
    }
    return ans;
}
int main(){
    //freopen("input.txt","r",stdin);
    memset(visited,false,sizeof(visited));
    memset(memo,-1,sizeof(memo));
    scanf("%d",&n);
    int a,b;
    for (int x=1;x<n;x++){
        scanf("%d%d",&a,&b);
        al[a].push_back(b);
        al[b].push_back(a);
    }
    dfs(1);
    printf("%d\n",(dp1(1)+dp2(1))%mod);
}


Measured memory_bytes: 17280
// 2020-07-11 20:59:42
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  REPC(i, l, r) {
    if(i % d == 0) ans++;
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3600
//
//  main.cpp
//  F
//
//  Created by 曾憲揚 on 2020/8/12.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;

int a[maxn];
vector<int> e[maxn];
//bool vis[maxn];
int dp[maxn];
int ans[maxn];

int bs(int l, int r, int t){
    //cout << "BS\n";
    if(dp[0] >= t) return 0;
    if(dp[r] < t) return r+1;
    
    while(r > l){
        //cout << l << r << endl;
        int m = (l+r)/2;
        if(dp[m] < t) l=m+1;
        else r = m;
    }
    
    //cout << "BS" << r << endl;
    return r;
}

void dfs(int p, int cur, int r){
    //cout << p << " " << cur << " " << r << " " << a[cur] << '\n';
    int pos = bs(0, r, a[cur]);
    
    int reg = dp[pos];
    dp[pos] = a[cur];
    
    ans[cur] = pos== (r+1) ? ++r + 1: r + 1;
    for(int i: e[cur]){
        if(i!=p) dfs(cur, i, r);
    }
    dp[pos] = reg;
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //memset(vis, 0, sizeof(vis));
    
    int n; cin >> n;
    fill(dp, dp+n+1, 2e9);
    
    for(int i=0; i<n; i++)
        cin >> a[i];
    for(int i=1; i<n ; i++){
        int u, v; cin >> u >> v;
        u--; v--;
        e[u].push_back(v); e[v].push_back(u);
    }
    dfs(0, 0, -1);
    for(int i=0; i<n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 31252
#include<stdio.h>
int main(){
	int S,h,m,s,a;
	scanf("%d",&S);
	h=S/3600;
	a=S%3600;
	m=a/60;
	s=a%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 2760
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    int n;
    scanf("%d",&n);
    double ans;
    if (n % 2 == 0) ans = 0.5;
    else if (n == 1) ans = 1;
    else ans = (double)((n+1)/2)/n;
    printf("%lf\n",ans);
}

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

bool has9(int x) {
	while (x) {
		if (x % 10 == 9)return true;
		x /= 10;
	}
	return false;
}

void call(int x) {
	if (has9(x))cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

	call(N);

}


Measured memory_bytes: 256