akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
typedef long double ld;

int L[105];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= n; i++)
		L[i] = L[i - 1] + L[i - 2];
	cout << L[n] << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int ans = 0;
		for(int i = 1; i < N + 1; i++){
			if(i < 10){
				ans++;
			}
			if(100 <= i && i < 1000){
				ans++;
			}
			if(10000 <= i && i < 100000){
				ans++;
			}
		}
		System.out.println(ans);
		stdIn.close();
	}
}


Measured memory_bytes: 35688
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()

lim = int(-(-sqrt(2*N)//1))+1
for i in range(lim):
	if i*(i+1) == 2*N:
		break
else:
	print("No")
	exit()

n = i+1
print("Yes")
print(n)
ans = [[] for _ in range(n)]
cnt = 1
for j in range(n):
	k = j+1
	while k < n:
		ans[j].append(cnt)
		ans[k].append(cnt)
		cnt += 1
		k += 1

for l in range(n):
	print(i, *ans[l])


Measured memory_bytes: 15040
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
  double t, x;
  cin >> t >> x;
  printf("%lf\n", t/x);
}

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

void printVector(vector<int> v) {
    for (auto x : v) {
        cout << x << ' ';
    }
    cout << '\n';
}

void printArray(ll A[], int size) {
    for (int i = 0; i <= size - 1; i++) cout << A[i] << ' ';
}

int main() {
    int n = 0;
    string s;
    cin >> s;
    string s1 = "";
    string s2 = "";
    n = s.size();
    for (int i = 0; i <= n - 1; i++) {
        if (i % 2 == 0) {
            s1 += '0';
            s2 += '1';
        }
        else {
            s1 += '1';
            s2 += '0';
        }
    }
    int m1 = 0;
    int m2 = 0;
    for (int i = 0; i <= n - 1; i++) {
        if (s[i] != s1[i]) m1++;
        if (s[i] != s2[i]) m2++;
    }
    cout << min(m1, m2) << '\n';
    return 0;
}

Measured memory_bytes: 3928
loop do
  n,k = gets.chomp.split(' ').map(&:to_i)
  break if n+k == 0

  stock = gets.chomp.split(' ').map(&:to_i)
  use=[]
  n.times{use << gets.chomp.split(' ').map(&:to_i)}
  sum=[]
  use.transpose.each{|x| sum << x.inject(:+)}
  success=true
  stock.zip(sum){|x,y|success=false if x < y}
  puts success ? 'Yes' : 'No'
end

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

using namespace std;

long long inf=1000000007;

int main(){
	long long n,m,x;
	cin>>n>>m>>x;
	bool flag=false;
	vector<vector<long long>> hoge(n,vector<long long>(m+1));
	for(int i=0;i<n;i++){
		for(int j=0;j<=m;j++){
			cin>>hoge.at(i).at(j);
		}
	}

	long long ans=inf;

	for(int tmp=0;tmp<(1<<n);tmp++){
		bitset<12> bits=tmp;
		vector<long long> rikai(m,0);
		long long kane=0;

		for(int i=0;i<n;i++){
			if(bits.test(i)){
				kane+=hoge.at(i).at(0);
				for(int j=1;j<=m;j++){
					rikai.at(j-1)+=hoge.at(i).at(j);
				}
			}
		}

		bool ok=true;
		for(auto a:rikai){
			if(a<x) ok=false;
		}

		if(ok){
			flag=true;
			ans=min(ans,kane);
		}
	}

	cout<<(flag ? ans : -1)<<endl;

	return 0;
}


Measured memory_bytes: 3628
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
S = input()

# ABC = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

ans = ""
for s in S:
    n = N
    if ord(s) + N > 90:
        n = N - 26
    ans += chr(ord(s) + n)

print(ans)


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, Q; cin >> N >> Q;
  int crt = 1;
  vector<bool> ok(N+2);
  ok[2] = true;
  REP(i,Q){
	int a, b; cin >> a >> b;
	swap(ok[a], ok[b]);
	if(crt == a) crt = b;
	else if(crt == b) crt = a;
	ok[crt-1] = ok[crt+1] = true;
  }
  ok[crt] = true;

  int ans = 0;
  FOR(i,1,N+1) ans += ok[i];
  cout << ans << endl;

  return 0;
}


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

