akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,ii,jj;
ll n,m,sum,num=INF;
ll ans;
ll a,b,c,d,e;
ll x[100005],y[100005],z[100005];
ll xa[100005],ya[100005],za[100005];
char s[100005];

int main(){
	cin>>s;
	n=strlen(s);
	for(i=0;i<n-8;i++){
		cout<<s[i];
	}
	el;
	return 0;
}

Measured memory_bytes: 5632
import sys
import heapq
input = sys.stdin.readline
N, M = map(int, input().split())
a = []
for _ in range(N):
  u, v = map(int, input().split())
  a.append((u, v))
a.sort(key = lambda x: -x[0])
h = []
res = 0
#print(a)
for i in range(M + 1):
  while len(a):
    if a[-1][0] > i: break
    heapq.heappush(h, -a.pop()[1])
  if len(h):
    res += heapq.heappop(h)
print(-res)

Measured memory_bytes: 63324
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            String str = s.nextString();
            if (str.equals("Sunny")) {
                out.println("Cloudy");
            } else if (str.equals("Cloudy")) {
                out.println("Rainy");
            } else {
                out.println("Sunny");
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main()
{
int x1,y1,x2,y2;scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
int dist1,dist2,x3,y3,x4,y4;
dist1=abs(x2-x1),dist2=abs(y1-y2);
if(y1>=y2&&x1>=x2)x3=x2+dist2,y3=y2-dist1,x4=x1+dist2,y4=y1-dist1;
else if(y1>=y2&&x2>=x1)x3=x2+dist2,y3=y2+dist1,x4=x1+dist2,y4=y1+dist1;
else if(y2>=y1&&x1>=x2)x3=x2-dist2,y3=y2-dist1,x4=x1-dist2,y4=y1-dist1;
else x3=x2-dist2,y3=y2+dist1,x4=x1-dist2,y4=y1+dist1;
printf("%d %d %d %d",x3,y3,x4,y4);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ca=0,cb=0,i;
    string s;
    cin>>s;
    for(i=0;i<3;i++)
    {
        if(s[i]=='A') ca++;
        if(s[i]=='B') cb++;
    }
    if(ca==2 || cb==2) cout<<"Yes\n";
    else cout<<"No\n";


    return 0;
}


Measured memory_bytes: 3624
# PANA2020
q = int(input())
query = [tuple(map(int, input().split())) for _ in range(q)]

def man(a, b, c, d):
    return abs(a - c) + abs(b - d)

def solve(a, b, c, d, i, carry):
    if (a, b) == (c, d):
        return carry
    if i == 29:
        if (a, c) == (1, 1) or (b, d) == (1, 1):
            return 4 + carry
        else:
            return man(a,b,c,d) + carry
    k = 3 ** (30 - 1 - i)
    ga = a // k
    gb = b // k
    gc = c // k
    gd = d // k
    if (ga, gb) == (gc, gd):
        a %= k
        b %= k
        c %= k
        d %= k
        return solve(a,b,c,d,i+1,carry)
    if ga != gc and gb != gd:
        return man(a,b,c,d) + carry
    if gb == gd:
        a,b,c,d = b,a,d,c
        ga = a // k
        gb = b // k
        gc = c // k
        gd = d // k
    if ga == 1:
        return carry + abs(b - d) + min(a+c - 2*(k-1), 4*k - a - c)
    if b > d:
        a,b,c,d = c,d,a,b
        ga = a // k
        gb = b // k
        gc = c // k
        gd = d // k
    # ga == gc != 1 and gb < gd
    a %= k
    c %= k
    kk = k // 3
    gga = a // kk
    ggb = b // kk
    ggc = c // kk
    ggd = d // kk
    if ggd - ggb == 1:
        if gga == ggc:
            return solve(a % kk, b % kk, c % kk, d % kk + kk, i+1, carry)
        else:
            return man(a,b,c,d) + carry
    else:
        nb = b % kk
        nd = d % kk + 2 * kk
        carry += (d - b) - (nd - nb)
        return solve(a,nb,c,nd,i+1,carry)

for a, b, c, d in query:
    print(solve(a-1,b-1,c-1,d-1,0,0))

Measured memory_bytes: 5492
def main():
    n = int(input())
    p = list(map(int, input().split()))
    ans = 0

    for i in range(n - 2):
        if p[i] < p[i + 1] < p[i + 2] or p[i] > p[i + 1] > p[i + 2]:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61992
N,K=list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N-1)]
MOD = 10**9+7

