akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

string dp[10010];

int main() {
    ll N, M;
    cin >> N >> M;
    bool num[10];
    fill(num, num + 10, false);
    ll mnum[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
    string digit[10] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
    ll A[M];
    REP(i, 0, M) {
        cin >> A[i];
        num[A[i]] = true;
    }
    ll numbo[9];
    fill(numbo, numbo + 9, 0);
    REP(i, 0, 10) {
        if (num[i]) {
            numbo[mnum[i - 1]] = i;
        }
    }
    fill(dp, dp + 10010, "");
    REP(i, 0, N) {
        if (i == 0 || dp[i] != "") {
            REP(j, 2, 8) {
                if (numbo[j] > 0) {
                    string tmp = dp[i] + digit[numbo[j]];
                    sort(tmp.begin(), tmp.end());
                    reverse(tmp.begin(), tmp.end());
                    if (dp[i + j].size() < tmp.size()) {
                        dp[i + j] = tmp;
                    } else if (dp[i + j].size() == tmp.size()) {
                        dp[i + j] = max(dp[i + j], tmp);
                    }
                }
            }
        }
    }
    string ans = dp[N];
    cout << ans << endl;
}


Measured memory_bytes: 26880
def CountingSort(A, k):
    n = len(A)
    C = [0for i in range(k+1)]
    #C[i] に i の出現数を記録する
    for i in range(n):
        C[A[i]] += 1
    #C[i] に i 以下の数の出現数を記録する
    for i in range(1,k+1):
        C[i] += C[i-1]
    
    B = [0for i in range(n)]  ##출력 배열 (出力配列)
    for j in range(n):
        B[C[A[j]]-1] = A[j]
        C[A[j]] -= 1
    return B
        
n = int(input())
A = list(map(int, input().split()))
k = max(A)
print(*CountingSort(A,k))



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

int main(){
	int N;
	cin >> N;
	vector<int> A(N),sortedA(N);
	for(int i(0);i<N;i++){
		cin >> A[i];
		sortedA[i] = A[i];
	}
	sort(sortedA.begin(),sortedA.end());
	int minA(sortedA[0]), maxA(sortedA[N-1]),maxCnt(0);
	for(int i(0);i<N;i++){
		if(A[i] == maxA) maxCnt++;
	}

	if(minA == maxA){
		for(int i(0);i<N;i++) cout<< minA << endl;
	}else{
		for(int i(0);i<N;i++){
			if(A[i] == maxA){
				if(maxCnt == 1){
					cout << sortedA[N-2] << endl;
				}else{
					cout << maxA << endl;
				}
			}else{
				cout << maxA << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
    int n;
    cin>>n;
    vector<int>num(n);
    vector<vector<pair<int,int>>>p(n);
    rep(i,n){
      cin>>num[i];
      rep(j,num[i]){
        int x,y;
        cin>>x>>y;
        x--;
        p[i].eb(x,y);
      }
    }
    int ans=0;
    for(int bit=0;bit<(1<<n);++bit){
      int cnt=0;
      bool flag=true;
      vector<int>a(n);
      vector<vector<int>>b(n);
      rep(i,n){
        if(bit&(1<<i)){
          ++cnt;
          a[i]=1;
        }
        rep(j,num[i]){
          if(a[i])b[p[i][j].first].pb(p[i][j].second);
        }
      }
      rep(i,n){
        rep(j,b[i].size()){
          if(a[i]!=b[i][j])flag=false;
        }
      }
      if(flag)chmax(ans,cnt);
    }
    cout<<ans<<"\n";
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string a;
int main()
{
	cin>>a;
	for(int i=0;i<a.length();++i)
	{
		if(a[i]=='C')
		{
			for(int j=i+1;j<a.length();++j)
			{
				if(a[j]=='F')
				{
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
# 貪欲法 + 山登り法 + 3点スワップ操作
import time
s__ = time.time()
limit = 1.9
#limit = 10

from numba import njit
import numpy as np

d = int(input())
cs = list(map(int, input().split()))
cs = np.array(cs, dtype=np.int64)
sm = [list(map(int, input().split())) for _ in range(d)]
sm = np.array(sm, dtype=np.int64)

@njit('i8(i8[:], i8)', cache=True)
def total_satisfaction(ts, d):
    ls = np.zeros(26, dtype=np.int64)
    s = 0
    for i in range(d):
        t = ts[i]
        t -= 1
        s += sm[i][t]
        ls[t] = i + 1

        dv = cs * ((i+1) - ls)
        s -= dv.sum()
    return s

@njit('i8[:]()', cache=True)
def greedy():
    ts = np.array([0] * d, dtype=np.int64)
    for i in range(d):
        mx = -1e10
        mxt = None
        for t in range(1, 26+1):
            ts[i] = t
            s = total_satisfaction(ts, i + 1)
            if s > mx:
                mx = s
                mxt = t
        ts[i] = mxt
    return ts

@njit('i8(i8, i8[:])', cache=True)
def loop(mxsc, ts):
    it = 100
    rds = np.random.randint(0, 6, (it,))
    rdd = np.random.randint(1, d, (it,))
    rdq = np.random.randint(1, 26, (it,))
    rdx = np.random.randint(1, 12, (it,))
    rdy = np.random.randint(1, 12, (it,))
    c1 = 0
    c2 = 3
    for i in range(it):
        bk1 = 0
        bk2 = 0
        bk3 = 0
        if rds[0] <= c1:
            # trailing
            di = rdd[i]
            qi = rdq[i]

            bk1 = ts[di]
            ts[di] = qi
        elif rds[0] <= c2:
            # swap
            di = rdd[i]
            xi = rdx[i]
            if di + xi >= d:
                xi = di - xi
            else:
                xi = di + xi
            
            bk1 = ts[di]
            bk2 = ts[xi]
            ts[di] = bk2
            ts[xi] = bk1
        else:
            # triswap
            di = rdd[i]
            xi = rdx[i]
            if di + xi >= d:
                xi = di - xi
            else:
                xi = di + xi
            yi = rdy[i]
            if xi + yi >= d:
                yi = xi - yi
            else:
                yi = xi + yi
            
            bk1 = ts[di]
            bk2 = ts[xi]
            bk3 = ts[yi]
            ts[di] = bk2
            ts[xi] = bk3
            ts[yi] = bk1

        sc = total_satisfaction(ts, d)

        if sc > mxsc:
            #print(mxsc, '->', sc)
            mxsc = sc
        else:
            # 最大値を更新しなかったら戻す
            if rds[0] <= c1:
                ts[di] = bk1
            elif rds[0] <= c2:
                ts[di] = bk1
                ts[xi] = bk2
            else:
                ts[di] = bk1
                ts[xi] = bk2
                ts[yi] = bk3

    return mxsc

ts = greedy()
mxsc = total_satisfaction(ts, d)
mxbk = mxsc

s_ = time.time()
mxsc = loop(mxsc, ts)
e_ = time.time()

consume = s_ - s__
elapsed = e_ - s_
#print('consume:', consume)
#print('elapsed:', elapsed)

if consume < limit:
    lp = int((limit - consume) / elapsed)
    #print('loop', lp)
    for _ in range(lp):
        mxsc = loop(mxsc, ts)

for t in ts:    print(t)
#print(mxbk, mxsc)
#print(time.time() - s__)


Measured memory_bytes: 124704
#include <stdio.h>

int is_leap(int year)
{
  return (year % 400 == 0) || (year % 100 != 0 && year % 4 == 0);
}


int main(void)
{
  int sep = 0;

  while (1) {
    int first, last;
    int year;
    int count;

    scanf("%d %d", &first, &last);
    if (first == 0 && last == 0) break;
    if (sep) {
      printf("\n");
    }
    else {
      sep = 1;
    }

    count = 0;
    for (year = first; year <= last; year++) {
      if (is_leap(year)) {
        count++;
        printf("%d\n", year);
      }
    }
    if (count == 0) {
      printf("NA\n");
    }
  }
  return (0);
}

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

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

	int n1=n;
	int sum=0;
	while(n){
		sum+=n%10;
		n/=10;
	}

	cout<< ((n1%sum==0)?"Yes":"No") <<endl;

}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
    static class Reader 
    { 
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} 
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];} 
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;} 
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();} 
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;} 
        public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;} 
        public double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } 
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } 
        public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;}
    }
    
    

    //       |----|       /\      |    |   -----   |
    //       |   /       /  \     |    |     |     |
    //       |--/       /----\    |----|     |     |
    //       |   \     /      \   |    |     |     |
    //       |    \   /        \  |    |   -----   -------
    
    
    public static void main(String[] args)throws IOException
    {
        PrintWriter out= new PrintWriter(System.out);
        Reader sc=new Reader();
        int arr[]=sc.arr(4);
        Arrays.sort(arr);
        if(arr[0]==1&&arr[1]==4&&arr[2]==7&&arr[3]==9)
        out.println("YES");
        else
        out.println("NO");
        out.flush();
    }
}