int main(){
    while (1){
	int n;
	int input[5001];
	int max1;
	cin >> n;
	if (n == 0) break;

	for (int i = 0; i < n; i++){
	    cin >> input[i];
	}
	max1 = input[0];

	for (int i = 0; i < n; i++){
	    int sum = 0;
	    for (int j = i; j < n; j++){
		sum += input[j];
		max1 = max(max1, sum);
	    }
	}
	cout << max1 << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/


typedef long long ll;
ll N, A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> A >> B;
    if (N == 1) {
        if (A != B) printf("0\n");
        else printf("1\n");
        return;
    }
    if (A > B) {
        printf("0\n");
        return;
    }

    ll ma = A + B * (N - 1);
    ll mi = A * (N - 1) + B;

    ll ans = ma - mi + 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll l,r,d;
  std::cin>>l>>r>>d;

  ll ans=0;

  rep(i,l,r+1)if(i%d==0)ans++;

  std::cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();		
		int x=tx-sx;
		int y=ty-sy;
		for(int i=0;i<y;i++) System.out.print("U");
		for(int i=0;i<x;i++) System.out.print("R");
		for(int i=y;i>0;i--) System.out.print("D");
		for(int i=x;i>0;i--) System.out.print("L");
		System.out.print("L");
		for(int i=0;i<=y;i++) System.out.print("U");
		for(int i=0;i<=x;i++) System.out.print("R");
		System.out.print("D");
		System.out.print("R");
		for(int i=y;i>=0;i--) System.out.print("D");
		for(int i=x;i>=0;i--) System.out.print("L");
		System.out.print("U");		
		sc.close();
	}
}


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

public class Hello
{
    public static void Main()
    {
        var q = new Queue<int>();
        var z = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1 };
        foreach (var x in z) q.Enqueue(x);
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var st = int.Parse(line[0]);
            var ar = int.Parse(line[1]);
            var bs = -1;
            while (bs != st) { bs = q.Dequeue(); q.Enqueue(bs); }
            var bslist = new List<int>();
            while (true)
            {
                bs = q.Dequeue(); q.Enqueue(bs);
                if (bs == ar) { display(bslist, st, ar); break; }
                else if (bs == st) bslist.Clear();
                else bslist.Add(bs);
            }
        }
    }  
    public static void display (List<int> b,int st,  int ar)
    {
        Console.Write("{0} ", st);
        foreach (var x in b) Console.Write("{0} ", x);
        Console.WriteLine(ar);
    }
}

Measured memory_bytes: 10068
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	vector<vector<char>> C(2,vector<char>(3));
	rep(i,2)rep(j,3) cin >> C[i][j];
	bool ok = true;
	rep(i,3){
		if(C[0][i] != C[1][2-i]) ok = false;
	}
	cout << (ok ? "YES" : "NO") << endl;
}

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

int gcd(int a, int b){
  if(b > a) return gcd(b, a);
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  int n; cin >> n;
  
  int ans = 0;
  
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    int temp; cin >> temp;
      a.at(i) = temp;
  }
  
  vector<int> l(n + 2, 0), r(n + 2, 0);
  
  for(int i = 1; i <= n; i++){
    l.at(i) = gcd(a.at(i - 1), l.at(i - 1));
  }
  for(int i = n; i > 0; i--){
    r.at(i) = gcd(a.at(i - 1), r.at(i + 1));
  }
  
  for(int i = 0; i < n; i++){
    ans = max(ans, gcd(l.at(i), r.at(i + 2)));
  }
  
  cout << ans << endl;
  
}

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


public class Main {

	Scanner sc;
	int[][] cards;
	
	int[][] cost;
	
	//i番目からj番目までの山を重ねる時の最小cost
	int dfs(int i,int j){
		if(cost[i][j]!=-1)return cost[i][j];
		
		int res=Integer.MAX_VALUE;
		if(i==j) res=0;
		else{
			for(int k=i;k<j;++k){
				res=Math.min(res, dfs(i,k)+dfs(k+1,j)+cards[i][0]*cards[k][1]*cards[k+1][0]*cards[j][1]);
			}
		}
		return cost[i][j]=res;
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	void io(){
		sc=new Scanner(System.in);
		int n=ni();
		cards=new int[n][2];
		cost=new int[n][n];
		for(int[] e:cost)Arrays.fill(e,-1);
		for(int i=0;i<n;++i){
			for(int j=0;j<2;++j)cards[i][j]=ni();
		}
		System.out.println(dfs(0,n-1));
	}
	
	void debug(Object...os){
		System.err.println(Arrays.deepToString(os));
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().io();
	}

}

Measured memory_bytes: 23456
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int X, A;

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

  if (X < A) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
  return 0;
}

Measured memory_bytes: 892
#include <stdio.h>

