akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
  
  double dp[3000][3000];
double call(double arr[],int i,int n,int p)
{
	if(i==n && p==0)
	 return 1.0;
	 
	 if(i==n && p!=0)
	  return 0.0;
	  
	  if(dp[i][p]!=-1)
	   return dp[i][p];
	   
	return dp[i][p]=arr[i]*call(arr,i+1,n,p-1)+(1-arr[i])*call(arr,i+1,n,p);
}
  int main() 
{ ios_base:: sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
   cin>>n;
   double arr[n];
   for(int i=0;i<n;i++)
   {
   	double r;
   	 cin>>r;
   	 arr[i]=r*1.0;
   }
   for(int i=0;i<3000;i++)
     for(int j=0;j<3000;j++)
       dp[i][j]=-1;
       
       double ans=0;
       for(int i=n/2+1;i<=n;i++)
       ans+=call(arr,0,n,i);
       
       printf("%.10lf",ans);
	return 0;
} 

Measured memory_bytes: 70784
s = gets.chomp
h = (s.to_i).divmod(3600)[0]
m = ((s.to_i).divmod(3600)[1]).divmod(60)[0]
ss = ((s.to_i).divmod(3600)[1]).divmod(60)[1]
puts h.to_s + ":" + m.to_s + ":" + ss.to_s

Measured memory_bytes: 8648
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <cmath>
#include<queue>
#define PI 3.141592653589793238
#define ll long long
using namespace std;

int main()
{
	int n, m;
	int cac = 0, cwa = 0;
	int tmpi;
	string tmps;
	bool* ac;
	int* wa;

	cin >> n >> m;
	ac = (bool*)malloc(sizeof(bool) * (n + 1));
	wa = (int*)malloc(sizeof(int) * (n + 1));

	for (int i = 0; i < n; i++) {
		ac[i] = false;
		wa[i] = 0;
	}

	for (int i = 0; i < m; i++) {
		cin >> tmpi >> tmps;
		if (ac[tmpi] == true) {
			continue;
		}
		if (tmps == "AC") {
			ac[tmpi] = true;
			cac++;
		} else {
			wa[tmpi]++;
		}
	}

	for (int i = 1; i <= n; i++) {
		if (ac[i]) {
			cwa += wa[i];
		}
	}

	printf("%d %d", cac, cwa);


	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a;
        cin>>a;
        n-=a;
    }
    if(n<0)cout<<-1<<endl;
    else cout<<n<<endl;

}

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