if N==1:
  print(K)
  exit()

counted = [0]* (N+1) #counted[i]: ノードiはカウント済み

adjucent_dict = {}
for a,b in AB:
  adjucent_dict.setdefault(a, set()).add(b)
  adjucent_dict.setdefault(b, set()).add(a)
  
from collections import deque

dq = deque([])

for i in range(1,N+1):
  if len(adjucent_dict[i])==1:
    dq.append(i)
    
#print(dq)

ans = K
while dq:
  v = dq.popleft()
  # assert(len(adjucent_dict[v])==1)
  parent = adjucent_dict[v].pop() #かならずlen(~)=1のはず
  adjucent_dict[parent].remove(v)
  #print(v, K - (len(adjucent_dict[parent])+1))
  ans *= max(0, K - (len(adjucent_dict[parent])+1))
  ans %= MOD
  
  if len(adjucent_dict[parent])==1:
    dq.append(parent)
  if len(adjucent_dict[parent])==0:
    break
  
print(ans)

Measured memory_bytes: 64976
fn z_algorithm<T: Eq>(s: &[T]) -> Vec<usize> {
    let len = s.len();
    let mut a = vec![0; len];
    a[0] = len;
    let mut i = 1;
    let mut j = 0;
    while i < len {
        while i + j < len && s[j] == s[i + j] {
            j += 1;
        }
        a[i] = j;
        if j == 0 {
            i += 1;
            continue;
        }
        let mut k = 1;
        while i + k < len && k + a[k] < j {
            a[i + k] = a[k];
            k += 1;
        }
        i += k;
        j -= k;
    }
    a
}

//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

use std::io::Write;

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    input! {
        n: usize,
        a: [usize; n],
        b: [usize; n],
    }
    let mut ans = vec![true; n];
    for k in 0usize..30 {
        let mut dp = vec![false; n];
        for x in 0usize..2 {
            let mut c = vec![];
            for a in b.iter() {
                c.push(x ^ ((a >> k) & 1));
            }
            c.push(2);
            for _ in 0..2 {
                for b in a.iter() {
                    c.push((b >> k) & 1);
                }
            }
            let z = z_algorithm(&c);
            for i in (n + 1)..(n + 1 + n) {
                if z[i] >= n {
                    dp[i - n - 1] = true;
                }
            }
        }
        for i in 0..n {
            ans[i] &= dp[i];
        }
    }
    for k in 0..n {
        if ans[k] {
            let x = a[k] ^ b[0];
            writeln!(out, "{} {}", k, x).ok();
        }
    }
}