int main(){
    int A,P,c;
    int k,kotae1=0,kotae;
    scanf("%d %d",&A,&P);
    c=A*3;
    kotae1=c+P;
    kotae=kotae1/2;
    printf("%d\n",kotae);
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int k, n;
	cin >> k >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0, mx = 0;
	repn(i, 1, n) ans += a[i] - a[i - 1], mx = max(mx, a[i] - a[i - 1]);
	ans += a[0] + (k - a[n - 1]);
	mx = max(mx, a[0] + (k - a[n - 1]));
	ans -= mx;
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

ll l[100];

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

	l[0] = 2;
	l[1] = 1;

	for (int i = 2;i <= n;i++) {
		l[i] = l[i - 1] + l[i - 2];
	}

	cout << l[n] << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a, b = [], []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(x+y)
    b.append(x-y)

a.sort()
b.sort()

ans = max(a[-1]-a[0], b[-1]-b[0])
print(ans)

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

//------------Constants----------------

//------------Variables----------------
int a,b;
//------------Functions----------------

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//------------Input--------------------
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> a >> b;
//------------Work---------------------
    cout << max(2*a-1,max(2*b-1,a+b));
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var h, w, n, sr, sc int
	var s, t string
	fmt.Scan(&h)
	fmt.Scan(&w)
	fmt.Scan(&n)
	fmt.Scan(&sr)
	fmt.Scan(&sc)
	fmt.Scan(&s)
	fmt.Scan(&t)

	dpxmin := make([]int, n+1)
	dpxmax := make([]int, n+1)
	dpymin := make([]int, n+1)
	dpymax := make([]int, n+1)
	dpxmin[n] = 1
	dpxmax[n] = w
	dpymin[n] = 1
	dpymax[n] = h

	for i := 1; i <= n; i++ {
		dpxmin[n-i] = dpxmin[n-i+1]
		dpxmax[n-i] = dpxmax[n-i+1]
		dpymin[n-i] = dpymin[n-i+1]
		dpymax[n-i] = dpymax[n-i+1]

		switch t[n-i] {
		case 'L':
			if dpxmax[n-i+1] < w {
				dpxmax[n-i]++
			}
		case 'R':
			if dpxmin[n-i+1] > 1 {
				dpxmin[n-i]--
			}
		case 'U':
			if dpymax[n-i+1] < h {
				dpymax[n-i]++
			}
		case 'D':
			if dpymin[n-i+1] > 1 {
				dpymin[n-i]--
			}
		}

		switch s[n-i] {
		case 'L':
			dpxmin[n-i]++
		case 'R':
			dpxmax[n-i]--
		case 'U':
			dpymin[n-i]++
		case 'D':
			dpymax[n-i]--
		}

		if dpxmin[n-i] > dpxmax[n-i] || dpymin[n-i] > dpymax[n-i] {
			fmt.Println("NO")
			return
		}
	}

	if dpxmin[0] <= sc && sc <= dpxmax[0] && dpymin[0] <= sr && sr <= dpymax[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 9728
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

typedef long long ll;

using namespace std;

int main()
{vector<char> vec; ll N; cin >> N;
 if( N == 0){cout << '0' << endl;}
else{
 while(N != 0)
 {if(N % 2 == 0){ N = - ( N / 2 );  vec.push_back('0');}
  else{N = -((N - 1) / 2); vec.push_back('1');}}
 
 reverse(vec.begin(),vec.end());
 
 for(ll i = 0; i < vec.size() ; i++)
 {cout << vec[i];}}
 
 return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
// priority_queue<int> PQ;

int main(){
  vector <pair <ll,ll>> q;
  ll n,k;

  scanf("%lld %lld", &n, &k);

  int i;
  for(i = 0;i < n;i++){
    ll a,b;
    scanf("%lld %lld", &a, &b);
    q.push_back(make_pair(a,b));
  }

  sort(q.begin(),q.end());

  i = 0;
  while(1){
    if(q[i].second >= k){
      printf("%lld\n", q[i].first);
      break;
    }

    k -= q[i].second;
    i++;
  }

  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
template <class T>inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

const ll MOD = 1e9+7;
vecl res(60);

ll modpow(ll a, ll n) {
    ll ans = 1;
    REP(i,n) {
        ans *= a;
        ans %= MOD;
    }
    return ans;
}

int main() {
    int N; cin >> N;
    vecl A(N); REP(i,N) cin >> A[i];
    REP(i,N) {
        REP(j,60) {
            if((A[i]>>j)&1) res[j]++;
        }
    }
    ll ans = 0;
    REP(i,60) {
        ll a = (res[i] * (N-res[i]))%MOD;
        ans += a*modpow(2,i);
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
import math
N = int(input())
def ceil(x,y):
    if x % y == 0:
        return x // y
    else:
        return x // y + 1
t=1
a=1
for i in range(N):
    T , A = [int(i) for i in input().split(' ')]
 #   print(T,A)
    n1 = ceil(t , T)
    n2 = ceil(a , A)
    n = max(n1,n2)
    #while T*n <= t and A*n <= a:
     #   n += 1
    
    t = T*n
    a = A*n
#    print(t,a)

print(t+a)


Measured memory_bytes: 3060
n = int(input())
p = list(map(int, input().split()))

counter = 0

for i in range(1, n - 1):
	if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i - 1] > p[i] and p[i] > p[i + 1]):
		counter += 1
		
		
print(counter)

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

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

    ll n,d;
    cin >> n >> d;
    d *= d;
    int ans = 0;
    auto get_dist = [&](ll a, ll b){
        return ((a * a) + (b * b));
    };
    for(int i=0; i<n; ++i){
        ll a, b;
        cin >> a >> b;
        if( get_dist(a, b) <= d ){
            ++ans;
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 string S,T;
  cin>>S>>T;
  string X=S+T;
  ll A=stoll(X);
  for(ll i=0;i<=sqrt(A);i++) {
if(i*i==A) {
cout<<"Yes"<<endl;
  return 0;
}
  }
  
  cout<<"No"<<endl;
}


Measured memory_bytes: 3608
//#pragma warning disable

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

public class Test
{
    public static void Main()
    {
        var line1 = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var a = line1[0];
        var b = line1[1];
        var c = line1[2];

        HashSet<Tuple<long, long, long>> hs = new HashSet<Tuple<long, long, long>>();

        int count = 0;

        while (true)
        {
            if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
            {
                Console.WriteLine(count);
                return;
            }

            var a2 = (b + c) / 2;
            var b2 = (c + a) / 2;
            var c2 = (a + b) / 2;

            var tuple = Tuple.Create(a2, b2, c2);

            if (hs.Contains(tuple))
            {
                break;
            }

            hs.Add(tuple);
            a = a2;
            b = b2;
            c = c2;

            count++;
        }

        Console.WriteLine(-1);
    }
}

Measured memory_bytes: 13524
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    
    int n = Integer.parseInt(br.readLine());
    TreeMap<Integer,Integer> have = new TreeMap<>(Collections.reverseOrder());
    TreeMap<Integer,Integer> toCome = new TreeMap<>();
    String[] s = br.readLine().split(" ");
    int max = 0;
    for (int i=0; i<(1<<n); i++) {
      int val = Integer.parseInt(s[i]);
      if (toCome.containsKey(val)) {
        toCome.put(val, toCome.get(val)+1);
      } else {
        toCome.put(val, 1);
      }
      if (val>max)
        max = val;
    }
    have.put(max, 1);
    if (toCome.get(max)==1) {
      toCome.remove(max);
    } else {
      toCome.put(max, toCome.get(max)-1);
    }
    
    for (int i=0; i<n; i++) {
      TreeMap<Integer, Integer> update = new TreeMap<>();
      for (int val: have.keySet()) {
        for (int j=0; j<have.get(val); j++) {
          Integer next = toCome.lowerKey(val);
          if (next==null) {
            System.out.println("No");
            return;
          }
          toCome.put(next, toCome.get(next) - 1);
          if (toCome.get(next)==0) 
            toCome.remove(next);
          if (update.containsKey(next)) {
            update.put(next, update.get(next)+1);
          } else {
            update.put(next, 1);
          }
        }
      }
      for (int val: update.keySet()) {
        if (have.containsKey(val)) {
          have.put(val, have.get(val) + update.get(val));
        } else {
          have.put(val, update.get(val));
        }
      }
    }
    System.out.println("Yes");
  }
}


Measured memory_bytes: 127256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

ll f(const vector<ll> &x, const int skip, const ll X) {
  ll work = 0LL;
  const int N = x.size();
  for(int i = 0; i < N; i++) {
    int a = i / skip;
    if(a == 0) work += X + 5LL * x[i];
    else {
      work += (ll)(3 + 2 * a) * x[i];
    }
  }
  //  cout << skip << "," << work << endl;                                     
  return work;
}

int main() {
  int N;    ll X ; cin>>N>>X;
  vector<ll> x(N);
  REP(i,N) cin>>x[i];
  ll ans = 1LL<<62;

  reverse(x.begin(), x.end());
  int left = 1, right = N;
  while(left < right) {
    int oleft = left, oright = right;
    int s1 = (left * 2 + right) / 3;
    int s2 = (left + right * 2) / 3;
    ll w1 = f(x, s1, X);
    ll w2 = f(x, s2, X);
    if(w1 < w2) {
      right = s2;
    } else {
      left = s1;
    }
    ans = min(ans, min(w1, w2));
    if(oleft ==	left &&	oright == right) break;
    //    cout << skip << " " << work << " " << ans << endl;                   
  }
  cout << ans + (ll)N * X << endl;
  return 0;
}





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

int main() {
    cout << fixed << setprecision(20);
	double A,B,M,H;
    cin >> A >> B >> H >> M;
    M = 60*H + M;
    double p = M_PI;
    double s = cos((11*M/360)*p);
    double L;
    L = pow((A*A + B*B - 2*A*B*s),0.50);
    cout << L << endl;

}

Measured memory_bytes: 4356
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+5;
const int inf=0x3f3f3f3f;
bitset<maxn> lsum[maxn],rsum[maxn];
int a[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]=min(a[i],k);
	}
	lsum[0][0]=true;
	for(int i=1;i<=n;i++)
		lsum[i]=lsum[i-1]|(lsum[i-1]<<a[i]);
	rsum[n+1][0]=true;
	for(int i=n;i>=1;i--)
		rsum[i]=rsum[i+1]|(rsum[i+1]<<a[i]);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		vector<int> l,r;
		for(int j=k;j>=0;j--)
			if(lsum[i-1][j])
				l.push_back(j);
		for(int j=0;j<=k;j++)
			if(rsum[i+1][j])
				r.push_back(j);
		int cnt1=0,cnt2=0;
		for(int t:l)
		{
			while(cnt1<r.size()&&r[cnt1]<k-t-a[i])
				cnt1++;
			while(cnt2<r.size()&&r[cnt2]<k-t)
				cnt2++;
			if(cnt1<cnt2)
			{
				ans++;
				break;
			}
		}
	}
	cout<<n-ans<<endl;
	return 0;
}




