akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    cout << a[0] + a[1] << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  long long ans=0;
  for (int i=1;i<n;i++) {
    int b=i/2;
    ans += a[b];
  }
  cout << ans << endl;
}


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

int main() {
 int a,b,c,K;
 cin >> a >> b >> c >> K;
 vector<int> num(3);
  num = {a,b,c};
  
 sort(num.begin(),num.end());
  for(int i=0;i<K;i++){
   num[2] =num[2]*2;
  }
  
  cout << num[0]+num[1]+num[2] << 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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int t = 0;
    REP(i,n) if(s[i] == 'R') t ++;
    if(t * 2 > n) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner in = new Scanner(System.in);
	
	public static void main(String[] args){
		int n = in.nextInt();
		long[] a = new long[n], b = new long[n];
		for(int i = 0; i < n; i++){
			a[i] = in.nextLong();
			b[i] = in.nextLong();
		}
		long sum = 0;
		for(int i = n - 1; i > -1; i--){
			if(((a[i] + sum) % b[i]) != 0){
				sum += b[i] - ((a[i] + sum) % b[i]);
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 65464
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

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

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

/*考えを書くスペース

*/
//main.cpp----------------------------
#define max_n 100000

void solve();
ll dfs(ll);

ll n;
ll h[max_n+1];
ll dp[max_n+1];

int main() {
  scanf("%lld", &n);
  rep(i, n) scanf("%lld", &h[i]);

  solve();

  return 0;
}

void solve() {

  dp[0] = 0;
  dp[1] = abs(h[1]-h[0]);
  for(int i=2; i<n; ++i) {
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
  }

  cout << dp[n-1];

}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
class Solve{
    public int n;
    public long k;
    public int[] a;
    Tree[] tree;
    int count;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    int dfs(Tree t,bool b){
        int max = 0;
        for(int i = 0;i < t.child.Count;i++){
            int m = dfs(t.child[i],true)+1;
            if(max < m){
                max = m;
            }
        }
        if(max == k-1 && b){
            count++;
            max = -1;
        }
        return max;
    }
    void Calc(){
        getinput();
        int rootnum = 0;
        int[] root = new int[n];
        tree = new Tree[n-1];
        for(int i = 0;i < n-1;i++){
            tree[i] = new Tree();
        }
        for(int i = 0;i < n-1;i++){
            if(a[i+1] == 1){
                root[rootnum] = i;
                rootnum++;
            }
            else{
                tree[a[i+1]-2].AddChild(tree[i]);
            }    
        }
        count = 0;
        for(int i = 0;i < rootnum;i++){
            dfs(tree[root[i]],false);
        }
        if(a[0] == 1){
            Console.WriteLine(count);
        }
        else{
            Console.WriteLine(count+1); 
        }
    }
    void getinput(){
        string[] str = Console.ReadLine().Split(' ');
        n = int.Parse(str[0]);
        k = int.Parse(str[1]);
        a = new int[n];
        str = Console.ReadLine().Split(' ');
        for(int i = 0;i < n;i++){
            a[i] = int.Parse(str[i]);
        }
    }    
}
class Tree{
    public List<Tree> child;
    public Tree(){
        child = new List<Tree>();
    }
    public void AddChild(Tree t){
        child.Add(t);
    }
}

Measured memory_bytes: 30688
import sys
input = sys.stdin.readline

N, L = map(int, input().split())
a = list(map(int, input().split()))
for i in range(N-1):
    if a[i] + a[i+1] >= L:
        print('Possible')
        for j in range(1, i+1):
            print(j)
        for j in range(i+1, N)[::-1]:
            print(j)
        exit()
print('Impossible')

Measured memory_bytes: 59872
// inputに入力データ全体が入る
function Main(str) {

  const num = parseInt(str);
  
  if (num > 999) {
    console.log('ABD');
    return;
  }
  
  console.log('ABC');
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
main :: IO()
main = do
    s <- getLine
    putStrLn $ if isStrongPalindrome s then "Yes" else "No"

isStrongPalindrome :: String -> Bool
isStrongPalindrome s = foldr (&&) True $ map isPalindrome (s : splitMid s)

isPalindrome :: String -> Bool
isPalindrome s = isSame s $ reverse s

isSame :: String -> String -> Bool
isSame [] [] = True
isSame [] [_] = False
isSame [_] [] = False
isSame (x:xs) (y:ys) = if x /= y then False else isSame xs ys

splitMid :: String -> [String]
splitMid s =
    let
        l = length s
        n = (l - 1) `div` 2
        f = take n s
        e = drop (n + 1) s
    in
    [f, e]


Measured memory_bytes: 508
def examA():
    L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K = I()

    ans = L[K-1]
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examA()

"""

"""

Measured memory_bytes: 5864
/***  بسم الله الرحمن ا لرحيم   ***/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
//#include<unordered_map>
#define endl                         '\n'	
#define Ceil(x,y)             ((x+y-1)/y)
#define sz(s)               (int)s.size()
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define all(v) ((v).begin()), ((v).end())
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define test int t;cin>>t;while(t--)
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
const double PI = acos(-1), EPS = 1e-7;
const int OO = 0x3f3f3f3f, N = 2e5 + 5, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return ((x / gcd(x, y)) * y); }
void file() {
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int a, b, c, d, arr[200], sum;
int main() {
	//file();
	cin >> a >> b >> c >> d;
	for (int i = a; i < b; i++) arr[i]++;
	for (int i = c; i < d; i++) arr[i]++;
	sum = 0;
	for (int i = 0; i < 200; i++) {
		if (arr[i] >= 2)sum++;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstring>
#define MAXN 200005
#define MAXM
#define LL long long
#define LD long double
using namespace std;

int n, num;
char s[MAXN];
LL ans;

int main()
{
	scanf("%s", s+1);
	int n=strlen(s+1);
	for(int i=1; i<=n; i++)
	{
		if(s[i]=='B') num++;
		else ans+=num;
	}
	printf("%lld\n", ans);
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)

int main() {
    int a,b; cin >> a >> b;

    if(b%a == 0) {
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }

    return 0;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  while(n!=-1){
    int a=1150;
    if(n>10){
      if(n>20){
	a+=1250;
	if(n>30){
	  a+=1400+160*(n-30);
	}else{
	  a+=140*(n-20);
	}
      }else{
	a+=125*(n-10);
      }
    }
    cout<<4280-a<<endl;
    cin>>n;
  }
  return 0;
}



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

int main(){
  int N, H, W;
  cin >> N >> H >> W;
  int count=0;
  for(int i=0; i<N; i++){
    int a, b;
    cin >> a >> b;
    if(a>=H && b>=W) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;


int main() {
    ll x,y;cin >> x >> y;
    ll cnt = x;
    ll ans = 0;
    while(x <= y){
        ll a = 2;
        while(true){
            if(a*x%x==0){
                ans++;
                x = a*x;
                break;
            }else{
                a++;
            }
        }
    }
    cout << ans;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    double L = in<double>()/3;
    cout << L*L*L << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl=vector<ll>;
using vs=vector<string>;
using vd=vector<double>;
using vvd=vector<vd>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<n;i++)

using D=double;
using P=complex<D>;
using L=pair<P,P>;
using VP=vector<P>;
const D EPS=1e-9;
#define X real()
#define Y imag()
#define LE(n,m) ((n)<(m)+EPS)
#define GE(n,m) ((n)+EPS>(m))
#define EQ(n,m) (abs((n)-(m))<EPS)
#define LINF 1e20

VP crosspointCC(P a, D ar, P b, D br){
    VP ps;
    P ab =b-a;
    D d=abs(ab);
    D crL=(norm(ab)+ar*ar-br*br)/(2*d);
    if(EQ(d,0) || ar<abs(crL)) return ps;
    P abN = ab*P(0,sqrt(ar*ar-crL*crL)/d);
    P cp=a+crL/d*ab;
    ps.push_back(cp+abN);
    if(!EQ(norm(abN),0))ps.push_back(cp-abN);
    return ps;
}
D dot(P a,  P b){
    return (conj(a)*b).X;
}

D cross(P a, P b){
    return (conj(a)*b).Y;
}

int ccw(P a,P b, P c){
    b-=a; c-=a;
    if(cross(b,c) >EPS)return 1;
    if(cross(b,c) <-EPS)return -1;
    if(dot(b,c) <-EPS)return 2;
    if(norm(b)<norm(c))return -2;
    return 0;
    
}
bool isecSS(P a1,P a2, P b1, P b2){
    return ccw(a1,a2,b1) * ccw(a1,a2,b2)<=0 &&
    ccw(b1,b2,a1)*ccw(b1,b2,a2)<=0;
}

int main(){
    int n;
    while(cin>>n,n){
        vd x(n),y(n),r(n);
        rep(i,n)cin>>x[i]>>y[i]>>r[i];
        vd px(2*n), py(2*n);
        px[0]=x[0];
        py[0]=y[0];
        px[2*n-1]=x[n-1];
        py[2*n-1]=y[n-1];
        rep(i,n-1){
            auto vp=crosspointCC(P(x[i],y[i]), r[i], P(x[i+1],y[i+1]), r[i+1]);
            px[i*2+1]=vp[0].X;
            py[i*2+1]=vp[0].Y;
            px[i*2+2]=vp[1].X;
            py[i*2+2]=vp[1].Y;
        }
        vvd dist(2*n, vd(2*n,LINF));
        rep(i,2*n)range(j,i+1,2*n){
            bool ok=true;
            range(k,(i==0?0:(i-1)/2+1),(j-1)/2){
                // cout<<i<<","<<j<<","<<k*2+1<<endl;
                // cout<<P(px[i],py[i])<<P(px[j],py[j])<<P(px[k*2+1],py[k*2+1])<<P(px[k*2+2],py[k*2+2])<<endl;
                if(!isecSS(P(px[i],py[i]), P(px[j],py[j]), P(px[k*2+1],py[k*2+1]), P(px[k*2+2],py[k*2+2]))){
                    ok=false;
                }
                // cout<<ok<<","<<endl;
            }
            // cout<<px[i]<<","<<py[i]<<","<<px[j]<<","<<py[j]<<endl;
            // cout<<i<<","<<j<<"="<<(ok?"ok":"ng")<<endl;
            if(ok){
                dist[i][j]=hypot(abs(px[i]-px[j]), abs(py[i]-py[j]));
            }
        }
        vd dp(n*2, LINF);
        dp[0]=0;
        rep(i,2*n){
            range(j,i+1,2*n){
                dp[j]=min(dp[j], dp[i]+dist[i][j]);
            }
        }
        // rep(i,n*2)cout<<dp[i]<<endl;
        cout<<setprecision(10)<<fixed<<dp[2*n-1]<<endl;
    }

}



Measured memory_bytes: 3416
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

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

//solve
  n++;
  ll total = 0;
  rep(i,n)
    if(i%3!=0 && i%5!=0)
      total += i;

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


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

  #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout);
      }
  #endif  

      int n;
      cin>>n;
      n%=10;
      if(n==3)
      		cout<<"bon";
      else if(n==0||n==1||n==6||n==8)
      		cout<<"pon";
      else
      		cout<<"hon";
}


Measured memory_bytes: 3648
#include <iostream>
#include <set>

using namespace std;

int main() {
    int n;
    cin >> n;
    set<int> se;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        se.insert(a);
    }
    cout << (se.size() == n ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 9728
N,K = map(int,input().split())
h = []
for i in range(N):
    a = int(input())
    h.append(a)

h.sort()

ans = 999999999999999
for i in range(N-K+1):
    hmin = h[i]
    hmax = h[i+K-1]
    if (hmax - hmin) < ans:
        ans = hmax - hmin

print(ans)


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

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

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

long long int calc(long long int a, long long int b, long long int p){
	if(b == 0) return 1;
	else if(b % 2 == 0){
		long long int d = calc(a, b / 2, p);
		return (d * d) % p;
	}
	else{
		return (a * calc(a, b - 1, p)) % p;
	}
}

int main(){
	long long int MOD = 1'000'000'007;
	long long int n, a, b;
	cin >> n >> a >> b;

	long long int ans = calc(2, n, MOD) - 1;

	long long int div = 1;
	for(long long int i = max(n, a); max(n, a) - min(n, a) < i; i--){
		div *= i;
		div %= MOD;
	}
	for(long long int i = 1; i <= min(n, a); i++){
		div *= calc(i, MOD - 2, MOD);
		div %= MOD;
	}

	ans += MOD;
	ans -= div;
	ans %= MOD;

	div = 1;
	for(long long int i = max(n, b); max(n, b) - min(n, b) < i; i--){
		div *= i;
		div %= MOD;
	}
	for(long long int i = 1; i <= min(n, b); i++){
		div *= calc(i, MOD - 2, MOD);
		div %= MOD;
	}
	
	ans += MOD;
	ans -= div;
	ans %= MOD;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3600
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

N = int(input())
A = list(map(int, input().split()))

if N == 1:
    print(A[0])
else:
    res = gcd(A[0], A[1])
    for i in range(2, N):
        res = gcd(res, A[i])
    print(res)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

void solve() 
{
    int n,m;cin>>n>>m;
    cout<<(n==m?"Yes":"No")<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define len(x) int((x).size())
#define res(x) cout << ((x) ? "YES\n" : "NO\n" )

typedef long long int integer;
typedef long double doble;

void solution() {
	int n;
	cin >> n;
	vector<int> a(n), b;
	for(int& x:a) {
		cin >> x;
		b.push_back(x);
	}
	sort(all(b));
	for(int& x:a) {
		cout << (x == b[n-1] ? b[n-2] : b[n-1]);
		cout << endl;
	}
}
 
int main(){
	int t = 1;
	//cin >> t;
	while(t--) solution();
	return 0;
}

Measured memory_bytes: 5112
import sys
sys.setrecursionlimit(1000000)

class UnionFind:
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.rank = [1] * N

    def root(self, x):
        px = self.par[x]
        if px == x:
            return x
        else:
            self.par[x] = self.root(px)
            return self.par[x]

    def unite(self, x, y):
        rootx = self.root(x)
        rooty = self.root(y)
        rankx = self.rank[rootx]
        ranky = self.rank[rooty]
        if rootx == rooty:
            return 0
        elif rankx < ranky:
            self.par[rooty] = rootx
            self.rank[rootx] += ranky
            return rankx * ranky
        else:
            self.par[rootx] = rooty
            self.rank[rooty] += rankx
            return ranky * rankx 
    
    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

N, M = map(int, input().split())
tree = UnionFind(N)
li = [list(map(int, input().split())) for i in range(M)]
inconv = [0] * M
for i in range(M-1, -1, -1):
    inconv[i] = tree.unite(li[i][0]-1, li[i][1]-1)
    
temp = 0
for i in range(M):
    temp += inconv[i]
    print(temp)


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

typedef long int lint;
typedef long long int llint;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main()
{
  int a[3];
  REP(i, 3){
    cin >> a[i];
  }
  sort(a, a + 3);
  if (a[0] == 5 && a[1] == 5 && a[2] == 7)  cout << "YES";
  else  cout << "NO";
  cout << endl;
}


Measured memory_bytes: 764
#include <stdio.h>
int main(){

  int a[4];
  int i,j;

  for(i = 0; i < 4; i++){
    
    scanf("%d",&a[i]);

  }

  for(i = 1; i < 4; i++){

    if(a[0] == a[i]){

      if(i == 1){

	if(a[2] == a[3]){

	  printf("yes\n");
	  
	  return 0;
	  
	}

      }
	
	if(i == 2){
	  
	  if(a[1] == a[3]){
	    
	    printf("yes\n");
	    
	    return 0;
	    
	  }

	}
	
	
	
	if(i == 3){
	  
	  if(a[1] == a[2]){
	    
	    printf("yes\n");
	    
	    return 0;
	    
	  }
	  
	}

      }


  }

  printf("no\n");

  return 0;

}

Measured memory_bytes: 580
#coding: utf-8

N, T = map(int, raw_input().split())
A = map(int, raw_input().split())

total, start, end = 0, 0, 0
for ai in A:
    if ai > end:
        total += end - start
        start = ai
    end = ai + T

if start < end:
    total += end - start

print total

Measured memory_bytes: 20060
k,n = map(int,input().split(" "))
a = list(map(int,input().split(" ")))
d_max = a[0]+(k-a[n-1])
d_max_i = n-1 
for i in range(1,n):
  if a[i] - a[i-1] > d_max:
    d_max = a[i] - a[i-1]
print(k-d_max)

Measured memory_bytes: 32376
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	string s;
	cin >> s;
	int n = s.size();
	rep(i, n - 1) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int [] a = new int [n+1];
		int [] ans=new int [n+1];
		int no=0;
		for(int i=1;i<=n;i++)
		{
			a[i]=in.nextInt();
		}
		for(int i=n;i>0;i--)
		{
			int q=0;
			for(int j=1;j*(i)<=n;j++)
			{				
				q=q+ans[i*j];
				
			}
			q=q%2;
				if(q==a[i])
				{
					ans[i]=0;
				}
				else
				{
					ans[i]=1;
					no++;
				}
		}
		System.out.println(no);
		for(int i=1;i<=n;i++)
		{
			if(ans[i]==1)
			{
				System.out.print(i+" ");
			}
		}
	}
}
	

Measured memory_bytes: 85804
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}

void main()
{
  int n; readV(n);

  int[int] h;
  foreach (_; 0..n) {
    int a; readV(a);
    h[a]++;
  }

  auto r = 0;
  foreach (v; h.values)
    if (v%2 == 1) ++r;

  writeln(r);
}


Measured memory_bytes: 7804
#include <bits/stdc++.h>
using namespace std;
using PP = pair<long, long>;
const int INF = 1e9;
template <class T> T Next() { T buf; cin >> buf; return buf; }

long input() {
  long ret;
  scanf("%lld", &ret);
  return ret;
}

const long INFLL = 1e18;
int main() {
  int a = input();
  int b = input();
  int c = input();
  int z = input();
  
  vector<long> s, t, u;
  s.reserve(a + 1);
  t.reserve(b + 1);
  u.reserve(c + 1);
  for (int i = 0; i < a; ++i) s.push_back(input());
  for (int i = 0; i < b; ++i) t.push_back(input());
  for (int i = 0; i < c; ++i) u.push_back(input());
  
  sort(s.rbegin(), s.rend());
  sort(t.rbegin(), t.rend());
  sort(u.rbegin(), u.rend());
  s.push_back(-INFLL);
  t.push_back(-INFLL);
  u.push_back(-INFLL);
  
  unordered_set<int> st;
  priority_queue<pair<long, int>> Q;
  Q.push(make_pair(s[0] + t[0] + u[0], 0));
  
  int cnt = 0;
  while (cnt < z) {
    auto q = Q.top(); Q.pop();
    long sc = q.first;
    int pos = q.second;
    if (st.count(pos)) continue;
    st.insert(pos);
    
    int i =  pos        & 0x3ff;
    int j = (pos >> 10) & 0x3ff;
    int k = (pos >> 20) & 0x3ff;
    
    cout << sc << endl;
    Q.push(make_pair(s[i + 1] + t[j] + u[k], pos +  1       ));
    Q.push(make_pair(s[i] + t[j + 1] + u[k], pos + (1 << 10)));
    Q.push(make_pair(s[i] + t[j] + u[k + 1], pos + (1 << 20)));
    ++cnt;
  }
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;

int main(void){
    int N;
    cin >> N;
    std::vector<int> vec;
    int m1;
    for (int i = 0; i < N;i++){
        cin >> m1;
        vec.push_back(m1);
    }
    std::sort(vec.begin(), vec.end(), std::greater<int>());
    int comb_n = vec[0];
    int comb_r_target = vec[0] / 2;
    double comb_r_target_d = vec[0] / 2.0;
    int comb_r;

    if(N==2){
        cout << vec[0] << " " << vec[1] << endl;
        return 0;
    }

    int i = 0;
    if(comb_r_target<vec[N-1]){
        comb_r = vec[N - 1];
    }else{
        while(vec[i]>comb_r_target){
            i++;
        }
        //cout << " i is " << i<<endl;
        //cout << comb_r_target <<" "<< comb_r_target_d<<endl;
        if (vec[i] == comb_r_target)
        {
            comb_r = vec[i];
        }else{
            if(comb_r_target_d-(double)vec[i]>(double)vec[i-1]-comb_r_target_d){
                comb_r = vec[i - 1];
            }else{
                comb_r = vec[i];
            }
        }
    }
    cout << comb_n << " " << comb_r << endl;

    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
map< char , int > count;
string str;
while( cin>>str ){
for(int i=0;i<(int)str.size();i++){
if( isupper(str[i]) ){
str[i]=tolower(str[i]);
}
}
for(int i=0;i<(int)str.size();i++){
count[ str[i] ]++;
}
}
for(char ch='a';ch<='z';ch++){
cout<<ch<<" : "<<count[ch]<<endl;
}
return 0;
}


Measured memory_bytes: 3176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        int R, G, B, N, ans = 0;

        void solve(InputReader in, PrintWriter out) {
            R = in.nextInt();
            G = in.nextInt();
            B = in.nextInt();
            N = in.nextInt();
            for (int r = 0; r <= N; r++) {
                for (int g = 0; g <= N; g++) {
                    int rem = N - (R*r + G*g);
                    if (rem >= 0 && rem % B == 0) ++ans;
                }
            }
            out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

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

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

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

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


Measured memory_bytes: 23380
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 100100;
const int MOD = 1e9+7;

int add(int x, int y) {
	x += y;
	if (x >= MOD) x -= MOD;
	return x;
}

int mul(int x, int y) {
	return (ll)x * y % MOD;
}

int n, m, p[MAXN], p1[MAXN];

vector <int> v, v1;

int sum;

int main() {
	scanf("%d %d",&n,&m);
	REP(i, n) scanf("%d",&p[i]);
	REP(i, m) scanf("%d",&p1[i]);

	REP(i, m - 1) v1.push_back(p1[i + 1] - p1[i]);

	REP(i, (int)v1.size()) {
		sum = add(sum, mul(v1[i], i + 1));
		sum = add(sum, mul(v1[i], mul(i + 1, (int)v1.size() - i - 1)));
	}

	REP(i, n - 1) v.push_back(p[i + 1] - p[i]);
	
	int sol = 0;
	REP(i, (int)v.size()) {
		sol = add(sol, mul(mul(i+1, v[i]), sum));
		sol = add(sol, mul(mul(v[i], sum), mul(i + 1, (int)v.size() - i - 1)));
	}


	printf("%d\n",sol);
	return 0;
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main(){
  ll n;
  cin >> n;
  string ans = "";
  while(n > 0) {
    n--;
    char c = n % 26 + 'a';
    ans += c;
    n /= 26;
  }
  reverse(all(ans));
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define PB push_back
#define MP make_pair
#define F first
#define S second

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll n,ans=0;
  	string s;
  	cin >> n >> s;
  	vector<ll> r,g,b;
  	for(ll i=0;i<n;i++){
    	if(s[i]=='R'){
        	r.PB(i);
        }else if(s[i]=='G'){
        	g.PB(i);
        }else{
        	b.PB(i);
        }
    }
  	ans+=r.size()*g.size()*b.size();
  	for(ll i=0;i<n;i++){
    		for(ll j=0;j<n;j++){
            	if(i>j){
                	if(s[i]!=s[j]){
                    	if(2*j-i>=0){
                        	if(s[2*j-i]!=s[i]&&s[2*j-i]!=s[j]) ans--;
                        }
                    }
                }
            }
    }
  	cout << ans << endl;
}

Measured memory_bytes: 3192
n = gets.to_i
data = gets.split(" ").map{|v|
  v.to_i
}
sorted = data.sort
len = sorted.length
mid = sorted[len / 2]
bm = sorted[len / 2 - 1]
data.each{|d|
  puts "#{d <= bm ? mid : bm}"
}


Measured memory_bytes: 23396
m,f,r = 0,0,0
result = []
count = 0
while True:
    count+=1
    m,f,r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        result.append("F")
        continue
    elif 80 <= m+f:
        result.append("A")
        continue
    elif 65 <= m+f < 80:
        result.append("B")
        continue
    elif 50 <= m+f < 65:
        result.append("C")
        continue
    elif 30 <= m+f < 50:
        if 50 <= r:
            result.append("C")
            continue
        else:
            result.append("D")
            continue
    else:
        result.append("F")

for i in range(count-1):
    print(result[i])



Measured memory_bytes: 5596
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, string.sub(k, i, i)) end local r = io.read local u = table.unpack return function() return r(u(a)) end end})
local N = read.n()
local A, B, C = {}, {}, {}
for i=1,N do
    A[i] = read.n()
end
for i=1,N do
    B[i] = read.n()
end
for i=1,N-1 do
    C[i] = read.n()
end

local ans = 0
local prev = nil
for i=1,N do
    ans = ans + B[A[i]]
    if prev and A[i] == prev + 1 then
        ans = ans + C[prev]
    end
    prev = A[i]
end
print(ans)

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

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

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
string str;
int main()
{
    cin>>str;
    int n=(int)str.size();
    for(int i=0;i<n;i++) if(str[i]=='?') str[i]='D';
    cout<<str<<endl;
}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int n;

int sumN(int x)
{
    int t=0;
    while (x)
    {
        t+=(x%10);
        x/=10;
    }
    return t;
}

int main()
{
    int minAns=10000000;
    cin>>n;
    for (int i=1; i<n; ++i)
    {
        int t=sumN(i)+sumN(n-i);
        if (t<minAns)
            minAns=t;
    }
    cout<<minAns<<endl;
    return 0;
}


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


int main(){
  while(true){
    int a, d, n, cnt = 0, ans;
    
    scanf("%d%d%d", &a, &d, &n);

    if(a + d + n == 0) break;

    for(int i=a;cnt != n; i += d){
      if(i == 2 || i == 3){
	++cnt;
      }
      else{
	for(int k=2;k <= sqrt(i);++k){
	  if(i%k == 0) break;
	  if(k == static_cast<int>(sqrt(i))) ++cnt;
	}
      }
      if(cnt == n) ans = i;
    }
    cout << ans << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3136
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define I(i,j) (i*7+j)

ll n,m,q,a[100050];
bool g[3000000];
bool used[3000000];

void dfs1(ll n,ll i,ll j) {
    REP(k,4) {
        ll y = i + dy[k],x = j + dx[k];
        if(0 <= y && y < n && 0 <= x && x < 7 && !used[I(y,x)] && !g[I(y,x)]) {
            used[I(y,x)] = true;
            dfs1(n,y,x);
        }
    }
}

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

    REP(i,q)
        cin >> a[i];

    ll l = 1;

    while(m * l % 7 != 0)l++;

    ll n2 = m * l / 7;

    REP(i,q) {
        ll p = a[i];

        while(p < n2 * 7){
            g[p] = true;
            p += m;
        }
    }

    ll c = 0;
    REP(i,n2) {
        REP(j,7) {
            if(!used[I(i,j)] && !g[I(i,j)]) {
                c++;
                used[I(i,j)] = true;
                dfs1(n2,i,j);
            }
        }
    }
    if(n == n2) {
        cout << c << endl;
        return 0;
    }

    REP(i,n2*7*2)
        g[i] = used[i] = false;

    REP(i,q) {
        ll p = a[i];

        while(p < n2 * 7 * 2){
            g[p] = true;
            p += m;
        }
    }

    ll c2 = 0;

    REP(i,n2*2) {
        REP(j,7) {
            if(!used[I(i,j)] && !g[I(i,j)]) {
                c2++;
                used[I(i,j)] = true;
                dfs1(n2*2,i,j);
            }
        }
    }

	ll b = 2 * c - c2;
	ll a = c - b;

	cout << a * n / n2 + b << endl;

    return 0;
}



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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

signed main()
{
    ll n, q;
    cin >> n >> q;
    vector<ll> a(n);
    for(auto& x : a)
        cin >> x;
    vector<ll> x(q);
    for(auto& y : x)
        cin >> y;

    vector<ll> rui(n + 1, 0);
    for(ll i = n - 1; i >= 0; --i)
        rui[i] = rui[i + 1] + a[i];

    vector<ll> rui2(n + 2, 0);
    for(ll i = 0; i < n; i += 2)
        rui2[i + 2] = rui2[i] + a[i];
    for(ll i = 1; i < n; i += 2)
        rui2[i + 2] = rui2[i] + a[i];


    for(auto& p : x){

        ll ind = distance(a.begin(), lower_bound(a.begin(), a.end(), p));

        // 高橋くんがnum個取る事ができるか
        auto f = [&](ll num){
            if(n - ind < num)
                return true;

            // [taka_bound, en]まで高橋くんがとった
            // 青木くんが[begin, taka_bound)まで取れる
            auto taka_bound = prev(a.end(), num);
            // 差が[0,max_diff)の範囲にj個あるかを調べる
            ll max_diff = (*taka_bound - p);
            ll dist = distance(lower_bound(a.begin(), a.end(), p - max_diff), taka_bound);

            return dist < (num - 1);
        };

        ll st = 1;
        ll en = n + 100;
        while(en - st > 1){
            ll num = (st + en) / 2;
            (f(num) ? en : st) = num;
        }
        // 影響が起こらない限界値
        ll value = rui[n - st];
        cout << value + rui2[n + 1 - 2 * st] << endl;
    }

}


Measured memory_bytes: 4864
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;


public class HelloWorld
{

    static long A;
    static long B;
    static long C;
    static long D;
    static long N;
    static SortedDictionary<long, long> dic;
    static public void Main()
    {
        var N = long.Parse(Console.ReadLine());
        var A = new long[N];
        var B = new long[N];
        for (int i = 0; i < N; i++)
        {
            var inp =
            Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            A[i] = inp[0];
            B[i] = inp[1];
        }

        long ans = 0;
        if (N%2 == 1)
        {
            ans = (long)(Median(B) - Median(A) + 1);
        }
        else
        {
            ans = (long)(Median(B) - Median(A)) + 1;
        }

        Console.WriteLine(ans);
    }

    public static long Median(long[] A)
    {
        var N = A.Length;
        Array.Sort(A);
        if(N%2 == 1)
        {
            return A[N / 2];
        }

        return A[N / 2] + A[(N / 2) - 1]; 
    }


}
public static class LINQExtension
{
    public static double Median(this IEnumerable<double>? source)
    {
        if (!(source?.Any() ?? false))
        {
            throw new InvalidOperationException("Cannot compute median for a null or empty set.");
        }

        var sortedList = (from number in source
                          orderby number
                          select number).ToList();

        int itemIndex = sortedList.Count / 2;

        if (sortedList.Count % 2 == 0)
        {
            // Even number of items.
            return (sortedList[itemIndex] + sortedList[itemIndex - 1]) / 2;
        }
        else
        {
            // Odd number of items.
            return sortedList[itemIndex];
        }
    }
}

Measured memory_bytes: 50060
#include <iostream>
#include <vector>
#include <list>
#include<utility>
#include <new>
#include <string>
#include<cmath>
#include<unordered_set>
#include<iomanip>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define forloop(i,x,z) for (int i=x;i<z;i++)
using ll = unsigned long long int;
/*bool cmp(pair<ll,ll>a,pair<ll,ll>b){
return a.second<b.second;
}*/
int main()
{int a,b,c,k;
	cin >> a>>b>>c>>k;
        while(b<=a){
            b=2*b;
            k--;
            if(k<0){
                cout<<"No";
                return 0;
            }
        }
        while(c<=b){
            c=2*c;
            k--;
            if(k<0){
                cout<<"No";
                return 0;
            }
        }
        if(k<0||a>=b||b>=c){
                cout<<"No";
                return 0;
            }
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
	int n,c[500],s[500],f[500];
int pd(int t,int c,int s,int f){
	
	while(t<s||t%f!=0)t++;
	return t;
}
int main(){
scanf("%d",&n);
int b=n;
n--;
for(int i=0;i<n;i++){
	scanf("%d %d %d",&c[i],&s[i],&f[i]);
}
int als=b;
for(int k=0;k<als-1;k++){
int sum=0;
/**/for(int i=k;i<als-1;i++){
	sum=pd(sum,c[i],s[i],f[i])+c[i];
}printf("%d\n",sum);}printf("%d",0);

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a <= 0 && b >= 0) {
    cout << "Zero" << endl;
    return 0;
  }
  if (a > 0 && b > 0) {
    cout << "Positive" << endl;
    return 0;
  }
  const int n = b - a + 1;
  if (n % 2 == 0)
    cout << "Positive" << endl;
  else
    cout << "Negative" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,i=1;
	
	
	do{
		scanf("%d",&a);
		if(a!=0){
		printf("Case %d: %d\n",i,a);
		}
		i++;
	}
	while(a!=0);
	
	
	
	return 0;
}

Measured memory_bytes: 600
/*
 _____ ____ _____   ___   ___   ___   ___ 
|_   _/ __ \_   _| |__ \ / _ \ |__ \ / _ \
  | || |  | || |      ) | | | |   ) | | | |
  | || |  | || |     / /| | | |  / /| | | |
 _| || |__| || |_   / /_| |_| | / /_| |_| |
|_____\____/_____| |____|\___/ |____|\___/ 
*/
#include <bits/stdc++.h>
#include <fstream>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
// assert(x==y); gives run time when false
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a*500 >= b){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll N, K;
    string S;

    cin >> N >> K;
    cin >> S;
    S[K - 1] = S[K - 1] + ('a' - 'A');
    cout << S << endl;

    return;
}

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


Measured memory_bytes: 256