fn main() {
    run();
}


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



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

	deque<long long> A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	
	sort(A.begin(),A.end());
	long long ans = 0;
	vector<pair<long long,long long>> B(0);
	for(int i=0;i<N-2;i++){
		long long a = A.front();
		long long b = A.back();
		A.pop_back();
		A.pop_front();
		if(abs(a-b-A.back())>=abs(b-a-A.front())){
			A.push_front(a-b);
			B.push_back(make_pair(a,b));
		}
		else{
			A.push_back(b-a);
			B.push_back(make_pair(b,a));
		}
	}
	B.push_back(make_pair(A[1],A[0]));
	cout<<A[1]-A[0]<<endl;
	
	for(int i=0;i<N-1;i++){
		cout<<B[i].first<<' '<<B[i].second<<endl;
	}
	
		
	
	
	
	return 0;
}

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    bool flag = true;
    if (S[0] == '0')
    {
        flag = false;
    }
    int cnt = 0;
    vector<pair<int, int>> x;
    rep(i, S.size())
    {
        if (S[i] == '1' && !flag)
        {
            x.push_back({cnt, 1});
            flag = !flag;
            cnt = 0;
        }
        if (S[i] == '0' && flag)
        {
            x.push_back({cnt, 0});
            flag = !flag;
            cnt = 0;
        }
        cnt++;
    }
    x.push_back({cnt, (flag ? 0 : 1)});
    vector<int> k;
    vector<int> sum;
    k.push_back(0);
    sum.push_back(0);
    int sum_ = 0, k_ = 0;
    rep(i, x.size())
    {
        sum_ += x[i].first;
        k_ += x[i].second;
        sum.push_back(sum_);
        k.push_back(k_);
    }
    vector<int> sum_max(k_ + 1), sum_min(k_ + 1);
    rep(i, sum_min.size()) sum_min[i] = INF;
    rep(i, sum.size())
    {
        sum_min[k[i]] = min(sum_min[k[i]], sum[i]);
        sum_max[k[i]] = max(sum_max[k[i]], sum[i]);
    }
    int ans = 0;
    rep(i, k_ + 1)
    {
        ans = max(ans, sum_max[min(i + K, int(sum_max.size()) - 1)] - sum_min[i]);
    }
    rep(i, sum_max.size())
    {
        //cout << sum_max[i] << " ";
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
int main() {
ll n,c,k;
cin>>n>>c>>k;
ll t[n]={};
ll bas=0;
ll a=0;
ll b=0;
for(ll i=0; i<n; i++){
cin>>t[i];}
sort(t,t+n);
for(ll i=0; i<n; i++){
ll r=t[i]+k;
bas++;
a=i;
while(t[a]<=r&&b<c){
b++;
a++;
}
i=a-1;
b=0;}
cout<<bas<<endl;}


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

using namespace std;

using ll = long long;

ll n, ans = 0;
const vector<pair<char, char>> add = {{1, '3'}, {2, '5'}, {4, '7'}};

void Solve(string &x, char flag) {
    for (const auto &it : add) {
        x.push_back(it.second);
        if (stoll(x) <= n) {
            if ((flag | it.first) == 7) ++ans;
            Solve(x, flag | it.first);
        }
        x.pop_back();
    }
}

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

    cin >> n;

    string x;
    Solve(x, 0);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N;
	int count=0,count2=0;
	char num[100];
	scanf("%d",&N);
	scanf("%s",num);

	for(int i=0;i<N;i++){
		if(num[i] == 'R'){
		count++;
		}else if(num[i] == 'B'){
		count2++;
		}
	}

	if(count > count2){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

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

int main()
{
	int n;
	long long x, p = 0;

	cin >> n >> x;

	while (n >= 0) {
		if (x >= (1ull << (n + 1)) - 1) {
			p += 1ull << n;
			x -= (1ull << (n + 1)) - 1;
		}
		else if (x > 0)
			x--;

		n--;
	}

	cout << p << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = scan.nextInt();
		}
		Arrays.sort(h);

		int min = Integer.MAX_VALUE;
		for(int i = 0; i < n - k + 1; i++) {
			min = Math.min(min, h[i + k -1] -h[i]);
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 49660
import java.util.*
fun gcd(a: Long, b: Long): Long = if(b == 0L) {a} else {gcd(b, a % b)}

fun main(args:Array<String>) {
    val (A,B,C,D) = readLine()!!.split(" ").map(String::toLong)
    val times_c = B / C - A / C + (if(A % C == 0L){1L} else {0L})
    // println("times_c: ${times_c}")
    val times_d = B / D - A / D + (if(A % D == 0L){1L} else {0L})
    // println("times_d: ${times_d}")
    val lcm_cd =  (C / gcd(C,D)) * D
    // println("lcm_cd: ${lcm_cd}")
    val times_common = B / lcm_cd - A / lcm_cd + (if(A % lcm_cd == 0L){1L} else {0L})
    // println("times_common: ${times_common}")

    (B - A + 1 - times_c - times_d + times_common).run(::println) 

}

Measured memory_bytes: 36072
#include "bits/stdc++.h"
using namespace std;

vector<vector<long long> > V;
vector<long long> X;

long long MOD = 1000000007, R, ANS = 0;

long long Calc(long long A, long long B) {
	if (B == 0) return 1;
	if (B % 2 == 0) {
		long long C = Calc(A, B / 2);
		return (C * C) % MOD;
	}
	return (A * Calc(A, B - 1)) % MOD;
}

long long DFS(long long P, long long Q) {
	long long COUNT = 0;
	for (int NP : V[P]) {
		if (NP != Q) {
			COUNT += DFS(NP, P);
		}
	}
	return X[P] = COUNT + 1;
}

int main() {
	R = Calc(2, MOD - 2);
	long long N;
	cin >> N;
	V.resize(N);
	X.resize(N);
	for (int i = 0; i < N - 1; i++) {
		long long A, B;
		cin >> A >> B;
		A--, B--;
		V[A].push_back(B);
		V[B].push_back(A);
	}
	DFS(0, -1);
	for (int i = 0; i < N; i++) {
		vector<long long> W;
		for (int j : V[i]) {
			if (X[j] < X[i]) W.push_back(X[j]);
		}
		if (N != X[i]) W.push_back(N - X[i]);
		long long MUL = 1;
		for (int j = 0; j < W.size(); j++) {
			MUL *= Calc(R, W[j]);
			MUL %= MOD;
		}
		long long COUNT = 0;
		for (int j = 0; j < W.size(); j++) {
			COUNT += (MUL * Calc(2, W[j])) % MOD;
			COUNT %= MOD;
		}
		COUNT = (COUNT - (MUL * (W.size() - 1)) % MOD + MOD) % MOD;
		COUNT = (1 - COUNT + MOD) % MOD;
		ANS += COUNT;
		ANS %= MOD;
	}
	cout << (ANS * R) % MOD << endl;
}

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

int main() {
  long n,ans=0;
  string s;
  cin >> n >> s;
  for(long i=1;i<n;i++) {
    vector<bool> x(26);
    vector<bool> y(26);
    long a=0;
    for(long j=0;j<i;j++) x[s[j]-'a']=true;
    for(long j=i;j<n;j++) y[s[j]-'a']=true;
    for(long j=0;j<26;j++) if(x[j]&&y[j]) a++;
    ans=max(ans,a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug(x)   cerr<<#x<<": "<<x<<endl;
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
typedef long long int ll;
using namespace std;

const ll mod = 1e9+7;


int n ;
vector<tuple<int,int,int>>arr;

int dp[100005][4];


int recur(int ind , int pre) {
    if(ind == n+1)return 0;

    if(dp[ind][pre] != -1)return dp[ind][pre];

    int used_a =  0 , used_b = 0 ,  used_c = 0;
    if(pre!=1)
        used_a = get<0>(arr[ind]) + recur(ind + 1 , 1);
    if(pre!=2)
        used_b = get<1>(arr[ind]) + recur(ind + 1 , 2);
    if(pre!=3)
        used_c = get<2>(arr[ind]) + recur(ind + 1 , 3);
    return dp[ind][pre] = max({used_a , used_b , used_c});
}



void solve(){
    cin >>n;
    arr.resize(n + 1);
    for(int i=1;i<=n;i++)cin>>get<0>(arr[i])>>get<1>(arr[i])>>get<2>(arr[i]);

    memset(dp , -1 , sizeof(dp));

    cout<<recur(1,0)<<endl; 
    return;
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

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

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/
int main(){
    ll N;
    cin >> N;
    vector<ll>num(N);
    rep(i,N)cin >> num[i];
    map<ll,ll> odd,even;
    rep(i,N){
        if(i % 2 == 0)odd[num[i]]++;
        else even[num[i]]++;
    }
    vector<P> od,ev;
    for(auto x : odd){
        od.push_back(P(x.second,x.first));
    }
    for(auto x : even){
        ev.push_back(P(x.second,x.first));
    }
    sort(all(od));sort(all(ev));reverse(all(od));reverse(all(ev));
    ll os = od.size(),es = ev.size();
    if(od[0].second != ev[0].second){
        cout << N - ev[0].first - od[0].first << endl;
    }
    else{
        if(os == 1 && es == 1){
            cout << N - max(od[0].first,ev[0].first) << endl;
        }
        else if(es == 1){
            cout << N - ev[0].first - od[1].first << endl;
        }
        else if(os == 1){
            cout << N - ev[1].first - od[0].first << endl;
        }
        else{
            cout << N - max(od[0].first + ev[1].first,od[1].first + ev[0].first) << endl;
        }
    }
}

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

int main(){
  char a; cin >> a;
  if(a=='A') cout << 'T' <<endl;
  if(a=='C') cout << 'G' <<endl;
  if(a=='G') cout << 'C' <<endl;
  if(a=='T') cout << 'A' <<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <string>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
	vector <int> A;
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);a-=i;
		A.push_back(a);
	}
	sort(A.begin(),A.end());
	ll ret=0;
	for(int i=0;i<n;i++) ret+=abs(A[i]-A[n/2]);
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	string S; cin >> S;
	lli K; cin >> K;
	char tmp = S[0];
	vector<int> cnt;
	int a = 0;
	rep(i, 0, S.length()) {
		if (tmp != S[i]) {
			cnt.push_back(a);
			a = 1;
			tmp = S[i];
		}
		else a++;
		if (i == S.length() - 1)cnt.push_back(a);
	}
	//rep(i, 0, cnt.size())cout << cnt[i] << " " << endl;
	if (cnt.size() == 1){
		cout << K * cnt[0] / 2 << endl;
		return 0;
	}
	lli ans = 0;
	rep(i, 0, cnt.size())ans += cnt[i] / 2;
	ans *= K;
	if (S[0] == S[S.length() - 1])
		ans += ((cnt[0] + cnt[cnt.size() - 1]) / 2 - cnt[0] / 2 - cnt[cnt.size() - 1] / 2)*(K - 1);

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define T true
#define F false

using namespace std;
typedef long long ll;

int ans = 0;

bool Judge(int n, const int N) {
	if (n > N)
		return F;
	int a;
	bool t = F, f = F, s = F;
	while (n > 0) {
		a = n % 10;
		if (a == 3) {
			t = T;
			n /= 10;
			continue;
		}
		if (a == 5) {
			f = T;
			n /= 10;
			continue;
		}
		if (a == 7) {
			s = T;
			n /= 10;
			continue;
		}
		return F;
	}
	if (t && f && s)
		return T;
	return F;
}

void Search(ll n, const int N) {
	n *= 10;
	if (n > N)
		return;
	if (Judge(n + 3, N))
		ans++;
	Search(n + 3, N);
	if (Judge(n + 5, N))
		ans++;
	Search(n + 5, N);
	if (Judge(n + 7, N))
		ans++;
	Search(n + 7, N);
	return;
}

int main(void) {
	ll n;
	scanf("%ld", &n);
	Search(3, n);
	Search(5, n);
	Search(7, n);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(int i=0;i<p;i++)
#define reep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

ll int A,B;

cin >> A >> B;
if(A-2*B>=0){
cout << A - 2*B;
}
else{
	cout << "0";}










	return 0;

}



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

#define ll long long
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)

using namespace std;

#define pow5(n) ((n)*(n)*(n)*(n)*(n))

int main()
{
  ll X; cin>>X;
  FOR(A,-120,120)FOR(B,-120,120){
    if (pow5(A)-pow5(B)==X){
      cout<<A<<" "<<B<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3652
/*
    Just Another Source code by - shahincsejnu
*/
#include                        <bits/stdc++.h>
#define   ulli                  unsigned long long int
#define   lli                   long long int
#define   MOD                   1000000007
#define   PI                    acos(-1.0)
#define   UNIQUE(V)             (V).erase(unique(ALL(V), (V).end()) //vector/string etc must need to be sorted
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define   ALL(V)                (V).begin(), (V).end()
#define   MEM(a, val)           memset(a, val, sizeof(a))
#define   SORT(v)               sort(v.begin(),v.end())
#define   REV(v)                reverse(v.begin(),v.end())
using     namespace             std;


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //timesave; 
    
    int arr[5];

    for(int i = 1; i <= 3; i++) cin >> arr[i];

    sort(arr+1, arr+4);

    if(arr[1] == 5 && arr[2] == 5 && arr[3] == 7) cout << "YES" << "\n";
    else cout << "NO" << "\n";

    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func r() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := r()

	vs := make([]int, 100001)
	max := -int(^uint(0)>>1) - 1
	for a, i := 0, 0; i < n; i++ {
		a = r()

		vs[a]++
		switch a {
		case 0:
			vs[a+1]++
		case 100000:
			vs[a-1]++
		default:
			vs[a-1]++
			vs[a+1]++
		}

		if a != 0 && vs[a-1] > max {
			max = vs[a-1]
		}
		if a != 100000 && vs[a+1] > max {
			max = vs[a+1]
		}
		if vs[a] > max {
			max = vs[a]
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 1408
a,b,k=map(int,input().split())

for i in range(k):
  if i%2==0:
    if a%2==0:
      b=b+int(a/2)
      a=int(a/2)
    else:
      b=b+int((a-1)/2)
      a=int((a-1)/2)
  else:
    if b%2==0:
      a=a+int(b/2)
      b=int(b/2)
    else:
      a=a+int((b-1)/2)
      b=int((b-1)/2)
print(a)
print(b)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmax(ll x, ll y)
{
    if (x > y)
        return x;
    else
        return y;
}

int main()
{
    int n,x; cin >> n >> x;
    vector<int> a(n);
    ll cnt=0;
    REP(i,n){
        cin >> a[i];
        if(a[i]>x){
            cnt+=a[i]-x;
            a[i]=x;
        }
    }

    REP(i,n-1){
        if(a[i]+a[i+1]>x){
            ll res = a[i]+a[i+1]-x;
            cnt+=res;
            a[i+1]-=res;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int N;
 int K;
 int i;
 int tmp=0;
 double tmpval;
 cin >> N >> K;
 int p[N];
 int sum[N+1];
 sum[0]=0;
for(i=0;i<N;i++){
    cin >> p[i];
    sum[i+1]=sum[i]+p[i];
}
for(i=K;i<N+1;++i){
if(sum[i]-sum[i-K]>tmp)tmp=sum[i]-sum[i-K];
   }
tmpval = (tmp + K)/2.0;
 cout << setprecision(11) << tmpval << endl;
 }

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

int main(){
  string S;
  cin >> S;
  int L=S.size();
  int ans=0;
  for(int i=0; i<L-1; i++){
    if(S.at(i)!=S.at(i+1)) ans++;    
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>

using namespace std;

int main(){
	int x, y;
	string s;
	cin >> s;

	x = s.find('A');
	y = s.find('Z', x);
	while (y < s.find('Z', y + 1)) {
		if (s.find('Z', y + 1) == -1)break;
		y = s.find('Z', y + 1);
	}
	cout << y - x + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N = 1e6 + 10;
using namespace std;
ll d,n;
int main() {
  ios::sync_with_stdio(false);
  cin>>d>>n;
  if(n==100)  n++;
  while(d--)   n*=100;
  cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void){
  int n,z,w;
  scanf("%d %d %d",&n,&z,&w);
  int a[n];
  for(int i=0;i<n;i++){
    scanf("%d",a+i);
  }
  int ans=0;
  if(n==1){
    ans=abs(a[n-1]-w);
  }else{
    ans=max(abs(a[n-1]-w),abs(a[n-2]-a[n-1]));
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            new Program().Solve();
        }

        void Solve()
        {
            var tmp = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int a = tmp[0];
            int b = tmp[1];

            int count = 0;
            for (int i = a; i <= b; i++)
            {
                if (PalindromicNumber(i))
                    count++;
            }
            Console.WriteLine(count);
        }

        bool PalindromicNumber(int num)
        {
            string s = num.ToString();
            int front = 0;
            int back = s.Length - 1;
            while (back - front > 0)
            {
                if (s[front] != s[back])
                {
                    return false;
                }
                front++;
                back--;
            }
            return true;
        }
    }
}


Measured memory_bytes: 15444
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int f[][] = new int[n + 1][10];
		int p[][] = new int[n + 1][11];
		int ans = 0;
		for (int i = 1; i <= n; i++)
			for (int j = 0; j < 10; j++)
				f[i][j] = Integer.parseInt(sc.next());
		for (int i = 1; i <= n; i++)
			for (int j = 0; j <= 10; j++)
				p[i][j] = Integer.parseInt(sc.next());
		for (int i = 1; i <= 1024; i++) {
			String bin[] = String.format("%10s", Integer.toBinaryString(i)).replaceAll(" ", "0").split("");
			int index[] = new int[n + 1];
			for (int j = 0; j < 10; j++) {
				if (Integer.parseInt(bin[j]) == 1) {
					for (int k = 1; k <= n; k++) {
						if (f[k][j] == 1)
							index[k]++;
					}
				}
			}
			int tem = 0;
			for (int j = 1; j <= n; j++) {
				tem += p[j][index[j]];
			}
			if (tem > ans || i == 1)
				ans = tem;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 29804
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k,ans=0;
	cin>>n>>k;
	range(i,k,n+2){
		(ans+=(n+1-i)*i+1)%=MOD;
	}
	puta(ans);
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  #ifdef _DEBUG
  //freopen("input.txt", "r", stdin);
  #endif
  ll n, x = 0;
  cin >> n;
  for (ll i = 1; i <= n; ++i) {
    if (i % 3 != 0 && i % 5 != 0) x += i;
  }
  cout << x << "\n";
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

ll N,a,b,c,d;
map<ll,ll> cnt;

ll f(ll n) {
  if(n<2) return n*d;
  if(cnt.count(n)) return cnt[n];
  ll res=inf;
  if(n*d>0) res=min(res,n*d);
  res=min(res,f(n/2)+a+d*abs(n/2*2-n));
  res=min(res,f(n/3)+b+d*abs(n/3*3-n));
  res=min(res,f(n/5)+c+d*abs(n/5*5-n));
  res=min(res,f((n+1)/2)+a+d*abs((n+1)/2*2-n));
  res=min(res,f((n+2)/3)+b+d*abs((n+2)/3*3-n));
  res=min(res,f((n+4)/5)+c+d*abs((n+4)/5*5-n));
  cnt[n]=res;
  return res;
}

int main() {
  ll t;
  cin >> t;
  while(t--) {
    cnt.clear();
    cin >> N >> a >> b >> c >> d;
    cout << f(N) << endl;
  }
}

Measured memory_bytes: 4384
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    string s;
    cin >> s;
    int l = s.length();
    int ans = 0;
    int c = 0;

    for(int i = 0; i < l; i++){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            c += 1;
        } else{
            ans = max(ans, c);
            c = 0;
        }
    }

    if(c > 0) ans = max(ans, c);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
	n,m,x = MI()
	a = LI()
	for i,aa in enumerate(a):
		if(aa>x):
			print(min(i, m-i))
			exit()

if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
long long chiyo(long long x){
    if(x%4==0) return x;
    if(x%4==1) return 1;
    if(x%4==2) return x+1;
    if(x%4==3) return 0;
}
int main(){
    long long n,m,a=0,b=0,A[200000]={0},B[200000]={0},ans=0,C[200000];
    cin>>n>>m;
    n=chiyo(n-1),m=chiyo(m);
    while(n>0) A[a]=n%2,n=n/2,a++;
    while(m>0) B[b]=m%2,m=m/2,b++;
    C[0]=1;
    rep(i,200000){
        C[i+1]=2*C[i];
        if(C[i+1]>2000000000000) break;
    }
    long long p=max(a,b);
    rep(i,p) ans+=((A[i]+B[i])%2)*C[i];
    cout<<ans;
}

Measured memory_bytes: 4864
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pii;

template<typename T>
using pq_gt = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using pq_lt = priority_queue<T, vector<T>, less<T>>;

#define se second
#define fi first
#define pb push_back

vector<pii> dist[200200];
ll loct[200200];
bool visited[200200];
set<int> idx;

int main() {
    ios::sync_with_stdio(false);
    int N,M;
    cin>>N>>M;
    for(int i = 0; i < M; ++i) {
    	int a,b,c;
    	cin>>a>>b>>c;
    	dist[a].pb({b,c});
    	dist[b].pb({a,-c});
    	idx.insert(a);
    	idx.insert(b);
    }
    for(int st:idx) {
    	if(!visited[st]) {
    		visited[st] = true;
    		loct[st] = 0;
    		queue<int> q;
    		q.push(st);
    		while(!q.empty()) {
    			int t = q.front();
    			q.pop();
    			for(pii n:dist[t]) {
    				if(visited[n.fi]) {
    					if(loct[t]+n.se!=loct[n.fi]) {
    						cout<<"No\n"; return 0;
    					}
    				} else {
    					visited[n.fi] = true;
    					loct[n.fi] = loct[t]+n.se;
    					q.push(n.fi);
    				}
    			}
    		}
    	}
    }
    cout<<"Yes\n";
}

Measured memory_bytes: 21248
n = gets.chomp.to_i
ary = gets.split(" ").map(&:to_i)

if ary.include?(0)
  puts 0
  exit
end

ans = 1
i = 0

ary.each do |x|
  ans *= x
  if ans > 10**18
    puts -1
    exit
  end
end

puts ans


Measured memory_bytes: 21684
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int k; cin>> k;
    string s; cin >> s;
    if (s.length() <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0,k) << "..." << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
S=list(input())
def zeroone(X,st,nx):
  out=0
  for i in range(len(X)):
    if i%2==0:
      if X[i]!=st:
        out+=1
    else:
      if X[i]!=nx:
        out+=1
        
  return out

ans1=zeroone(S,"1","0")
ans2=zeroone(S,"0","1")
ans=min(ans1, ans2)
print(ans)


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

int main()
{
  int n;
  cin>>n;
  for(int i=9;i>0;i--){
    if(n%i) continue;
    else if(n/i>0&&n/i<10){
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
}

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

int main() {
  int N;
  long K;
  std::cin >> N >> K;
  std::vector<int> a(N), b(N);
  for (long i=0; i<N; i++) {
    std::cin >> a.at(i) >> b.at(i);
  }
  map<int,long> m;
  for (int i=0; i<N; i++) {
    m[a[i]] += b[i];
  }
  
  /*for (auto it=m.begin(); it!=m.end(); it++) {
    cerr << it->first << ' ' << it->second << endl;
  }*/
  
  long count = 0;  
  for (auto it=m.begin(); it!=m.end(); it++) {
    count += it->second;
    //cerr << it->first << endl;
    if (count>=K) {
      cout << it->first << endl;
      break;
    }
  }
  return 0;
}

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

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007


int main() {
    int A, B, C; cin >> A >> B >> C;
    cout << min(B / A, C) << endl;
}


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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int n; cin >> n;
  int a;
  vi b(100001);
  rep(i,n){
    cin >> a;
    if(0<a) b[a-1]++;
    b[a]++;
    if(a<100000)b[a+1]++;
  }
  cout << *max_element(all(b)) << endl;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll solve(string s,int k){
    ll n = s.size();
    vvvl dp(110,vvl(2,vl(5,0))); //dp[桁数][ある数字未満か][0でない個数]
    dp[0][0][0] = 1;

    for ( int i = 0; i < n; ++i ){
		const int D = s[i] - '0'; //左から数えた桁数

		for ( int j = 0; j < 2; ++j ){
			for ( int k = 0; k < 4; ++k ){
				for ( int d = 0; d <= ( j ? 9 : D ); ++d ){
					dp[ i + 1 ][ j || ( d < D ) ][ k + (d != 0) ] += dp[i][j][k];
				}
			}
		}
	}
    ll res = 0;
    rep(i, 2) {  
        res += dp[n][i][k];
    }
	return res;
}
signed main()
{   
    gearup;
    string n;
    int k; cin >> n >> k;
    cout << solve(n,k) << endl;
}


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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll k(ll h, ll w) {
  ll mini = min(h, w);
  for(ll i = 0; i < h; i++) {
    ll a = max(i * w, (h - i) * (w / 2 + (w % 2 ? 1 : 0))) - min(i * w, (h - i) * (w / 2));
    mini = min(mini, a);
  }
  return mini;
}

int main() {
  ll h, w;
  cin >> h >> w;

  if(h % 3 == 0 || w % 3 == 0) {
    cout << 0 << endl;
    return 0;
  }

  cout << min(k(h, w), k(w, h)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x) {cout << #x << " = " << (x) << endl;}


int main() {
    LL N, K;
    cin >> N >> K;
    VI h(N + 1);
    FOR(i, 1, N + 1) {
        cin >> h[i];
    }

    VI dp(N + 1, LLONG_MAX);
    dp[1] = 0;
    FOR(i, 1, N + 1) {
        FOR(k, 1, K + 1) {
            LL j = i + k;
            if (j <= N) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }

    cout << dp[N] << endl;
	
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  I k;
  cin >> s >> k;
  vector<string> v;
  REP(i,s.size()){
    string ss;
    ss += s.at(i);
    v.push_back(ss);
    if (i < s.size()-1){
      I si = s.size();
      si = min(si, i+k+1);
      for (I j = i+1;j<si;j++){
        ss += s.at(j);
        v.push_back(ss);
      }
    }
  }
  SORT(v);
  unique(ALL(v));
  REP(i,v.size()){
    if (i == k-1){
      cout << v.at(i) << endl;
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
int solve(int x){
    if(x%2==0){
        return x/2;
    }else{
        return 3*x+1;
    }
}

int main(){
    int n,ans;
    cin >> n;
    int ind=0;
    vector<int> a={};
    a.push_back(n);
    while(1){
        int youso = solve(a[a.size()-1]);
        auto itr = find(a.begin(),a.end(),youso);
        if(itr != a.end()){
            ans = a.size()+1;
            break;
        }else{
            a.push_back(youso);
        }

        for(int i=0;i<a.size();i++){
           // cerr << a[i] << " ";
        }
        //cerr << endl;
    }

    cout << ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N,tmp;
    int cnt = 0;
    int i,j;

    scanf("%d" ,&N);
    int num[N];

    for(i = 0;i < N;i++){
        scanf("%d", &num[i]);
    }

    for(i = 0; i < N;i++){
        for(j = N - 1;j > i;j--){
            if(num[j] < num[j-1]){
                tmp = num[j-1];
                num[j-1] = num[j];
                num[j] = tmp;
                cnt++;
            }
        }
    }

    for(i = 0; i < N - 1;i++){
        printf("%d ", num[i]);
    }
    printf("%d\n%d\n", num[N-1], cnt);

    return 0;
}

Measured memory_bytes: 600