Measured memory_bytes: 16768
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}

struct UnionFindTree{
    vec par,size,rank,height;//par[i]:iの親,size[i]:iの属する木の要素数,rank[i]:iが、自分の属する木の何階層目にあるか,height[i]:iを根とする部分木の高さ
    int setNum;//木が何本あるか
    UnionFindTree(int n):par(n),size(n),rank(n),height(n){
        rep(i,n){
            par[i]=i;
            size[i]=1;
            rank[i]=-1;
            height[i]=1;
        }
        setNum=n;
    }
    int root(int x){
        if(par[x]==x)return x;
        return root(par[x]);
    }
    void unite(int x, int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry)return;
        if(height[rx]<height[ry]){
            par[rx]=ry;
            size[ry]+=size[rx];
        }else{
            par[ry]=rx;
            size[rx]+=size[ry];
            if(height[rx]==height[y]){
                height[rx]++;
            }
        }
        setNum--;
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    int getSize(int x){//xの属する木の要素数
        return size[root(x)];
    }
    int getSetNum(){//木の本数
        return setNum;
    }
    int getRank(int x){//xが何階層目にあるか
        if(par[x]==x)return 0;
        return 1;
    }
    int getHeight(int x){//xの属する木の高さ
        return height[root(x)];
    }
};
int main(){
    int n=in(),m=in();
    UnionFindTree uf(n);
    rep(i,m){
        int a=in(),b=in(),c=in();
        uf.unite(a-1,b-1);
    }
    int ans=0;
    rep(i,n)if(!uf.getRank(i))ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    ll n;
    cin >> n;
    ll sum = 0;
    for (int i = 1; i <= n; i++)
    {
        if (ceil(fmod(i, 15)) == 0 or ceil(fmod(i, 3)) == 0 or ceil(fmod(i, 5)) == 0)
        {
        }
        else
        {
            sum += i;
        }
    }
    cout << sum << endl;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {

    ll a, b; cin >> a >> b;
    ll diff = b-a;
    ll a_ = 0;

    REP1(i, 1000){
        // cout << a_ << endl;
        if(i == diff){
            cout << a_ - a << endl;
            return 0;
        }
        a_ += i;
    }


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3684
N,K = map(int,input().split())
V = list(map(int,input().split()))
max_cnt = -float('inf')
for k in range(min(N,K)+1):
  for i in range(k+1):
    j = k - i
    le = V[:i]
    ri = V[-j:] if j > 0 else []
    ne = [i for i in le if i < 0]+[j for j in ri if j < 0]
    ne.sort()
    max_cnt = max(sum(le)+sum(ri) - sum(ne[:K-k]),max_cnt)
    
print(max_cnt)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();

		System.out.println(A*B);

	}

}