int main() {
   int A, B, C, D;
   cin >> A >> B >> C >> D;
   if (B<C || D<A) {
       cout << "0\n";
       return 0;
   }
   else cout << min(D,B) - max(A,C) << "\n";
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
def solve(N,A):
    ans = 1
    lis = [A[0]]
    for i in range(1,N):
        if len(lis)==1 or diff==0:
            diff = A[i]-A[i-1]
        elif (A[i]-A[i-1])*diff<0:
            ans += 1
            lis = []
        lis.append(A[i])
    return ans
print(solve(N,A))

Measured memory_bytes: 14252
using System;
using System.Collections.Generic;

class MainClass
{
    public static void Main(string[] args)
    {
        var N = LnInt();
        var A = LnInt();
        Console.WriteLine(N * N - A);
    }

    public class Node
    {
        public List<long> nodeIndexes = new List<long>();
        public List<long> routeCost = new List<long>();
        public long thisTotalCost;
    }

    public static int[] LnInts()
    {
        var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        var ins = new int[vs.Length];
        for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]);
        return ins;
    }

    public static int LnInt()
    {
        var vs = Console.ReadLine().Trim();
        return int.Parse(vs);
    }

    public static string[] LnStrs()
    {
        var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        return vs;
    }
    public static string LnStr()
    {
        var vs = Console.ReadLine().Trim();
        return vs;
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <set>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
int a[200005];
int mx[200005];
int main(int argc, char** argv) {
	int n,k;
	cin>>n>>k;
	rep(i,1,n)
	{
		scanf("%d",&a[i]);
	}
	set<int>s;
	int ans=0;
	mx[1]=0;
	int fg=0;
	rep(i,2,n)
	{
		mx[i]=mx[i-1];
		if(a[i]<=a[i-1])
		{
		mx[i]=max(i-1,mx[i]);	
		}
		if(i>=k&&mx[i]>=i-k+1)
		{
			ans++;
		}
		else if(i>=k)
		{
			fg=1;
		}
	}
	rep(i,1,k+1)
	{
		s.insert(a[i]);
		if(i!=k+1)continue;
		set<int>::iterator it1,it2;
		it1=s.begin();
		it2=--s.end();
		if(*it1==a[1]&&*it2==a[k+1]&&mx[i]>=i-k)
		{
			ans--;
		}
	}
	rep(i,k+2,n)
	{
		s.erase(a[i-k-1]);
		s.insert(a[i]);
		set<int>::iterator it1,it2;
		it1=s.begin();
		it2=--s.end();
		if(*it1==a[i-k]&&*it2==a[i]&&mx[i]>=i-k)
		{
			ans--;
		}
	}
	
	
	cout<<ans+fg;
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define pb push_back
#define sc1(x) scanf("%lld",&x)
#define sc2(x,y) scanf("%lld%lld",&x,&y)
#define sc3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define MX 100000
#define PI acos(-1)
using namespace std;

typedef long long int ll;


int main()
{
    ll k,x;
    sc2(k,x);
    for(ll i=x-k+1;i<=x+k-1;i++)
    {
        printf("%lld",i);
        if(i<x+k-1)
            printf(" ");
    }
    printf("\n");
    return 0;
}




Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
holds = 0
ans = 1000
for i in range(n-1):
    if a[i] <= a[i+1]:
        div, mod = divmod(ans, a[i])
        holds += div
        ans = mod
    else:
        ans += holds * a[i]
        holds = 0

print(ans + holds * a[i+1])

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int kingaku;
  int itienMai;
  cin >> kingaku >> itienMai;
  int gohyakuenMai;
  gohyakuenMai = kingaku / 500;
  kingaku = kingaku - gohyakuenMai * 500;
  if(kingaku <= itienMai){
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

long long gcd(long long n, long long x){
    return x ? gcd(x, n % x) : n;
}

int main(){
    long long n, x, r;
    cin >> n >> x;
    r = gcd(n, x);
    cout << (n / r - 1) * r * 3 << endl;
}


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

using namespace std;

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

    // 01 〜 12
    string a = S.substr(0, 2);
    string b = S.substr(2, 2);

    int aa = stoi(a);
    int bb = stoi(b);

    if (1 <= aa && aa <= 12) {
        // aa は 月 or 年
        if (1 <= bb && bb <= 12) {
            // bb は 月 or 年
            cout << "AMBIGUOUS" << endl;
            return 0;
        }
        // bb は 年
        cout << "MMYY" << endl;
        return 0;
    }
    // aa は 年
    if (1 <= bb && bb <= 12) {
        // bb は 月
        cout << "YYMM" << endl;
        return 0;
    }    

    cout << "NA" << endl;
    
    return 0;
}


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

#define ll long long int
#define mod ((int)1e9+7)

pair<int, int> dfs(vector<vector<int>> &graph, int curr_node, int parent){
	int w = 1, b = 1;
	for(int i = 0; i < graph[curr_node].size(); i++){
		if(graph[curr_node][i]!=parent){
			pair<int, int> temp = dfs(graph, graph[curr_node][i], curr_node);
			w = (((ll)temp.first+temp.second)*(ll)w)%mod;
			b = ((ll)temp.first*b)%mod;
		}
	}
	return make_pair(w, b);
}	

void test(vector<vector<int>> &graph){
	pair<int, int> answer = dfs(graph, 0, -1);
	cout << ((answer.first%mod) + (answer.second%mod))%mod << endl;
}

int main(){
	#ifndef ONLINE_JUDGE
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/input.txt", "r", stdin);
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/output.txt", "w", stdout);
	#endif
	int n;
	pair<int, int> temp;
	cin >> n;
	vector<vector<int>> graph(n);
	for(int i = 0; i < n-1; i++){
		cin >> temp.first >> temp.second;
		graph[temp.first-1].push_back(temp.second-1);
		graph[temp.second-1].push_back(temp.first-1);
	}
	test(graph);
	return 0;
}

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

int main(void) {
	int a,b,c;
	cin >> a >> b;
    c=10*b;
    for(int i=c;i<c+10;i++){
        double d=i*0.08;
        if(a==(int)d){
            cout << i << "\n";
            return 0;
        }
        //cout << d << "\n";
    }
    cout << "-1" << "\n";
	return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
j = 0

for i in range(len(S)):
    if S[i].islower() and T[i].islower():
        S = S.replace(S[i], alphabet[j])
        T = T.replace(T[i], alphabet[j])
        j += 1
    elif S[i].isupper() and T[i].isupper():
        pass
    else:
        break

if S == T:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3632
import java.math.BigInteger;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.Vector;

public class Main {
    public static Scanner r=new Scanner(System.in);
    public static void main(String[] args) {
        long n;
        n=r.nextLong();
        --n;
        ArrayList<Integer> a=new ArrayList<>();
        while(n>-1){
            int ch=(int)(n%26);
            a.add(ch);
            n/=26;
            --n;
        }
        Collections.reverse(a);
        for(int x:a){
            System.out.print((char)(x+'a'));
        }
    }
}


Measured memory_bytes: 35860
### 解答


#入力はじめ

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

#入力終わり


#累積和とる

A_wa = [0]
for i in range(N) :
    A_wa.append(A_wa[i]+A[i])

B_wa = [0]
for i in range(M) :
    B_wa.append(B_wa[i]+B[i])

#累積和計算おわり


ans = 0
end = N #二分探索の後に設定しなおしたいので先に設定しておく

for i in range(M+1):#Bを順番に増やしていくよー
    A_use = K-B_wa[i]
    if A_use<0: #Bだけでこえてる
        break
    
    ##Aは最大で何冊よめるかな
    A_MAX = 0
    start = 0
    while  end-start>=1 : #調べるのが2個以上
        now = int((start + end+1)/2) #切り上げ
        if A_wa[now]==A_use :  #A[i]がKと一致
            A_MAX = now #ここが最大
            break
        elif A_wa[now]<A_use : #A[i]がKより小さい
            start = now #目的の値はここ以上のとこにある
            A_MAX = now #現時点での最大値
        else : #A[i]がKより大きい
            end = now-1#目的の値はここより小さい
    ##Aの最大探すの終わり
    
    #これ最大？
    if A_MAX+i>ans :
        ans=A_MAX+i

    end=A_MAX #endの再設定

#コンソールにだす
print(ans)
    

    






Measured memory_bytes: 47128
#include <iostream>

using namespace std;

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

    int count = 0;
    for (int i = 0; i < N; ++i)
    {
        int d1, d2;
        cin >> d1 >> d2;

        if (d1 == d2)
        {
            ++count;
        }
        else
        {
            count = 0;
        }

        if (count == 3)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

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

int main(){
    string N;
    char n;

    cin >> N;

    n = N[N.length()-1];

    if(     n == '2' ||
            n == '4' ||
            n == '5' ||
            n == '7' ||
            n == '9'){
        cout << "hon" << endl;
        return 0;}
    else if(n == '0' ||
            n == '1' ||
            n == '6' ||
            n == '8'){
        cout << "pon" << endl;
        return 0;}
    else{
        cout << "bon" << endl;
        return 0;}
}


Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,d,v;
    while (cin>>n>>m) {
        if (n==0&&m==0) {
            break;
        } else {
            std::map<int, int> map;
            for (int i=0;i<n;i++) {
                cin>>d>>v;
                if (map.find(d)==map.end()) {
                    map.insert(make_pair(d,v));
                } else {
                    if (map.at(d)<v) {
                        map.erase(d);
                        map.insert(make_pair(d,v));
                    }
                }
            }
            int sum=0;
            for (int j=1;j<=m;j++) {
                sum+=map.at(j);
            }
            cout<<sum<<endl;
        }
    }
}


Measured memory_bytes: 3108
# frozen_string_literal: true

w, h, n = gets.split.map(&:to_i)
x, y, a = Array.new(n) { gets.split.map(&:to_i) }.transpose

l = x.select.with_index { |_, i| a[i] == 1 }.max || 0
r = x.select.with_index { |_, i| a[i] == 2 }.min || w
d = y.select.with_index { |_, i| a[i] == 3 }.max || 0
u = y.select.with_index { |_, i| a[i] == 4 }.min || h

puts l > r || d > u ? 0 : (r - l) * (u - d)

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

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

#define fr first
#define sc second

int main(){
	static ll n,m,v,p;
	static ll a[100010];
	scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
	for(int i = 0 ; i < n ; i ++){
		scanf("%lld",&a[i]);
	}
	sort(a,a+n);
	reverse(a,a+n);
	
	ll ret = p;
	ll sum = 0;
	for(int i = p ; i < n ; i ++){
		sum += a[i-1];
		ll q = p-1+n-i;
		if(sum+max((ll)0,v-q)*m <= (n-q)*(a[i]+m) && a[p-1] <= a[i]+m)ret ++;
	}
	cout << ret << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
lnt S(lnt x) {
	lnt ret = 0;
	for (; x; x /= 10)
		ret += x%10;
	return ret;
}
bool chk(lnt x, lnt y) {return x*S(y) <= y*S(x);}
int main() {
	int n, m = 0; read(n);
	for (lnt x = 1, d = 1; m < n; x += d)
		if (chk(x, x+d))
			printf("%lld\n", x), m++;
		else x -= d, d *= 10;
	return 0;
}


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

int main()
{
    string name[100001];
    int work[100001];
    int i, n, q, rest, time, head;
    cin >> n >> q;
    work[0] = 0;
    rest = n; time = 0; head = 0;

    for(i = 1; i <= n; i++) cin >> name[i] >> work[i];

    while(rest > 0){
        for(i = 0; i <= n; i++){
            if(work[i] > q){
                time = time + q;
                name[head] = name[i];
                work[head] = work[i] - q;
                head++;
                if(head > n) head = head - n - 1; // ???ring buffer.
                work[i] = 0;
            }else if(work[i] > 0){
                time = time + work[i];
                cout << name[i] << " " << time << endl;
                work[i] = 0;
                rest--;
            }else{}
            if(rest == 0) break;
        }
    };

    return 0;
}

Measured memory_bytes: 4532
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	ax,bx,m = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	b = readline() |> split |> parseMap
	ans = minimum(a)+minimum(b)
	for i in 1:m
		x,y,c = readline() |> split |> parseMap
		ans = min(ans,a[x]+b[y]-c)
	end
	println(ans)
end

main()

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

using namespace std;

int p[20000];
int vk[20000];

struct str{
    int a, b, w;
};

void Sort (str mas[], int l, int r){
    int i, j, s;
    s = mas[(l + r) / 2].w;
    i = l; j = r;
    while (i <= j){
        if (mas[i].w < s){
            i++;
        }
        else if (mas[j].w > s){
            j--;
        }
        else{
            swap(mas[i], mas[j]);
            i++; j--;
        }
    }
    if (i < r){
        Sort (mas, i, r);
    }
    if (l < j){
        Sort (mas, l, j);
    }
}

int get(int x){
    if (x == p[x]){
        return x;
    }
    else{
        return p[x] = get(p[x]);
    }
}

int unite (int x, int y){
    x = get(x); y = get(y);
    if (x == y){
        return 0;
    }
    if (vk[x] > vk[y]){
        swap(x, y);
    }
    p[x] = y;
    if (vk[x] == vk[y]){
        vk[y]++;
    }
    return 0;
}

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(a, max(b, c)) - min(a, min(b, c));
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
    int N, K;
    cin >> N >> K;
    long double ans = 0.0;
    for (int i = 1; i <= N; i++) {
        int dif = K - i;
        if (dif <= 0) ans += 1.0;
        else {
            long double a = log2((long double)K / (long double)i);
            ans += 1.0 / pow(2.0, ceil(a));
        }
    }
    ans /= (long double)N;
    cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

vector<int> g[100000];
int d[100000];
bool used[100000];
int pr[100000];
int ct[100000];
void dfs(int x){
  used[x]=1;
  ct[x]=1;
  for(auto y:g[x]){
    if(used[y]) continue;
    d[y]=d[x]+1;
    pr[y]=x;
    dfs(y);
    ct[x]+=ct[y];
  }
}

int main()
{
	int n; cin>>n;
  for(int i=0; i<n-1; i++){
    int a, b;
    cin>>a>>b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(0);
  int v1, v2, dmx=0;
  for(int i=0; i<n; i++){
    if(dmx<d[i]){
      v1=i;
      dmx=d[i];
    }
  }
  d[v1]=0;
  fill(used, used+n, 0);
  fill(ct, ct+n, 0);
  dfs(v1);
  pr[v1]=v1;
  dmx=0;
  for(int i=0; i<n; i++){
    if(dmx<d[i]){
      v2=i;
      dmx=d[i];
    }
  }
  //cout<<v1<<" "<<v2<<endl;
  vector<int> deg;
  int v0=v2;
  deg.push_back(0);
  v0=pr[v0];
  int pr0=v2;
  while(v0!=v1){
    int c=0;
    for(auto y:g[v0]){
      if(y==pr0) continue;
      if(y==pr[v0]) continue;
      if(ct[y]>1){
        cout<<-1<<endl;
        return 0;
      }
      c++;
    }
    deg.push_back(c);
    v0=pr[v0];
    pr0=pr[pr0];
  }
  deg.push_back(0);
  vector<int> ans1, ans2;
  int c=1;
  for(int i=0; i<deg.size(); i++){
    for(int j=1; j<=deg[i]; j++){
      ans1.push_back(c+j);
    }
    ans1.push_back(c);
    c+=(deg[i]+1);
  }
  reverse(deg.begin(), deg.end());
  c=1;
  for(int i=0; i<deg.size(); i++){
    for(int j=1; j<=deg[i]; j++){
      ans2.push_back(c+j);
    }
    ans2.push_back(c);
    c+=(deg[i]+1);
  }
  bool a1=1;
  for(int i=0; i<n; i++){
    if(ans1[i]==ans2[i]) continue;
    if(ans1[i]<ans2[i]){
      a1=1;
    }else{
      a1=0;
    }
    break;
  }
  if(a1){
    for(int i=0; i<n-1; i++) cout<<ans1[i]<<" ";
    cout<<ans1[n-1]<<endl;
  }else{
	for(int i=0; i<n-1; i++) cout<<ans2[i]<<" ";
    cout<<ans2[n-1]<<endl;
  }
	return 0;
}

Measured memory_bytes: 13560
#include<bits/stdc++.h>
namespace my_std{
	using namespace std;
	#define reg register
	#define Rint register int
	#define FOR(i,a,b) for(register int i=(a);i<=(b);++i)
	#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
	#define GO(x,p,e,i,v) for(register int i=p[x].head,v;i;i=e[i].link)
	#define MEM(a,v) memset(a,v,sizeof(a))
	#define PII pair<int,int>
	#define MP make_pair
	typedef long long LL;
	typedef double DB;
	inline int read(){
		char c=getchar();int ans=0,f=1;
		while(c>'9'||c<'0'){ f^=(c=='-'); c=getchar(); }
		for(;c<='9'&&c>='0';c=getchar()) ans=(ans<<1)+(ans<<3)+(c^48); return f?ans:-ans;
	}
	const int mod = 1e9 + 7;
	inline void inc(int &x,const int &y){ x+=y; if(x>=mod) x-=mod; }
	inline int ksm(int x,LL y){ int res=1; for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod; return res; }
	inline int gcd(int x,int y){ if(x>y) swap(y,x); return y?gcd(y,x%y):x; }
	#define FILE(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
}
using namespace my_std;

int a,b;

int main(){
	a = read() , b = read();
	printf("%d",(a * 3 + b) >> 1);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	string S;
	cin >> S;

	int cnt[3] = { 0, 0, 0 };
	rep(i, S.size()) {
		cnt[S[i] - 'a']++;
	}

	int minV = 100000000;
	int maxV = 0;
	rep(i, 3) {
		minV = min(minV, cnt[i]);
		maxV = max(maxV, cnt[i]);
	}

	if (maxV - minV >= 2) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}


    return 0;
}


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

int main()
{
  string s; cin >> s;
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl; 
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define inf (ll)1e9

#define debugone(x) cout << #x << " " << x << "\n"; cout.flush();
#define debugtwo(x) cout << #x << "-------------" << "\n";for(auto &it: x) cout << it << " ";cout << "\n"; cout.flush();
#define debugthree(x, i, j) cout << #x << "------------" << "\n";cout << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cout << x[k] << " ";cout << "\n"; cout.flush();



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
		
	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
}

Measured memory_bytes: 256
import scala.io.Source.stdin

object Main extends App {
  val O = 'o';val X = 'x'
  stdin.getLines.foreach { s =>
    val r = s.toArray match {
      case Array(O,O,O,_*) | Array(_,_,_,O,O,O,_*) | Array(_,_,_,_,_,_,O,O,O)
      | Array(O,_,_,O,_,_,O,_*) | Array(_,O,_,_,O,_,_,O,_) | Array(_,_,O,_,_,O,_,_,O)
      | Array(O,_,_,_,O,_,_,_,O) | Array(_,_,O,_,O,_,O,_*)  => O
      case Array(X,X,X,_*) | Array(_,_,_,X,X,X,_*) | Array(_,_,_,_,_,_,X,X,X)
      | Array(X,_,_,X,_,_,X,_*) | Array(_,X,_,_,X,_,_,X,_) | Array(_,_,X,_,_,X,_,_,X)
      | Array(X,_,_,_,X,_,_,_,X) | Array(_,_,X,_,X,_,X,_*)  => X
      case _ => 'd'
    }
    println(r)
  }
}

Measured memory_bytes: 44000
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 0;

    for (int i = 3; i <= n; i+=2) {
      int count = 0;
      for (int k = 1; k <= n; k++) {
        if (i%k == 0) {
          count++;
        }
      }
      if (count == 8) {
        ans++;
      }
    }

    System.out.println(ans);

  }

}


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

int main(){
    double K;
    cin >> K;
    int N = K;
    int count = 0;
    
    
        count = K/(2.0);
    
    if(N %2 == 0){
        cout << count<< endl;
    }else{
    cout << count+1  << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K,S;
    cin>>K>>S;
    int count=0;
    for(int i=0;i<=min(K,S);i++){
        for(int j=0;j<=min(S-i,K);j++){
            if(S-i-j<=K){count++;}
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;

void solve(){
    int s, w;
    cin >> s >> w;
    if(w >= s) {
        cout << "unsafe";
    }    
    else {
        cout << "safe";
    }
}

 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, x, ans;
	int a, b, c;
	while(true) {
		cin>>n>>x;
		if(n==0&&x==0) break;
		ans=0;
		for(a=1; a<=n-2; ++a) {
			for(b=a+1; b<n; ++b) {
				c=x-a-b;
				if(c<=b) break;
				if(c<=n) ++ans;
			}
		}
		cout<<ans<<'\n';
	}
	return 0;
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second

int a[34];
void solve(){  
	int valid=0;
	int n;
	cin>>n;
	rep(i,0,n){
		cin>>a[i];
		int f=1;
		repd(j,i-1,0){
			if(a[j]>a[i]){
				f=0;
				break;
			}
		}
		valid+=f;
	}
	cout<<valid<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,ans[510][510];

void solve(int lb,int ub,int co)
{
	int mid=(lb+ub)/2;
	for(int i=lb;i<=mid;i++) for(int j=mid+1;j<=ub;j++) ans[i][j]=co;
	if(lb==ub) return;
	solve(lb,mid,co+1);
	solve(mid+1,ub,co+1);
}

int main()
{
	cin>>n;
	solve(1,n,1);
	repn(i,n-1)
	{
		for(int j=i+1;j<=n;j++) cout<<ans[i][j]<<' ';
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int x,y;
  cin>>x>>y;
  int z=y-2*x;
  if(z>=0 && z%2==0 && (x-z/2)>=0){
    cout<<"Yes\n";
  }
  else cout<<"No\n";
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3628
#include <iostream>
#include <set>
using namespace std;
#define ll long long
#define mod 1000000007

// n!
ll factorial[100002];

// n!^(mod - 1)
ll mod_factorial[100002];

// factor^(q)
ll pow (ll factor, ll q) {
  if (q == 1) {
    return factor % mod;
  }
  if (q % 2 == 0) {
    ll sub = pow (factor, q / 2);
    return ((sub % mod) * (sub % mod)) % mod;
  }
  else {
    return ((factor % mod) * (pow (factor, q - 1) % mod)) % mod;  
  }
}

void init () {
  for (ll i = 0; i <= 100001; i++) {
    if (i == 0 || i == 1) {
      factorial[i] = 1;    
    }    
    else {
      factorial[i] = ((i % mod) * (factorial[i - 1] % mod)) % mod;   
    }
  }  
  for (ll i = 0; i <= 100001; i++) {
    if (i == 0 || i == 1) {
      mod_factorial[i] = 1;  
    }  
    else {
      mod_factorial[i] = pow (factorial[i], mod - 2) % mod;  
    }
  }
}

ll C(ll n, ll k) {
  if (n < k) {
    return 0;  
  }
  // nCk を返す
  // n! * (k!)^(mod - 1) * (n - k)!^(mod - 1) に対応する
  ll sub = ((factorial[n] % mod) * (mod_factorial[k] % mod)) % mod;
  return ((sub % mod) * (mod_factorial[n - k] % mod)) % mod;
      
}

int main () {
  init(); 
  ll n;
  cin >> n;
  set<ll> box;
  ll itrsecond = 0;
  ll itrfirst;
  ll a[n + 1];
  for (ll i = 0; i <= n; i++) {
    ll sub;
    cin >> sub;
    if (box.count(sub) == 1) {
      itrsecond = i;  
    }    
    box.insert(sub);
    a[i] = sub;
  }
  for (ll i = 0; i <= n; i++) {
    if (a[i] == a[itrsecond]) {
      itrfirst = i;
      break;  
    }    
  }
  for (ll i = 1; i <= n + 1; i++) {
    if (i == 1) {
      cout << n << endl;  
    }  
    else {
      if (i == n + 1) {
        cout << 1 << endl;  
      }
      else {
        ll sub = (C(n + 1, i) % mod + mod - C(itrfirst + n - itrsecond, i - 1)% mod) % mod;
        cout << sub << endl;
      }
    }
  }
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;

int main(){
	int n; cin >> n;
	vi b(n); rep(i, n) cin >> b[i];
	vi ans;
	bool ok = true;
	rep(i,n) {
		int pos = -1;
		rep(j, b.size()){
			if (j+1 == b[j]) pos = max(pos, j);
		}
		if(pos != -1){
			ans.push_back(b[pos]);
			b.erase(b.begin()+pos);
		} else ok = false;
	}
	reverse(all(ans));
	if (ok){
	rep(i,n) cout << ans[i] << endl;
	} else {
		cout << -1 <<endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)

{
	int ab, cd, ef, gh;

	scanf("%d", &ab);

	cd = ab / 3600;
	ef = ab % 3600 / 60;
	gh = ab % 3600 % 60;

	if(0 <= ab && ab <86400);
	{
		printf("%d:%d:%d\n", cd, ef, gh);
	}
	
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;

    cin >> n;

    vector<int> l(n);

    int tmp = 0;
    int i = 0;
    int max = 0;
    int sum = 0;
    while(cin >> tmp) {
        if(max < tmp) {
            max = tmp;
        }

        sum += tmp;

        l[i] = tmp;
        i ++;
        if(i >= n) {
            break;
        }
    }

    sum -= max;

    if(sum > max) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

ll ans = 0, parent = 0;
vec color(100010,-1);
vector<vector<P> > G(100010,vector<P>(0));
void dfs(ll v, ll ng){
    //cout<<v<<' '<<ng<<endl;
    ll temp = 0;
    for(P p : G[v]){
        //cout<<v<<' '<<p.fi<<endl;
        if(temp == ng) ++temp;
        if(color[p.se] == -1) {
            color[p.se] = temp;
            dfs(p.fi, temp);
            ++temp;
        }
    }
    return;
}

int main(){
    cin>>N;
    //vector<P> edge(0);
    rep(i,N-1){
        cin>>A>>B;
        --A,--B;
        G[A].emplace_back(B,i);
        G[B].emplace_back(A,i);
    }
    rep(i,N) {
        ll temp = G[i].size();
        if(ans < temp){
            ans = temp;
            parent = i;
        }
    }
    cout<<ans<<endl;
    //cout<<parent<<endl;
    dfs(parent,-1);
    rep(i,N - 1) cout<<color[i] + 1<<endl;
}

Measured memory_bytes: 9216
#include<stdio.h>
int main(){
    int n,a,b,c,d;
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);

    if((n+a-1)/a*b < (n+c-1)/c*d)
        printf("%d\n",(n+a-1)/a*b);
    else printf("%d\n",(n+c-1)/c*d);

    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define pb push_back
using namespace std;

const int INF = 10000000;
int cost[2][111][111];
int d[111];
bool used[111];
int V;
struct edge {
    int from,to,money,time;
};
vector<edge> E;

int bf(int s,int g,int r){
    FOR(i,0,111)d[i]=INF;
    d[s]=0;
    while(1){
        bool update=false;
        FOR(i,0,E.size()){
            const edge& e=E[i];
            int from=e.from;
            int to=e.to;
            int cost=r?e.time:e.money;
            if(d[to]>d[from]+cost){
                d[to]=d[from]+cost;
                update=true;
            }
        }
        if(!update)break;
    }
    return d[g];
}

int main(){
    int n;
    while(1){
        cin>>n>>V;
        if(!(n||V)) break;
        E.clear();
        FOR(i,0,n){
            int a,b,m,t;cin>>a>>b>>m>>t;
            E.pb({a,b,m,t});
            E.pb({b,a,m,t});
        }
        int k;cin>>k;
        FOR(i,0,k){
            int p,q,r;cin>>p>>q>>r;
            cout<<bf(p,q,r)<<endl;
        }
    }
}

Measured memory_bytes: 1344
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && a != c || a == c && a != b || b == c && b != a) cout << "Yes";
  else cout << "No";
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
N, K = [int(i) for i in input().split()]
MOD = 10**9 + 7

sum_ = 0
for k in range(K, N+2):
  max_ = N*(N + 1)//2 - (N - k) * (N - k + 1)//2
  min_ = k*(k-1)//2 
  sum_ += ((max_ - min_ +1) % MOD)

print(sum_ % MOD)

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

#define ll long long

signed main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  for(;;){
    c -= b;
    if(c<=0){
      cout << "Yes" << "\n";
      break;
    }
    a -= d;
    if(a<=0){
      cout << "No" << "\n";
      break;
    }
  }
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>


using namespace std;


void white_cells()
{
  int H, W, h, w;
  cin >> H >> W >> h >> w;

  cout << (H * W) - (h * W) - (H * w) + (h * w) << "\n";
}


void double_helix()
{
  char b;
  cin >> b;

  if (b == 'A') cout << "T\n";
  else if (b == 'T') cout << "A\n";
  else if (b == 'C') cout << "G\n";
  else  cout << "C\n";

}


void five_antennas()
{
  vector<int> a(5);
  for (int i = 0; i < 5; ++i) cin >> a[i];
  int k;
  cin >> k;

  if (a[4] - a[0] > k)
  {
    cout << ":(\n";
    return;
  }
  cout << "Yay!\n";

}

void buttons()
{
  int a, b;
  cin >> a >> b;

  int v_max = 0;
  for (int i = 0; i < 2; ++i) {
    if (a > b) {
      v_max += a;
      --a;
    }
    else
    {
      v_max += b;
      --b;
    }
  }
  cout << v_max << "\n";
}


void biscuit_generator()
{
  int a, b, t;
  cin >> a >> b >> t;

  cout << t / a * b << "\n";
}


int main()
{
  //white_cells();
  //double_helix();
  //five_antennas();
  //buttons();
  biscuit_generator();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _I inline
#define _R register
#define memset(x,y) memset(x,y,sizeof(x))
#define mod 1000000007
#define INF 0x3f3f3f3f
#define ull unsigned long long
#define ll long long
using namespace std;
//char buf[1<<21],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
_I int read(){
	int x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9')f|=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	f&&(x=-x);
	return x;
}
const int N=205;
int n,cnt=1,ans=-1,head[N],bl[N*N*2],maxx;
char ch;
bool vst[N];
struct node{
	int next,to;
}e[N*N*2];
struct note{
	int fa,x,d;
};
void add(int x,int y){
	++cnt;
	e[cnt].next=head[x];
	e[cnt].to=y;
	head[x]=cnt;
}
bool bfs(int s){
	memset(vst,0);
	queue<note>q;
	while(!q.empty())q.pop();
	q.push((note){0,s,1});vst[s]=1;
	while(!q.empty()){
		int x=q.front().x,fa=q.front().fa,d=q.front().d;q.pop();
		maxx=max(maxx,d);
		for(_R int i=head[x];i;i=e[i].next){
			if(e[i].to==fa)continue;
			if(bl[e[i].to]>0&&(abs(bl[e[i].to]-d)!=1))return false;
			bl[e[i].to]=d+1;
		}
		for(_R int i=head[x];i;i=e[i].next){
			if(e[i].to==fa)continue;
			if(!vst[e[i].to])vst[e[i].to]=1,q.push((note){x,e[i].to,d+1});
		}
	}
	return true;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();
	for(_R int i=1;i<=n;++i)
		for(_R int j=1;j<=n;++j){
			do{ch=getchar();}while(ch!='1'&&ch!='0');
			if(ch=='1')add(i,j);
		}
	for(_R int i=1;i<=n;++i){
		memset(bl,0);
		bl[i]=1;maxx=0;
		bfs(i)&&(ans=max(ans,maxx));
	}
	printf("%d",ans);
	return 0;
}


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

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


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
#include <set>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 100000;
int k;
string s;

int main(){
  set<string> ss;
  cin >> s >> k;
  int n = s.size();
  for(int i = 1; i <= min(5, k); i++) {
    REP(j, n - i + 1) {
      ss.insert(s.substr(j, i));
    }
  }

  auto itr = ss.begin();
  REP(i, k - 1) itr++;

  cout << *itr << endl;

  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s,t;cin>>s>>t;
    if(s.size()+1==t.size() and s==t.substr(0,s.size())) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
ll R,G,B,N;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>R>>G>>B>>N;
	ll ans=0;
	REP(r,N+1){
		REP(g,N+1){
			ll rem=N-r*R-g*G;
			if(rem>=0 && rem%B==0){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL dp[55][55][2505];
int main(){
    int n, a, x;
    scanf("%d%d", &n, &a);
    dp[0][0][0] = 1;
    for(int i=1;i<=n;i++){
        scanf("%d", &x);
        for(int j=0;j<i;j++){
            for(int k=0;k<=50*j;k++){
                dp[i][j][k] += dp[i-1][j][k];
                dp[i][j+1][k+x] += dp[i-1][j][k];
            }
        }
    }   
    LL ans = 0;
    for(int j=1;j<=n;j++) ans += dp[n][j][j*a];
    printf("%lld\n", ans);
}

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

int main(int argc, char const *argv[])
{
	int h,w;
	cin>>h>>w;
	char a[h][w];
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cin>>a[i][j];
		}
	}	
	for (int i = 0; i < h; ++i)
	{
		int f=1;
		for (int j = 0; j < w; ++j)
		{
			if (a[i][j]=='#')
			{
				f=0;
				break;
			}
		}
		if (f)
		{
			--h;
			for (int j = i; j < h; ++j)
			{
				for (int k = 0; k < w; ++k)
				{
					a[j][k]=a[j+1][k];
				}
			}
			--i;
		}
	}	
	for (int i = 0; i < w; ++i)
	{
		int f=1;
		for (int j = 0; j < h; ++j)
		{
			if (a[j][i]=='#')
			{
				f=0;
				break;
			}
		}
		if (f)
		{
			--w;
			for (int j = i; j < w; ++j)
			{
				for (int k = 0; k < h; ++k)
				{
					a[k][j]=a[k][j+1];
				}
			}
			--i;
		}
	}
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cout<<a[i][j];
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    test = 0
    for i in range(1,10):
        if test == 1:
            break
        for j in range(1,10):
            if i*j == n:
                print('Yes')
                test = 1
                break

    if test == 0:
        print('No')


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
s=input()
n=len(s)
if n%2==0:
    if s[n//2-1]!=s[n//2]:
        print(n//2)
    else:
        for i in range(2,n//2+1):
            if s[n//2-i]!=s[n//2] or s[n//2-1+i]!=s[n//2]:
                print(n//2+i-1)
                break
        else:
            print(n)
else:
    for i in range(1,n//2+1):
        if s[n//2-i]!=s[n//2] or s[n//2+i]!=s[n//2]:
            print(n//2+i)
            break
    else:
        print(n)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  ll V, E;
  cin >> V >> E;
  vvll dp(V, vll(V, INF));
  for(int i = 0; i < V; i++){
    dp.at(i).at(i) = 0;
  }
  for(int i = 0; i < E; i++){
    int s, t, d;
    cin >> s >> t >> d;
    dp.at(s).at(t) = d;
  }
  for(int k = 0; k < V; k++){
    for(int i = 0; i < V; i++){
      for(int j = 0; j < V; j++){
        if(dp.at(i).at(k) == INF || dp.at(k).at(j) == INF) continue;
        chmin(dp.at(i).at(j), dp.at(i).at(k) + dp.at(k).at(j));
      }
    }
  }
  bool flag = true;
  for(int i = 0; i < V; i++){
    if(dp.at(i).at(i) < 0) flag = false;
  }
  if(flag){
    for(int i = 0; i < V; i++){
      for(int j = 0; j < V; j++){
        if(dp.at(i).at(j) != INF) cout << dp.at(i).at(j);
        else cout << "INF";
        if(j == V-1) cout << endl;
        else cout << ' ';
      }
    }
  }
  else cout << "NEGATIVE CYCLE" << endl;
  
  
}



Measured memory_bytes: 3256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 1000000007
#define M 2200000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}

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

	int n;
	cin>>n;
	set<string>se;
	rep(i,n){
		string s;
		cin>>s;
		se.insert(s);
	}
	cout<<se.size()<<endl;
}


Measured memory_bytes: 19204
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int a[10];

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    FOR(4)
        cin >> a[i];
    sort(a, a + 4);
    int ans = abs(a[0] + a[3] - a[1] - a[2]);
    cout << ans << endl;


    solve();
    return 0;
}



Measured memory_bytes: 3216
import bisect
n = int(input())
a = list(int(i) for i in input().split())
a2 = sorted(a)
median1 = a2[n//2-1]
median2 = a2[n//2]
for i in a:
  if i <= median1:
    print(median2)
  else:
    print(median1)

Measured memory_bytes: 25228