Measured memory_bytes: 20948
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	A := nextInt()
	B := nextInt()
	C := nextInt()

	temp := B
	B = A
	A = temp

	temp = C
	C = A
	A = temp

	fmt.Println(A, B, C)
}


Measured memory_bytes: 1760
/*****************************
Filename: dkljlkfd.cpp
Author: hbb
Create: 2020-04-05 13:36:56
 *****************************/
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const int inf = INT_MAX >> 1;
typedef long long int LL;

LL n;

int main(){
	scanf("%lld", &n);
	LL ans = 0;
	for(int i = 1; i <= sqrt(n - 1); i++){
		if((n - 1) % i == 0 && i != sqrt(n - 1)){
			ans += 2;
		}
		else if((n - 1) % i == 0) ans++;
	}
	for(int i = 2; i <= sqrt(n); i++){
		if(n % i == 0){
			LL temp = n;
			while(temp % i == 0){
				temp /= i;
			}
			if(temp % i == 1){
				ans++;
			}
			if(n / i != i){
				LL ti = n / i;
				temp = n;
				while(temp % ti == 0){
					temp /= ti;
				}
				if(temp % ti == 1) ans++;
			}
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
int Xiaobo()
{
	int a[5];
	for(int i=1;i<=3;i++) cin>>a[i];
	sort(a+1,a+1+3);
	if((a[1]==a[2]&&a[1]!=a[3])||(a[1]==a[3]&&a[1]!=a[2])||(a[2]==a[3]&&a[1]!=a[2])) 
	{
		puts("Yes");
	}
	else puts("No");
	return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

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

    int N;
    std::cin >> N;

    vector<int> v;
    v.resize(N);
    for(int i=0;i<N;++i){
        std::cin >> v[i];
    }

    std::sort(v.begin(), v.end());

    int res = 0;
    
    for(int i=0,j=0;i<N;i=j){
        while(j < N && v[j] == v[i]){
            ++j;
        }

        int n = j - i;
        if(n >= v[i]){
            res += n - v[i];
        }else{
            res += n;
        }
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        boolean[] can = new boolean[n];
        can[0] = true;
        int[] ball = new int[n];
        Arrays.fill(ball, 1);
        int ans = 0;
        for (int i = 0; i < m; i++) {
            int x = scanner.nextInt() - 1;
            int y = scanner.nextInt() - 1;

            if (can[x]) {
                can[y] = true;

                if (ball[x] == 1) {
                    can[x] = false;
                }
            }

            ball[x]--;
            ball[y]++;
        }

        for (boolean b : can) {
            if (b) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 63376
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
string s;
int n, p, v[N], pre[N];
ll powmod(ll a, ll b)
{
	ll ans = 1;
	while(b)
	{
		if(b&1) ans = ans*a%p;
		a = a*a%p;
		b >>= 1;
	}
	return ans;
}
void solve()
{
	for(int i=0; i<n; i++) v[(s[i]-'0')%p]++;
	ll ans = 0;
	for(int i=0; i<n; i++)
	{
		ans += v[0];
		v[(s[i]-'0')%p]--;
	}
	cout << ans;
	exit(0);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> p >> s;
	if(p==2||p==5) solve();
	v[n] = 0;
	for(int i=n-1; i>=0; i--) v[i] = (v[i+1]+powmod(10, n-i)*(s[i]-'0')%p)%p;
	for(int i=0; i<=n; i++) pre[v[i]]++;
	ll ans = 0;
	for(int i=0; i<n; i++)
	{
		pre[v[i]]--;
		ans += pre[v[i]];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1428
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;

int m,k;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d",&m,&k);
	
	if(k > (1 << m) - 1){
		puts("-1");
		return 0;
	}
	
	if(m == 1){
		if(k == 0)
		    printf("0 0 1 1\n");
		else
		    puts("-1");
		return 0;
	}
	
	printf("%d ",k);
	for(int i = 0;i <= (1 << m) - 1;i++){
		if(i != k)
		    printf("%d ",i);
	}
	printf("%d ",k);
	for(int i = (1 << m) - 1;i >= 0;i--){
		if(i != k)
		    printf("%d ",i);
	}
	return 0;
}


Measured memory_bytes: 1792
L = int(input())
A = [int(input()) for _ in range(L)]
dp = [[0]*5 for _ in range(L)]
dp[0][0] = A[0]
dp[0][1] = A[0] % 2 if A[0] > 0 else 2
dp[0][2] = 1-A[0] % 2
dp[0][3] = A[0] % 2 if A[0] > 0 else 2
dp[0][4] = A[0]
for i in range(1, L):
    dp[i][0] = dp[i-1][0] + A[i]
    tmp = A[i] % 2 if A[i] > 0 else 2
    dp[i][1] = min(dp[i-1][0], dp[i-1][1])+tmp
    tmp = 1-A[i] % 2
    dp[i][2] = min(dp[i-1][0], dp[i-1][1], dp[i-1][2])+tmp
    tmp = A[i] % 2 if A[i] > 0 else 2
    dp[i][3] = min(dp[i-1][0], dp[i-1][1], dp[i-1][2], dp[i-1][3])+tmp
    dp[i][4] = min(dp[i-1][0], dp[i-1][1], dp[i-1]
                   [2], dp[i-1][3], dp[i-1][4]) + A[i]
print(min(dp[L-1]))


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

using Graph = vector<vector<int>>;

#define MAX_N 1010
#define MAX_SIZE 10010
#define INF 1000000000

ll dp[MAX_N][MAX_SIZE] = {0};

int main() {
    int H, N;
    cin >> H >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    rep(i, N) {
        cin >> A[i] >> B[i];
    }
    rep(i, MAX_N) {
        rep(j, MAX_SIZE) {
            dp[i][j] = INF;
        }
    }
    // rep(i, MAX_SIZE) {
    //     dp[0][i] = 0;
    // }
    dp[0][0] = 0;
    rep(i, N) {
        rep(j, MAX_SIZE) {
            if(j < A[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                dp[i + 1][j] = min(dp[i + 1][j - A[i]] + B[i], dp[i][j]);
            }
        }
    }
    // rep(i, N + 1) {
    //     rep(j, H + 3) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    ll minValue = INF;
    for(int i = H; i < MAX_SIZE; i++) {
        if(dp[N][i] <= minValue) minValue = dp[N][i];
    }
    cout << minValue << endl;
    return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  ll now = -1, ans = 0;
  rep(i, n) {
    ll h;
    cin >> h;
    if(h >= now) {
      ans++;
      now = h;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);
const long double EPS = 1e-10L;

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n,m;
long double x[66],y[66],c[66],r[66];

long double dist(long double x1, long double y1, long double x2, long double y2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

bool judge(long double t){
	int i,j,k,cnt=0;
	long double xc,yc,a,p,q;
	for(i=0; i<n; ++i){
		r[i] = t/c[i];
	}
	for(i=0; i<n; ++i){
		cnt = 0;
		for(k=0; k<n; ++k){
			if(r[k]>=dist(x[k],y[k],x[i],y[i])+EPS){
				++cnt;
			}
		}
		if(cnt>=m){
			return true;
		}
		for(j=0; j<i; ++j){
			p = x[j]-x[i]; q = y[j]-y[i];
			a = p*p+q*q-r[j]*r[j]+r[i]*r[i]; a/=2.0L;
			if(dist(x[i],y[i],x[j],y[j])>r[i]+r[j]+EPS){
				continue;
			}
			if(dist(x[i],y[i],x[j],y[j])+EPS<abs(r[i]-r[j])){
				continue;
			}
			cnt = 0;
			xc = a*p+q*sqrt((p*p+q*q)*r[i]*r[i]-a*a); xc /= (p*p+q*q); xc += x[i];
			yc = a*q-p*sqrt((p*p+q*q)*r[i]*r[i]-a*a); yc /= (p*p+q*q); yc += y[i];
			for(k=0; k<n; ++k){
				if(r[k]+EPS>=dist(x[k],y[k],xc,yc)){
					++cnt;
				}
			}
			if(cnt>=m){
				return true;
			}
			cnt = 0;
			xc = a*p-q*sqrt((p*p+q*q)*r[i]*r[i]-a*a); xc /= (p*p+q*q); xc += x[i];
			yc = a*q+p*sqrt((p*p+q*q)*r[i]*r[i]-a*a); yc /= (p*p+q*q); yc += y[i];
			for(k=0; k<n; ++k){
				if(r[k]+EPS>=dist(x[k],y[k],xc,yc)){
					++cnt;
				}
			}
			if(cnt>=m){
				return true;
			}
		}
	}
	return false;
}

int main(void){
	int i;
	long double ok=4e6L,ng=0.0L,med;
	cin >> n >> m;
	for(i=0; i<n; ++i){
		cin >> x[i] >> y[i] >> c[i];
	}
	for(i=0; i<100; ++i){
		med = (ok+ng)/2.0L;
		if(judge(med)){
			ok = med;
		}else{
			ng = med;
		}
	}
	cout << fixed << setprecision(20) << ok << endl; 
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n; cin >> n;
    ll a = n%10;

    if(a == 3) cout << "bon" << endl;
    else if(a == 0 or a == 1 or a == 6 or a == 8) cout << "pon" << endl;
    else cout << "hon" << endl;


    return 0;
}



Measured memory_bytes: 3636
N=int(input())
a=input().rstrip().split()
  
asiba=[100000]*N
asiba[0]=0
asiba[1]=abs(int(a[1])-int(a[0]))

for i in range(2,N):

    if (asiba[i-1]+abs(int(a[i])-int(a[i-1])))> (asiba[i-2]+abs(int(a[i])-int(a[i-2]))):
        asiba[i]=asiba[i-2]+abs(int(a[i])-int(a[i-2]))

    else:
        asiba[i]=asiba[i-1]+abs(int(a[i])-int(a[i-1]))
    

print(asiba[N-1])


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


int main() {
	int X, Y, Z;
	int K;
	cin >> X >> Y >> Z;
	cin >> K;
	vector<long long> A(X), B(Y), C(Z);

	for (int i = 0; i < X; i++) cin >> A[i];
	for (int i = 0; i < Y; i++) cin >> B[i];
	for (int i = 0; i < Z; i++) cin >> C[i];

	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());
	sort(B.begin(), B.end());
	reverse(B.begin(), B.end());
	sort(C.begin(), C.end());
	reverse(C.begin(), C.end());

	vector<long long> ABC;
	for (int a = 0; a < X; a++)
	{
		for (int b = 0; b < Y; b++)
		{
			if ((a + 1) * (b + 1) > K) break;

			for (int c = 0; c < Z; c++)
			{
				if ((a + 1) * (b + 1) * (c + 1) > K) break;

				ABC.push_back(A[a] + B[b] + C[c]);
			}
		}
	}


	sort(ABC.begin(), ABC.end());
	reverse(ABC.begin(), ABC.end());

	for (int i = 0; i < K; i++)
	{
		cout << ABC[i] << endl;
	}

}



Measured memory_bytes: 1404
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, M, K;
  cin >> N >> M >> K;
  ll A, B, C, D;
  vector<set<ll>> frd(N + 1);
  vector<set<ll>> blk(N + 1);

  rep(i, M){
    cin >> A >> B;

    frd[A].insert(B);
    frd[B].insert(A);
  }
  rep(i, K){
    cin >> C >> D;

    blk[C].insert(D);
    blk[D].insert(C);
  }

  vl vis(N + 1, 0);
  vvl conn;
  
  rep2(n, 1, N + 1){
    if(vis[n] == 1) continue;
    conn.push_back({});
    
    queue<ll> que;
    que.push(n);
    ll top;

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

      if(vis[top] == 1) continue;
      vis[top] = 1;
      conn[conn.size() - 1].push_back(top);

      for(auto it = frd[top].begin(); it != frd[top].end(); it++){
        if(vis[(*it)] == 1) continue;
        que.push((*it));
      }
    }
  }

  vl cnt(N + 1, 0);

  rep(i, conn.size()){
    stable_sort(conn[i].begin(), conn[i].end());

    rep(j, conn[i].size()){
      ll n = conn[i][j];
      ll count = 0;
      
      for(auto it = frd[n].begin(); it != frd[n].end(); it++){
		auto jt = lower_bound(conn[i].begin(), conn[i].end(), (*it));
		if(((*jt) == (*it)) && (jt != conn[i].end())) count++;
      }
      for(auto it = blk[n].begin(); it != blk[n].end(); it++){
		auto jt = lower_bound(conn[i].begin(), conn[i].end(), (*it));
		if(((*jt) == (*it)) && (jt != conn[i].end())) count++;
      }

      cnt[n] = conn[i].size() - count - 1;
    }
  }

  rep2(i, 1, N + 1) cout << cnt[i] << ' ';
  cout << "\n";
  
  return 0;
}


Measured memory_bytes: 38020
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x,int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/


int main()
{
	int N;
	int d[100005];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> d[i];
	}
	sort(d, d + N);
	cout << d[N / 2] - d[N / 2 - 1] << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


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

	ll a,b,c;
	cin >> a >> b >> c;
	if(b-a==c-b){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
ll fact[200100];
ll inv[200100];
void pre(){
	for(ll i = 0; i <= 200001; ++i){
		if(i == 0) fact[i] = 1;
		else fact[i] = fact[i - 1] * i % mod;
		inv[i] = bp(fact[i], mod - 2);
	}
}
ll c(ll n, ll k){
	return fact[n] * inv[n - k] % mod * inv[k] % mod;
}
void solve(){
	pre();
	ll n, m, a, b;
	cin >> n >> m >> a >> b;
	ll ans = 0;
	for(ll i = b + 1; i <= m; ++i){
		ll u = n - a;
		ll x = m - i + 1;
		//cout << i << " " << u << " " << x << ' ' << y << '\n';
		ll ways = c(u + i - 2, i - 1) * c(x + a - 2, x - 1) % mod;
		ans += ways; 
		ans %= mod;
	}
	cout << ans;
	
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 3328
n=int(input())
l=[]
for i in range(n):
    x,y,h=map(int,input().split())
    l.append([x,y,h])
    if h!=0:
        a,b,c=x,y,h
for x in range(101):
    for y in range(101):
        h=c+abs(x-a)+abs(y-b)
        if all(r==max(h-abs(x-s)-abs(y-t),0)for s,t,r in l):
            print(x,y,h)
            exit()

Measured memory_bytes: 3064
N = int(input())
SP = [None] * N
for i in range(N):
    SP[i] = input().split()
    SP[i][1] = int(SP[i][1]) * -1

for i in range(N):
    SP[i].append(i + 1)

S = sorted(SP)

for i in range(N):
    ans = S[i][2]
    print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
    int h,w,a,b;
    scanf("%d %d %d %d",&h,&w,&a,&b);
    for(int i = 0;i < h;i++,putchar('\n'))for(int j = 0;j < w;j++)if((i < b && j < a) || (i>=b && j>=a))putchar('0');
    else putchar('1');
    return 0;
}

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

int main(){
    ll n, k;
    cin >> n >> k;
    ll j = k;
    for (int i = 1; i < n; i++)
        j *= (k-1);
        cout << j << endl;
        return 0;
        
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const int N=100010;
const int INF=1e9;
const int MOD=1e9+7;
int n,m;
int a[N],b[N];
struct Point{
	int x,y;
	friend bool operator == (const Point &a,const Point &b){
		return a.x==b.x&&a.y==b.y;
	}
}p[N];
int d[N],dcnt;
int f[N];
void readData(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=m;i++) scanf("%d",&b[i]);
}
void initDis(){
	int cnt=1;
	p[1]=(Point){0,0};
	for(int i=1,j;i<=n;i++){
		j=upper_bound(b+1,b+1+m,a[i])-b;
		if(1<j&&j<=m)
			p[++cnt]=(Point){a[i]-b[j-1],b[j]-a[i]};
	}
	p[++cnt]=(Point){INF,INF};
	n=cnt;
}
void Diz(){
	for(int i=1;i<=n;i++)
		d[++dcnt]=p[i].y;
	sort(d+1,d+1+dcnt);
	dcnt=unique(d+1,d+1+dcnt)-d-1;
	for(int i=1;i<=n;i++)
		p[i].y=lower_bound(d+1,d+1+dcnt,p[i].y)-d;
}
namespace BIT{
	int n;
	int a[N];
	void setup(int _n){
		n=_n;
	}
	void add(int u,int x){
		for(;u&&u<=n;u+=u&-u)
			(a[u]+=x)%=MOD;
	}
	int que(int u){
		int res=0;
		for(;u;u-=u&-u)
			(res+=a[u])%=MOD;
		return res;
	}
}
bool cmpByX(const Point &a,const Point &b){
	if(a.x!=b.x)
		return a.x<b.x;
	return a.y<b.y;
}
void solve(){
	sort(p+1,p+1+n,cmpByX);
	n=unique(p+1,p+1+n)-p-1;
	BIT::setup(dcnt);
	BIT::add(p[1].y,1);
	for(int i=2,j;i<=n;i=j){
		for(j=i;j<=n&&p[j].x==p[i].x;j++);
		for(int k=i;k<j;k++)
			f[k]=BIT::que(p[k].y-1);
		for(int k=i;k<j;k++)
			BIT::add(p[k].y,f[k]);
	}
	printf("%d\n",f[n]);
}
int main(){
	readData();
	initDis();
	Diz();
	solve();
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 2000000;
using namespace std;

int main() {
  int N;
  while (cin >> N && N) {
    std::vector<int> A(N);
    REP(i, N) { cin >> A[i]; }
    sort(A.begin(), A.end());
    int ans = A[1] - A[0];
    REP(i, N - 1) {
      ans = min(ans, A[i + 1] - A[i]);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3156
# -*- coding: utf-8 -*-
#ARC073C
import copy
import sys
import math

#n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

a=hoge[0]
b=hoge[1]

print(max(a+b,max(a-b,a*b)))


Measured memory_bytes: 3572
import java.io.*;
import java.util.*;


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int m=sc.nextInt();
        int[]a=new int[m],b=new int[m];
        long[]c=new long[m];
        for(int i=0;i<m;++i){
            a[i]=sc.nextInt()-1;
            b[i]=sc.nextInt()-1;
            c[i]=-sc.nextInt();
        }
        long[]d=new long[n];
        Arrays.fill(d,1L<<48);
        d[0]=0;
        long x1=-1,x2=-1;
        for(int i=0;i<2*n;++i){
            for(int j=0;j<m;++j)
                d[b[j]]=Math.min(d[b[j]],d[a[j]]+c[j]);
            if(i==n-1)x1=d[n-1];
            if(i==2*n-1)x2=d[n-1];
        }
        assert x1>=x2;
        if(x1==x2)
            out.println(-x1);
        else
            out.println("inf");
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 22996
# -*- coding: utf-8 -*-
n = int(input())

if n < 10:
  m = n
elif n < 100:
  m = 9
elif n < 1000:
  m = n - 90
elif n < 10000:
  m = 909
elif n < 100000:
  m = n - 9090
else:
  m = 90909
print(m)

Measured memory_bytes: 2940
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;


int main()
{
    string s; cin >> s;
    sort(s.begin(), s.end());
    if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _CRT_SECURE_NO_WARNINGS
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
  int r,g,b;
  cin >> r >> g >> b;
  int n = 10*g + b;
  if(n%4 == 0){
    P("YES"); 
  }else{
    P("NO") 
  }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    ll n,i;
    string a,b,s;
    cin>>n>>a>>b;
    for (i=0;i<n;i++){
        s+=a[i];
        s+=b[i];
    }
    cout<<s;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false); cin.tie(0);
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const int nmax = 1e5 + 10;
int n;
ll a[nmax];
int main() {
    IO;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + 1 + n);
    double d = fabs(a[1] - (double) a[n] / 2);
    ll y = a[1];
    for (int i = 2; i < n; i++)
        if (fabs(a[i] - (double) a[n] / 2) < d) {
            y = a[i];
            d = abs(a[i] - (double) a[n] / 2);
        }
    cout << a[n] << " " << y;
    return 0;
}


Measured memory_bytes: 1024
import collections

n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]

c = [[] for _ in range(n)]
for a, b in ab:
    a, b = a-1, b-1
    c[a].append(b)
    c[b].append(a)

point = [0] * n
for p, x in px:
    point[p-1] += x

parents = [0] * n
ans = [0] * n
q = collections.deque()
q.append(0)
while q:
    v = q.pop()
    ans[v] = ans[parents[v]] + point[v]
    for i in c[v]:
        if i == parents[v]:
            continue
        parents[i] = v
        q.append(i)
print(' '.join(list(map(str, ans))))

Measured memory_bytes: 188860
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  if(n == 1) {
    cout << 1 << endl;
  }
  else {
    int doubles = 2;
    while(doubles <= n) {
      doubles *=2;
    }
    doubles /= 2;
    cout << doubles << endl;
  }
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cmath>
typedef long long ll;
ll a[100+5];
ll n,co,ans=10000000000;
int max=-1000,min=1000;
ll solve(int x)
{
	ll ret=0;
	for(int i=1;i<=n;i++)
		ret+=(a[i]-x)*(a[i]-x);
	return ret;
}
int main()
{
	scanf("%lld",&n);//n<=100
	for(int  i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		if(a[i]>max)
			max=a[i];
		if(a[i]<min)
			min=a[i];
	}
	for(int i=min;i<=max;i++)
	{
		co=solve(i);
		if(co<ans)
			ans=co;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> left(n,0);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = n-2; i >= 0; i--){
        left[i] = max(left[i+1],a[i+1]);
    }
    
    ll ans = -1e18;
    for(int i = 0; i < n-1; i++){
        ans = max(ans,(ll)left[i]-a[i]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4412
#include <bits/stdc++.h>
#define F(i,n) for (ll i=1; i<=(ll)n; i++)
#define FF(i,n) for (ll i=0; i<(ll)n; i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pi pair < ll , ll >
#define re(x) (ll)x.size()
#define y1 u228
#define vi vector < ll >
using namespace std;
typedef long long ll;
const ll N = 2e5+228;
const ll big = 2e9;
const ll md = 1e9 + 7;
int n;
ll a[N],l,r;
ll go(ll x){
    ll ans=0;
    F(i,n) ans+=abs(a[i]-(x+i));
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    //freopen("input.txt","r",stdin);
    cin>>n;
    F(i,n) cin>>a[i];
    l=-2e9; r=2e9;
    while (r-l>3){
        ll l1=l+(r-l+1)/3ll;
        ll r1=r-(r-l+1)/3ll;
        if (go(l1)<go(r1)) r=r1; else l=l1;
    }
    ll tex=9e18;
    for (int i=l; i<=r; i++) tex=min(tex,go(i));
    cout<<tex<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int gcd(int x, int y);
int main(){
  int x , y;

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

  return 0;
}

int gcd (int x , int y){
  int strage , i = 1;
  if(x < y){
    strage = y;
    y = x;
    x = strage;
  }

  while(i != 0){
    i = x%y;
    x = y;
    y = i;
    
  }

  return x;
}



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

int main(){
    int n;
    cin>>n;
    ll ans=1;
    ll x=1e18;
    ll vec[n];
    for(int i=0;i<n;i++){
        cin>>vec[i];
    }
    sort(vec,vec+n);
    if(vec[0]==0){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        ans*=vec[i];
        if(i<n-1&&ans>1e9){
          if(vec[i+1]>x/ans){
            cout<<-1<<endl;
            return 0;
          }
        }
        if(ans>x){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4408
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    map<int,int>mp;
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++)
        {
            for(int k=1;k<=100;k++)
            {
                int ans= i*i + j*j + k*k +i*j + i*k + j*k;
                mp[ans]++;
            }
        }
    }
    int count=0;
    for(int i=1;i<=n;i++)
    {
        if(mp.find(i)==mp.end())
        cout<<0<<'\n';
        else
        cout<<mp[i]<<'\n';
    }
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    int p[11];
    int res = 0;
    REP(i,N){
        cin >> p[i];
    }
    REP(i,N){
        res = max(p[i], res);
    }
    int x = 0;
    REP(i,N){
        x += p[i];
    }
    int ans = x - res / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#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;


int main() {
    int A,B,K; cin >> A >> B >> K;
    int count = 0;
    REPR(i,101){
        if(A%i==0 && B%i==0){
            count ++;
            if(count == K){
                cout << i << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream> 
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

struct Point 
{
	int x;
	int y;
};

int main(){

	int w,h,x,y,r;
	bool in = 1;
	Point topLeft,topRight,bottomLeft,bottomRight;

	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	
	topLeft.x = x-r;
	topLeft.y = y-r;

	topRight.x = x+r;
	topRight.y = y-r;
	
	bottomLeft.x = x-r;
	bottomLeft.y = y+r;

	bottomRight.x = x+r;
	bottomRight.y = y+r;

	if(topLeft.x < 0 || topLeft.x > w) 
		in = 0;
	if(topLeft.y < 0 || topLeft.y > h ) 
		in = 0;

	if(topRight.x < 0 || topRight.x > w) 
		in = 0;
	if(topRight.y < 0 || topRight.y > h ) 
		in = 0;

	if(bottomLeft.x < 0 || bottomLeft.x > w) 
		in = 0;
	if(bottomLeft.y < 0 || bottomLeft.y > h ) 
		in = 0;
	
	if(bottomRight.x < 0 || bottomRight.x > w) 
		in = 0;
	if(bottomRight.y < 0 || bottomRight.y > h ) 
		in = 0;

	if(in) 
		puts("Yes");	
	else 
		puts("No");	

	return 0;
}


Measured memory_bytes: 3132
#include <iostream>

using namespace std;

int main(int argc, const char * argv[])
{
    int N;
    char S[100];
    cin >> N >> S;

    int count = 0;
    for (int i = 0; i < N - 2; ++i) {
        if (S[i] == 'A') {
            if (S[i + 1] == 'B') {
                if (S[i + 2] == 'C') {
                    count++;
                }
            }
        }
    }

    cout << count;

    return 0;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<int, int> P;
int dp[1000+1][10000+1];
int main()
{
    int h, n;
    cin >> h >> n;
    vector <P> tmp(n);
    for (int i = 0; i < n; i++) {
        cin >> tmp[i].first >> tmp[i].second;
    }
    sort(tmp.begin(), tmp.end());
    for (int i = 1; i <= h; i++) {
        dp[0][i] = ((i-1)/tmp[0].first + 1) * tmp[0].second;
    }
    
    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= h; j++) {
            dp[i][j] = min(dp[i-1][j], dp[i][j - tmp[i].first] + tmp[i].second);
        }
    }
    /*
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= h; j++) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/
    cout << dp[n-1][h] << endl;
    return 0;
}



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

int main()
{
	int n; cin >> n;
	
	vector<int> x(n); for (int i = 0; i < n; i++) cin >> x[i];
	
	vector<int> y(n);
	y = x;
	sort(y.begin(), y.end());

	int leftIndex = (n - 1 - 1) / 2;
	int rightIndex = (n -1 + 1) / 2;

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

		if (x[i] <= y[leftIndex]) {
			cout << y[rightIndex] << endl;
		}
		else if (y[rightIndex] <= x[i]) {
			cout << y[leftIndex] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,aa=0,bb;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    if(aa<a){
      aa=a;
      bb=b;
    }
  }
  cout<<aa+bb;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
a = sorted(map(int,input().split()))[::-1]
c = [0,2,5,5,4,5,6,3,7,6]
dp = [-float('inf')]*(n+1)
dp[0] = 0
for i in range(2, n+1):
    for j in a:
        if i >= c[j]:
            dp[i] = max(dp[i], dp[i-c[j]]+1)
r = []
while n:
    i = max((i for i in a if n>=c[i]), key=lambda x: dp[n-c[x]])
    r.append(i)
    n -= c[i]
print(''.join(map(str, r)))

Measured memory_bytes: 3692