Measured memory_bytes: 35920
while(True):
    n, x = map(int, input().split())
    if(n == x == 0):
        break
    ans = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if(i + j + k == x):
                    ans += 1
    print(ans)

Measured memory_bytes: 7664
num = int(input())

def digitSum(n):
    s = 0
    while n!=0:
        s += n%10
        n //=10
    return s


arr = []
rev_arr = []
for n in range(1,num):
    arr.append(n)
rev_arr = arr[::-1]

final_arr = []
for n in range(num-1):
    val = digitSum(arr[n]) + digitSum(rev_arr[n])
    final_arr.append(val)

print(min(final_arr))

Measured memory_bytes: 8600
#include <iostream>
#ifdef TEST_NUMAHHA
#include <fstream>
#endif
using namespace std;
 
int body(){
 
  int N, i, j;
  char W[100][10];
  char cstart[100], cend[100];
 
#ifdef TEST_NUMAHHA
std::ifstream in("input.txt");
std::cin.rdbuf(in.rdbuf());
#endif
 
  cin >> N;
  for(i=0;i<N;i++){
    cin >> W[i];
    for(j=0;j<10;j++){
      if ('\0'==W[i][j]){
	break;
      }
    }
    //printf("%s  ",W[i]);
    //printf("(%c,%c)\n",W[i][0], W[i][j-1]);
    cstart[i]=W[i][0];
    cend[i]=W[i][j-1];
    if(i>0){
      if (cend[i-1]!=cstart[i]) return 0;
      for(j=0;j<i;j++){
	for(int k=0;k<10;k++){
	  if( W[i][k]!=W[j][k] ) break;
	  if( '\0'==W[i][k] && '\0'==W[j][k] ) return 0;
	  if( k==9 && W[i][9]==W[j][9] ) return 0;
	}
      }
    }
  }
 
  
  
  return 1;
}
 
 
int main(void) {
 
  char ans[10];
 
  if(body()) sprintf(ans,"Yes");
  else sprintf(ans,"No");
 
  cout <<ans<< '\n';
#ifdef TEST_NUMAHHA
  printf("press Enter!\n");
  getchar();
#endif  
  return 0;
}

Measured memory_bytes: 256
// RAM RAM
    #include <bits/stdc++.h>
    #define int long long
    #define pb push_back
    #define ppb pop_back
    #define vi vector<int>
    #define mp make_pair
    #define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
    #define N 55
    const int MOD=1000000007;
    using namespace std;
     
    int32_t main()
    {
    	ios_base::sync_with_stdio(false);cin.tie(0);
    	
     

     
        int n,m;cin>>n>>m;
        int res=0;
        if(m>=2*n){
        	m=m-2*n;
        	res+=n;
        }else{
        	res+=(m/2);
        	m=m%2;
        	//cout<<"Check"<<endl;
        }

        
        res+=((m/4));
        // while(m>=4){
        // 	res++;
        // 	m-=4;
        // }

        cout<<res<<endl;
    	return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[3005][3005],x,y;
string s,t,lcs;
int main(){
  cin>>s>>t;
  for(int i=1;i<=(int)s.size();i++){
    for(int j=1;j<=(int)t.size();j++){
      if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
      else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  }
  x=s.size();
  y=t.size();
  while(x>0 && y>0){
    if(s[x-1]==t[y-1]){
      lcs+=s[x-1];
      x--;
      y--;
    }else if(dp[x-1][y]>dp[x][y-1]) x--;
    else y--;
  }
  reverse(lcs.begin(),lcs.end());
  cout<<lcs;
  return 0;
}

Measured memory_bytes: 38832
h,w = map(int,input().split())
 
if h == 1 or w == 1:
    print(1)
elif h % 2 == 0:
    print(int(h*w/2))
elif h % 2 == 1 and w % 2 == 0:
    print(int(h*w/2))
else:
    print(int(h*(w//2)+h//2+1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100000
#define rint register int
#define gc() getchar()
inline int read(int r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}
vector<int> e[MAXN+5]; int fa[MAXN+5], h[MAXN+5], n, K, Ans;
void DFS(int p){h[p] = 1; for(auto v:e[p]) DFS(v), h[p] = max(h[p],h[v]+1); if(h[p]==K&&fa[p]>1) ++Ans, h[p] = 0;}
int main(){n = read(), K = read(), Ans = read()>1; for(rint i = 2; i <= n; e[fa[i]=read()].push_back(i), i++); DFS(1); printf("%d\n",Ans); return 0;}

Measured memory_bytes: 11136
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        int N = int.Parse(ReadLine());
        var A = ReadLine().Split().Select(long.Parse).ToArray();
        var d1 = new long[N];
        var d2 = new long[N];
        d1[0] = A[0];
        for (int i = 1; i < N; i++)
        {
            d1[i] = Gcd(d1[i-1], A[i]);
        }
        d2[N - 1] = A[N - 1];
        for (int i = N - 2; i >= 0; i--)
        {
            d2[i] = Gcd(d2[i + 1], A[i]);
        }

        long ans = 0;
        ans = Max(ans, d1[N - 2]);
        ans = Max(ans, d2[1]);
        for (int i = 0; i < N-2; i++)
        {
            ans = Max(ans, Gcd(d1[i],d2[i+2]));
        }
        WriteLine(ans);
    }
    static long Gcd(long a,long b)
    {
        return a == 0 ? b : Gcd(b % a, a);
    }
}


Measured memory_bytes: 40636
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAXN 100010
using namespace std;

int n;
int d[MAXN];
int a[MAXN];
int a0[4][MAXN];

namespace Fenwick{
	int c[MAXN];

	void clear(){ memset(c,0,sizeof c); }

	void add(int x,int v){
		while(x<=n){
			c[x]+=v;
			x+=x&(-x);
		}
	}

	int sum(int x){
		int res=0;
		while(x){
			res+=c[x];
			x-=x&(-x);
		}
		return res;
	}
}

int main(){
#ifdef DEBUG
	freopen("E.in","r",stdin);
#endif
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a0[1][i]);
	for(int i=1;i<=n;i++) scanf("%d",&a0[2][i]);
	for(int i=1;i<=n;i++) scanf("%d",&a0[3][i]);
	int t0=0,t1=0;
	for(int i=1;i<=n;i++){
		int v1=min(a0[1][i],a0[3][i]),v3=max(a0[1][i],a0[3][i]);
		a[i]=v1/3+1;
		if(v3!=v1+2 || v1%3!=1 || a0[2][i]!=v1+1 || (a[i]-i)%2!=0){
			puts("No");
			return 0;
		}
		if(v1==a0[3][i]){
			if(i&1) t1^=1;
			else t0^=1;
		}
	}
	for(int i=n-((n&1)^1);i>=1;i-=2){
		int temp=Fenwick::sum(a[i]);
		Fenwick::add(a[i],1);
		if(temp&1) t0^=1;
	}
	Fenwick::clear();
	for(int i=n-(n&1);i>=2;i-=2){
		int temp=Fenwick::sum(a[i]);
		Fenwick::add(a[i],1);
		if(temp&1) t1^=1;
	}
	if(t0 || t1) puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
ll b[1000005];
int main()
{
	while(1)
    {
        ll a[1005];
        ll n,m;
        cin >> n>>m;
        if(n==0)break;
        for(ll i=0; i<n; i++)
        {
            cin>>a[i];
        }
        ll k=0;
        for(ll i=0; i<n; i++)
            for(ll j=0; j<n; j++)
            {
                if(i==j)b[k]=0;
                else if(a[i]+a[j]<=m)
                b[k]=a[i]+a[j];
                else b[k]=0;
                k++;
            }
        ll sum=0;
        for(ll i=0; i<k; i++)
        {
            sum=max(b[i],sum);
        }
        if(sum==0)cout<<"NONE"<<endl;
        else cout<<sum<<endl;
    }
	return 0;
}





Measured memory_bytes: 10920
#include<stdio.h>

int main(){
    int a, b, n, sum, i;

    while(scanf("%d %d %d", &a, &b, &n) != EOF){
        sum = 0;
        a %= b;
        for(i = 0; i < n; i++){
            sum += a * 10 / b;
            a = a * 10 % b;
        }
        printf("%d\n", sum);

    }
    return 0;
};

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

int a[200000];

long long int comb(int n,int r){
    long long int ans = 1;
    for(int i=n;i>n-r;--i){
        ans = ans * i;
    }
    for(int i=1;i<r+1;i++){
        ans = ans / i;
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    memset(a,0,sizeof(a));
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    int ansN = a[n-1];
    int ansR = 0;
    if(ansN%2==0){
        a[n-1] = ansN/2;
        sort(a,a+n);
        for(int i=0;i<n;i++){
            if(a[i]==ansN/2){
                if(a[i+1] - a[i] < a[i] - a[i-1]) ansR = a[i+1];
                else ansR = a[i-1];
            }
        }
    }else{
        a[n-1] = (ansN-1) / 2;
        sort(a,a+n);
        for(int i=0;i<n;i++){
            if(a[i] == (ansN-1)/2){
                if(a[i+1] - a[i] - 1 < a[i] - a[i-1]) ansR = a[i+1];
                else ansR = a[i-1];
            }
        }
    }
    cout << ansN << " " << ansR << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int x; cin >> x;
    if (x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, M;
	vector<vector<int>> G;
	// vector<vector<int>> L;
	
	cin>>N>>M;
	
	G.resize(N);
	
	for(int i = 0; i < M; i++){
		int A, B;
		
		cin>>A>>B;
		A--, B--;
		
		G[A].push_back(B);
	}
	
	for(int i = 0; i < N; i++){
		vector<pair<int,int>> dis(N, make_pair(-1,INF));
		queue<pair<int,int>> Q;
		
		Q.push(make_pair(i,0));
		
		dis[i] = make_pair(-1,0);
		
		// cout<<"i = "<<i<<endl;
		
		while(!Q.empty()){
			bool flag = false;
			pair<int,int> P = Q.front(); Q.pop();
			int d = P.second, now = P.first;
			
			// cout<<"now "<<now<<" "<<d<<endl;
			
			
			
			if(dis[now].second < d) continue;
			
			for(int next : G[now]){
				if(next == i){
					// flag = true;
					vector<int> ans;
					
					// ans.push_back(i);
					
					for(;now != -1;){
						ans.push_back(now);
						
						now = dis[now].first;
					}
					
					sort(ans.begin(), ans.end());
					
					ans.erase(unique(ans.begin(), ans.end()),ans.end());
					
					map<int,int> mp1, mp2;
					
					for(int i = 0; i < ans.size(); i++){
						mp1[ans[i]]++;
					}
					
					for(int i = 0; i < ans.size(); i++){
						for(int j = 0; j < G[ans[i]].size(); j++){
							if(mp1[G[ans[i]][j]] == 0) continue;
							mp2[G[ans[i]][j]]++;
							mp2[ans[i]]--;
						}
					}
					
					for(int i = 0; i < ans.size(); i++){
						if(mp2[ans[i]]){
							flag = true;
							break;
						}
					}
					
					if(flag) break;
					cout<<ans.size()<<endl;
					
					for(int i = 0; i < ans.size(); i++){
						cout<<ans[i]+1<<endl;;
					}
					// cout<<endl;
					
					return 0;
				}
				
				if(dis[next].second > dis[now].second + 1){
					// cout<<"next "<<next<<endl;
					dis[next].second = dis[now].second + 1;
					dis[next].first = now;
					Q.push(make_pair(next, dis[next].second));
				}
				if(flag) break;
			}
			if(flag) break;
		}
	}
	
	cout<<-1<<endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  for(int i=min(a,b); i<=max(a,b); i++){
    if(i < min(a,b)+k ||i > max(a,b)-k){
      cout << i << endl;
    }
  }
}

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

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

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    int n;
    cin>>n;
    vector<int> x(n),y(n),z(n);
    for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>z[i];

    set<tuple<int,int,int>> s;

    auto isSpace=[&](int xp,int yp,int zp){
        if(!(0<=xp && xp<a && 0<=yp && yp<b && 0<=zp && zp<c)) return true;
        return bool(s.count(make_tuple(xp,yp,zp)));
    };
    ll res=(a*b+b*c+c*a)*2;
    for(int i=0;i<n;i++){
        for(int j=0;j<6;j++){
            int tox=x[i]+dx[j],toy=y[i]+dy[j],toz=z[i]+dz[j];
            if(isSpace(tox,toy,toz)){
                res--;
            }
            else{
                res++;
            }
            
        }
        s.insert(make_tuple(x[i],y[i],z[i]));
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 3200
def main():
    N = int(input())
    S = list(input())
    alpha = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    for i in range(len(S)):
        idx = alpha.index(S[i])
        idx += N
        if idx > len(alpha) - 1:
            idx -= len(alpha)
        S[i] = alpha[idx]
    print("".join(S))
main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long

using namespace std;

signed main(){
    string str;
    //nums.resize(n);
    cin >> str;
    for(int i=0;i<str.size();i++){
        if(str[i]=='7') {
            cout << "Yes" << endl;
            break;
        }
        else{
            if(i==str.size()-1){
                cout << "No" << endl;

            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3628
from collections import Counter

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

E = list(Counter(V[0::2]).most_common())+[(10001,0)]
O = list(Counter(V[1::2]).most_common())+[(10002,0)]

need_not_change = 0
if E[0][0] != O[0][0]:
    need_not_change = E[0][1] + O[0][1]
else:
    need_not_change = max([E[0][1] + O[1][1],E[1][1] + O[0][1]])
print(N - need_not_change)

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

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  for(int i = n / 2 - 1; i > 0; i--){
    if(s.substr(0, i) == s.substr(i, i)){
      cout << 2 * i << endl;
      return 0;
    }
  }
}

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

int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    ll sum=A+B;
    ll ans;
    ll q=N/(sum);
    ll r=N%(sum);
    ll p;
    if(r>=A) p=A;
    else p=r;
    ans=q*A+p;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int prime[1000000];
int main(){
    prime[0]=-1;
    prime[1]=-1;
    for(int i=2;i<1000000;i++){
        if(prime[i]==0){
            prime[i]=1;
            for(int j=i*2;j<1000000;j+=i)prime[j]=-1;
        }
    }
    int now;
    while(~scanf("%d",&now)){
        int ans=0;
        for(int i=1;i<now+1;i++)if(prime[i]==1)ans++;
        printf("%d\n",ans);
    }
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; ++i)
  {
    cin >> p[i];
  }

  sort(p.begin(), p.end());
  int ans = accumulate(p.begin(), p.end(), 0);
  cout << ans - p.back() / 2;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3608