akhauriyash/Code-Regression huggingface dataset:
// Example program
#include <iostream>
#include <string>

using namespace std;

int main()
{
  int64_t a,b,k;
  	cin >> a >> b >> k;
  	if(a > k){
  	        cout << (a - k ) << " " << b << "\n";
  	    } else {
  	            if(b >= (k-a))
  	                cout << "0 " << b - (k - a) << "\n"; 
  	            else
  	                cout << "0 0\n";
  	        }
      return 0;
}


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

int main(){
    long long N, Q;
    scanf("%lld%lld", &N, &Q);

    vector<long long> A(N), AS(N + 2), S(N + 1), X((N - 1) / 2), a((N + 1) / 2);
    for(int i = 0; i < N; ++i){
        scanf("%lld", &A[i]);
        AS[i + 2] = A[i] + AS[i];
        S[i + 1] = A[i] + S[i];
    }
    
    for(int i = 1; i <= (N + 1) / 2; ++i){
        a[i - 1] = *S.rbegin() - *(S.rbegin() + i) + *(AS.rbegin() + i * 2);
    }

    for(int i = 1; i <= (N - 1) / 2; ++i){
        X[i - 1] = *(A.rbegin() + i) + *(A.rbegin() + i * 2);
    }

    reverse(a.begin(), a.end());
    reverse(X.begin(), X.end());

    for(long long i = 0, x = 0; i < Q; ++i){
        scanf("%lld", &x);
        printf("%lld\n", a[lower_bound(X.begin(), X.end(), x * 2) - X.begin()]);
    }
    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;

ll find(ll N) { 
    ll count = 0; 
	for(ll i = 5; N / i >= 1; i *= 5) 
        count += N/i;
    return count;
} 

int main(int argc, char ** argv) {
	ll N;
	cin >> N;
	if(N&1) puts("0");
	else cout << find(N/2) << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int MAX = 45;
int F[MAX];

int fib(int n)
{
    if (F[n] != 0) return F[n];
    if (n == 0) F[n] = 1;
    if (n == 1) F[n] = 1;
    if (n >= 2) F[n] = fib(n-2) + fib(n-1);
    return F[n];
}

int main()
{
    for (int i = 0; i != MAX; ++i)
    {
        F[i] = 0;
    }
    int n;
    cin >> n;
    cout << fib(n) << endl;
    return 0;
}


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

int main(){
    int n,y;
    cin>>n>>y;
    for(int a=0;a<=n;a++){
        for(int b=0;b<=n;b++){
            int c=n-a-b;
            if(c<0) continue;
            if(a*10000+b*5000+c*1000==y){
                cout<<a<<" "<<b<<" "<<c<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String alp[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
    for(int i = 0;i<26;i++){
      if(s.equals(alp[i])){
        System.out.println(alp[i+1]);
        return;
      }
    }
  }
}


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

using namespace std;

int main() {
  int n, m, x;
  cin >> n >> m >> x;

  int a[101];
  for (int i = 0; i <= 100; ++i) a[i] = 0;
  for (int i = 0; i < m; ++i) {
    int in;
    scanf("%d", &in);
    a[in] = 1;
  }

  int cost1 = 0;
  int xx = x;
  while (xx != 0) {
    cost1 += a[xx];
    --xx;
  }

  int cost2 = 0;
  xx = x;
  while (xx != n) {
    cost2 += a[xx];
    ++xx;
  }

  cout << (cost1 < cost2 ? cost1 : cost2) << endl;
}


Measured memory_bytes: 256
x = input()
chars = list(x)
a = ord(chars[0])
b = ord(chars[1])
c = ord(chars[2])
d = ord(chars[3])
if (a==b and c==d and a!=c) or (a==c and b==d and a!=b) or (a==d and b==c and a!=b):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");

		int d = Integer.parseInt(line[0]);
		int n = Integer.parseInt(line[1]);

		int n1 = 0;
		int n2 = 0;

		if(n>=(100^2)){
			n2 = n/((int)Math.pow(100,2));
//			System.out.println(n2);
		}
		if(n>=100){
			n1 = n/100 ;
//			System.out.println(n2);
		}
		n = n+n1+n2;

		System.out.println((int)Math.pow(100,d)*n);


	}
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> x>>y;
  if(x>1&&y>1){
    cout << (x*y+1)/2 << endl;
  }
  else{
    cout<<1<<endl;
  }
}


Measured memory_bytes: 256
// finish date: 2018/06/16
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <functional>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define pii pair<int,int>
const int bigmod = 1000000007;
#define INF 1050000000


int main() {
    int D, N;
    cin >> D >> N;
    if (N == 100) N++;
    D = round(pow(100, D));
    cout << N * D << endl;
    return 0;
}






Measured memory_bytes: 896
import java.util.Scanner;
import java.math.BigDecimal;

public class Main {
        public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                double r = sc.nextDouble();
                double area = Math.PI * r * r;
                double length = 2 * Math.PI * r;
                System.out.println(BigDecimal.valueOf(area) + " " + BigDecimal.valueOf(length));
                sc.close();
        }
}



Measured memory_bytes: 28456
#include<stdio.h>
#include<string.h>
int main(void){
    int n;
    scanf("%d",&n);
    char s[n+1],t[n+1];
    scanf("%s%s",s,t);
    for(int i=0;n>i;++i)
    printf("%c%c",s[i],t[i]);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

vector<Int> solve(Int N, Int A, Int B){
  if(A + B > N + 1) return {-1};
  if(A * B < N) return {-1};

  vector<Int> res;
  Int cur = 0;
  Int num = A * B - N;
  for(Int i=0;i<B;i++) res.push_back(cur + B - i);
  cur += B;
  for(Int i=0;i<A - 1;i++){
    if(num - (B - 1) >= 0) res.push_back(cur + 1), num -= B - 1, cur++;
    else if(num){
      Int x = cur + (B - num);
      pr(res, cur, x, num);
      for(Int i=0;i<B-num;i++) res.push_back(x--);
      cur += (B - num);
      num = 0;
    }
    else{
      for(Int i=0;i<B;i++) res.push_back(cur + B - i);
      cur += B;
    }
  }
  Int x = N;
  assert(res.size() == N);
  return res;
}


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N, A, B;
  cin>>N>>A>>B;

  auto ans = solve(N, A, B);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 8300
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = -(1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


//変数
constexpr int MAX_M = 2000;
constexpr int MAX_N = 1000;
struct Edge { ll from, to, cost; };

array<Edge, MAX_M> edges;
array<ll, MAX_N> d;
ll N, M;




//サブ関数
//入力
void input()
{
	cin >> N >> M;
	REP(i, M) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		edges[i] = { a,b,c };
	}
}

bool update()
{
	bool updated = false;
	REP(i,M){
		auto edge = edges[i];
		if (d[edge.from] != INFL && d[edge.to] < d[edge.from] + edge.cost) {
			d[edge.to] = d[edge.from] + edge.cost;
			if (edge.to == N - 1)updated = true;
		}
	}
	return updated;
}

//計算
void calc()
{
	constexpr int s = 0;
	REP(i, N)d[i] = INFL;
	d[s] = 0;
	REP(times, 2*N) update();

	if (update())cout << "inf" << endl;
	else {
		cout << d[N - 1] << endl;
	}
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int dise[6];

void swap(int a, int b, int c, int d){
	int temp;
	
	temp = dise[a];
	dise[a] = dise[b];
	dise[b] = dise[c];
	dise[c] = dise[d];
	dise[d] = temp;
}

int main(void)
{
	int i, n, sum, temp;
	char input[6];
	
	while (scanf("%d", &n), n != 0){
		sum = 1;
		dise[0] = 1;
		dise[1] = 2;
		dise[2] = 3;
		dise[3] = 5;
		dise[4] = 4;
		dise[5] = 6;
			
		for (i = 0; i < n; i++){
			scanf("%s", input);
			
			if (strcmp(input, "North") == 0){
				swap(0, 1, 5, 3);
			}
			
			else if (strcmp(input, "East") == 0){
				swap(0, 4, 5, 2);
			}
			
			else if (strcmp(input, "West") == 0){
				swap(0, 2, 5, 4);
			}
			
			else if (strcmp(input, "South") == 0){
				swap(0, 3, 5, 1);
			}
			
			else if (strcmp(input, "Right") == 0){
				swap(1, 2, 3, 4);
			}
			
			else if (strcmp(input, "Left") == 0){
				swap(1, 4, 3, 2);
			}

			sum += dise[0];
		}
		
		printf("%d\n", sum);
	}
	
	return (0);
}

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

int main() {
  int H, W;
  cin >> H >> W;

  // Make grid
  vector<vector<char>> grid(H, vector<char>(W));

  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> grid.at(i).at(j);
    }
  }

  // change dot to ! at "W"
  for(int i=0, dot=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(grid.at(i).at(j) == '.'){
        dot++;
      }
      if(dot == W){
        for(int k=0; k<W; k++){
          grid.at(i).at(k) = '!';
        }
      }
    }
    dot=0;
  }

  // change dot to ! at "H"
  for(int i=0, dot=0; i<W; i++){
    for(int j=0; j<H; j++){
      if(grid.at(j).at(i) == '.' || grid.at(j).at(i) == '!' ){
        dot++;
      }
      if(dot == H){
        for(int k=0; k<H; k++){
          grid.at(k).at(i) = '!';
        }
      }
    }
    dot=0;
  }

  // skip !
  for(int i=0, count=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(grid.at(i).at(j) == '!'){
        count++;
        continue;
      }
      else{
        cout << grid.at(i).at(j);
      }
    }
    if(count == W){
      count=0;
      continue;
    }
    else if(i == H-1){
      break;
    }
    else{
      count=0;
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  int64_t sum = 0;
  for(int64_t i=1; i*i <= N; i++){
    if((N-i) %i == 0){
      int64_t m = (N-i)/i;
        if(m > i){
          sum += m;
        }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
D=dict()
for i in range(N):
    try:
        D[A[i]]+=1
    except:
        D[A[i]]=1

total=0
for k,v in D.items():
    total+=k*v

Q=int(input())
for _ in range(Q):
    b,c=map(int,input().split())
    if b in D:
        total=total-D[b]*b+D[b]*c
        print(total)
        try:
            D[c]+=D[b]
        except:
            D[c]=D[b]
        D[b]=0
    else:
        print(total)
        continue

Measured memory_bytes: 20628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner teclado = new Scanner(System.in);

		int n, k;
		n = teclado.nextInt();
		k = teclado.nextInt();
		int count =0;
		int soma;
		if(k <= n && n <=50 && 1 <= k ) {
			for(int i=k-1; i <n ;i ++) {
				soma=i+i+1;
				count++;
			
			}
		}
		System.out.println(count);

	}

}


Measured memory_bytes: 23764
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	str := oneStr()

	nums := []int{}

	for _, s := range str {
		n := string(s)
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}

	ans := calc(nums)

	fmt.Println(ans)
}

func calc(nums []int) int {
	if len(nums) == 1 {
		return 0
	}

	if len(nums) == 2 {
		if nums[0] == nums[1] {
			return 1
		} else {
			return 0
		}
	}

	ans0 := 0
	ans1 := 0
	for i := 0; i < len(nums); i++ {
		// 0スタート
		if i%2 != 0 && nums[i] == 0 {
			ans0++
		}
		if i%2 == 0 && nums[i] == 1 {
			ans0++
		}

		//1
		if i%2 != 0 && nums[i] == 1 {
			ans1++
		}
		if i%2 == 0 && nums[i] == 0 {
			ans1++
		}
	}

	return min(ans0, ans1)
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


Measured memory_bytes: 6400
# -*- coding: utf-8 -*-

N = int(input())
F = []
for n in range(N):
    f = [i for i in input().split()]
    # biaryに変換
    str_f = ''.join(f)
    int_f = int(str_f, 2)
    F.append(int_f)

P = []
for n in range(N):
    p = [int(i) for i in input().split()]
    P.append(p)


max_benefit = -100000000000000
for i in range(1, 1024):
    benefit = 0
    for n in range(N):
        # ANDをとる
        and_number = F[n] & i
        count = bin(and_number).count('1')
        benefit += P[n][count]
    if benefit > max_benefit:
        max_benefit = benefit

print(max_benefit)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{  
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	string a ,b;
	cin >> a >> b;
	int len1=a.size();
	int len2=b.size();
		for(int i=0;i<len1;i++)

		{
			cout<< a[i];
			if(i<len2)
			
			{
				cout<<b[i];
			}
		}
	
	
}

Measured memory_bytes: 3528
N = int(input())
A = list(map(int, input().split()))

flag = True
j = 1
cnt = 0

while flag:
    flag = False
    for i in reversed(range(j, N)):
        if A[i] < A[i-1]:
            tmp = A[i]
            A[i] = A[i-1]
            A[i-1] = tmp
            cnt += 1
            flag = True
    j += 1

result = [str(i) for i in A]
print(' '.join(result))
print(cnt)



Measured memory_bytes: 5600
#include <stdio.h>

int main(void){
    int i,j,n,m;
    char c,s[5]={'S','H','C','D','\0'};
    static int card[4][13];
    scanf("%d\n",&n);
    
    for(i=0;i<n;i++){
        scanf("%c %d\n",&c,&m);
        for(j=0;j<4;j++)
            if(s[j]==c)
                card[j][m-1]=1;
    }
    
    for(i=0;i<4;i++)
        for(j=0;j<13;j++)
            if(card[i][j]==0)
                printf("%c %d\n",s[i],j+1);
    
    return 0;
}


Measured memory_bytes: 2048
package main

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

var s = bufio.NewScanner(os.Stdin)

func nextInt() int {
	s.Scan()
	i, e := strconv.Atoi(s.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func solve(H, W int) int {
	var (
		sa int
		sb int
		sc int
	)

	ans := 1000000000000
	for h := 1; h <= H-1; h++ {
		sa = h * W

		for i := 0; i < 2; i++ {
			if i%2 == 0 {
				w := W / 2
				sb = (H - h) * w
				sc = (H - h) * (W - w)
			} else {
				hh := (H - h) / 2
				sb = hh * W
				sc = (H - h - hh) * W
			}

			smax := max(max(sa, sb), sc)
			smin := min(min(sa, sb), sc)

			ans = min(ans, smax-smin)
		}
	}
	return ans
}

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

	H, W := nextInt(), nextInt()

	fmt.Println(min(solve(H, W), solve(W, H)))
	// var (
	// 	h int
	// 	w int
	// )
	// if H < W {
	// 	h = H
	// 	w = W
	// } else {
	// 	h = W
	// 	w = H
	// }

	// smax := w * (h / 2)

	// if (h - h/2) < w/2 {

	// }

	// smin := (h - h/2) * (w / 2)

	// fmt.Printf("smax=%d, smin=%d\n", smax, smin)

}

func abs(a int) int {
	if a < 0 {
		return -1 * a
	}
	return a
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

int a[1000000];

signed main(){
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    sort(a,a+n);
    int count=0,ans=0;
    if(n==1) cout<<a[0]<<endl;
    else{
      for(int i=0;i<n;i++){
	if(i==0) continue;
	if(a[i]==a[i-1]) count++;
	if(a[i]!=a[i-1]||i==n-1){
	  if(2*(count+1)>n){
	    cout<<a[i-1]<<endl;
	    ans=1;
	    break;
	  }
	  count=0;
	}
      }
      if(ans==0)
	cout<<"NO COLOR"<<endl;
    }
  }
  return 0;
}




Measured memory_bytes: 10884
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector

int main(){
    int n,k;
    cin >> n >> k;
    ve<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(), p.end());
    int ans=0;
    rep(i,k) ans += p[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    void run(){
	String ans = solve();
	System.out.println(ans);
    }

    String solve(){
	String ans = "A";
	while(sc.hasNext()){
	    String s = sc.next();
	    String l = s.substring(0, 1);
	    String r = s.substring(2, 3);
	    if(ans.equals(l)) ans = r;
	    else if(ans.equals(r)) ans = l;
	    //System.out.println("*"+ans);
	}
	return ans;
    }
}

Measured memory_bytes: 17128
#include<cstdio>
#include<map>
using namespace std;

#define ran 202202

const int lim = 2e9+7;

int n, q;
int l[ran], r[ran], v[ran], a[ran];
map<int, int> mp;
map<int, int> ::iterator it;
int mi[ran*9*8];
int ans[ran*9*8];

void upd(int id, int s, int e, int l, int r, int val) {
	if(s==l && e==r) {
		mi[id] = min(mi[id], val);
		return;
	}
	int mid = (s+e)/2;
	if(r<=mid) upd(id*2, s, mid, l, r, val);
	else
	if(l>mid) upd(id*2+1, mid+1, e, l, r, val);
	else {
		upd(id*2, s, mid, l, mid, val);
		upd(id*2+1, mid+1, e, mid+1, r, val);
	}
}

void dfs(int id, int s, int e) {
	if(s==e) {
		ans[s] = mi[id];
		return;
	}
	mi[id*2] = min(mi[id*2], mi[id]);
	mi[id*2+1] = min(mi[id*2+1], mi[id]);
	int mid = (s+e)/2;
	dfs(id*2, s, mid);
	dfs(id*2+1, mid+1, e);
}

int main() {
	scanf("%d%d", &n, &q);
	for(int i=0;i<n;i++) {
		int s, t, x;
		scanf("%d%d%d", &s, &t, &x);
		l[i] = s-x;
		r[i] = t-x-1;
		v[i] = x;
		
		mp[l[i]-1] = mp[l[i]] = mp[l[i]+1] = mp[r[i]-1] = mp[r[i]] = mp[r[i]+1] = 0;
	}
	
	for(int i=0;i<q;i++) {
		scanf("%d", &a[i]);
		mp[a[i]-1] = mp[a[i]] = mp[a[i]+1] = 0;
	}
	int id=0;
	for(it = mp.begin(); it!=mp.end(); it++) {
		int val = (*it).first;
		mp[val] = id++;
	}
	
	int sz = mp.size();
	for(int i=0;i<sz*8;i++) mi[i] = lim;
	for(int i=0;i<n;i++)
		upd(1, 0, sz, mp[l[i]], mp[r[i]], v[i]);
	dfs(1, 0, sz);
	
	for(int i=0;i<q;i++) {
		int res = ans[mp[a[i]]];
		if(res==lim) puts("-1");
		else printf("%d\n", res);
	}
	
	return 0;
}

Measured memory_bytes: 155264
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String inp = scanner.nextLine();
            String str = inp+inp;
            String key = scanner.nextLine();

            if(str.contains(key)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}



Measured memory_bytes: 26280
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

map<ll, int> zip;
VL unzip;
void compress_coordinate(VL x){
    int n = x.size();
    REP(i,n) unzip.push_back(x[i]);
    sort(ALL(unzip));
    unzip.erase(unique(ALL(unzip)), unzip.end());
    REP(i,unzip.size()) zip[unzip[i]] = i;
}

int main() {
    ll n, l;
    cin >> n >> l;
    vector<PL> p(n);
    VL x;
    REP(i,n){
        p[i].first = lin();
        p[i].second = lin();
        x.push_back(p[i].first);
        x.push_back(p[i].second);
    }
    sort(ALL(p));
    compress_coordinate(x);
    l = zip[l];
    REP(i,n){
        p[i].first = zip[p[i].first];
        p[i].second = zip[p[i].second];
    }
    ll ans1 = 1, d = 0, e = 0;
    REP(i,n){
        if (p[i].first > d){
            d = e;
            if (d < l) ans1++;
        }
        chmax(e, p[i].second);
    }

    VL s(l + 1);
    REP(i,n){
        s[p[i].first]++;
        s[p[i].second]--;
    }
    REP(i,l) s[i + 1] += s[i];
    ll ans2 = 0;
    REP(i,l) chmax(ans2, n - s[i] + 1);

    cout << ans1 << " " << ans2 << endl;
    return 0;
}



Measured memory_bytes: 39116
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n, W;
ll w[100], v[100];

ll dp[101][100001];

int main() {
    cin >> n >> W;
    rep(i,n) cin >> w[i] >> v[i];
    rep(i,n) {
        for (int j = 0; j < w[i]; j++) dp[i+1][j] = dp[i][j];
        for (int j = w[i]; j <= W; j++) {
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
        }
    }
    ll ans = 0;
    rep(i,W+1) ans = max(ans, dp[n][i]);
    cout << ans << endl;
}



Measured memory_bytes: 78336
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = B[A[-1]-1]

for i in range(N-1):
    ans += B[A[i]-1]
    if A[i+1] == A[i] + 1:
        ans += C[A[i]-1]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
    fio();
    int n, m, x;
    cin >> n >> m >> x;
    vii a(n, vi(m));
    vi c(n);
    rep (i, n) {
        cin >> c[i];
        rep (j, m) cin >> a[i][j];
    }

    int ans = inf;
    rep (i, 1 << n) {
        vi b(m);
        int res = 0;
        rep (j, n) {
            if (i & (1 << j)) {
                res += c[j];
                rep (k, m) {
                    b[k] += a[j][k];
                }
            }
        }
        bool flag = true;
        rep (k, m) {
            if (b[k] < x) flag = false;
        }

        if (flag) chmin(ans, res);
    }

    if (ans == inf) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }
}

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

void Main() {
    // input
    u_int32_t X;
    cin >> X;


    // translate
    u_int32_t ans = 0;
    if (X >= 500) {
        ans += 1000 * (X / 500);
        X %= 500;
    }

    if (X >= 5) {
        ans += 5 * (X / 5);
        X %= 5;
    }


    // output
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int A[100000], n;

/* 二分探索 */
int binarySearch(int key) {
    int left = 0;
    int right = n;
    int mid;

    while (left < right) {
        mid = (left + right) / 2;

        if (key == A[mid])      //keyを発見
            return 1;
        if (key > A[mid])       //後半を探索
            left = mid + 1;
        else if (key < A[mid])  //前半を探索
            right = mid;
    }

    return 0;
}


int main() {
    int i, q, key, sum = 0;

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

    cin >> q;
    for (i = 0; i < q; i++) {
        cin >> key;
        if (binarySearch(key))
            sum++;
    }

    cout << sum << endl;
}


Measured memory_bytes: 3476
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll A[200010];
int main()
{
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = K; i < N; i++) {
		if (A[i] > A[i - K]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF (9e18)
#define EPS (1e-6)
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
void INIT(){
	ios::sync_with_stdio(false); cin.tie(0);
}

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
	INIT();
	//code...
	int n,m; cin>>n>>m;
	priority_queue<double> pq;
	while(n--){
		int t; cin>>t;
		pq.emplace(t);
	}
	while(m--){
		pq.emplace(pq.top()/2.0);
		pq.pop();
	}
	ll ans=0;
	while(!pq.empty()){
		ans+=(ll)pq.top();
		pq.pop();
	}
	cout<<ans<<"\n";
	return 0;
}






















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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n, q;
  string s;
  cin >> n >> s >> q;
  vll vq(q);
  rep(i, q) cin >> vq[i];

  vll nc(n + 2);

  rep(i, n) {
    if (s[i] == 'C')
      nc[i]++;
  }

  REP(i, n) {
    nc[i] += nc[i - 1];
  }

  for (const auto k : vq) {
    ll ans = 0;

    vll imos(n + 2);
    vll dc(n + 2);

    rep(i, n) {
      if (s[i] == 'D') {
        dc[i] = nc[min(i + k - 1, n - 1)] - nc[i];
        imos[i]++;
        if (i + k < n) {
          imos[i + k]--;
        }
      }
    }

    REP(i, n) {
      imos[i] += imos[i - 1];
    }

    REP(i, n) {
      dc[i] += dc[i - 1];
      if (s[i] == 'C') {
        dc[i] -= imos[i];
      } else if (s[i] == 'M') {
        ans += dc[i];
      }
    }

    cout << ans << endl;
  }

  return 0;
}


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

int main(){
  ll N; cin >> N;
  vector<pair<ll,ll>> sX(N), X(N+1);
  rep(i, 0, N){
    ll x;
    cin >> x;
    sX[i] = {x, i+1};
  }
  sort(sX.begin(), sX.end());
  
  rep(i, 0, N){
    X[sX[i].second] = {sX[i].first, i+1};
  }
  rep(i, 1, N+1){
    if(X[i].second > N/2){
        cout << sX[N/2-1].first << endl;
    }else{
        cout << sX[N/2].first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 9484
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    vector<int> d(N);
    F0R(i, N) cin >> d[i];
    ll total = 0;
    for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			total += (ll) d[i] * (ll) d[j];
		}
	}
	cout << total << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3668
import Control.Monad
import Data.List

solve :: [String] -> Bool
solve (w1:w2:[]) = (last w1) == (head w2)
solve (w1:w2:ws) = ((last w1) == (head w2)) && solve (w2:ws)

main :: IO ()
main = do
  n <- readLn
  ws <- replicateM n getLine
  let isOk = (==1) . maximum . map length . group $ sort ws
  putStrLn $ if isOk && solve ws then "Yes" else "No"

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

int main(){
    int n,d;
    cin>>n>>d;
    int range = d*2+1;
    int cnt = 0;
    int tmp = 0;
    while(tmp<n){
        tmp += range;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

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

int main(){
  int t,mc=512411,c;
  int N,T; cin>>N>>T;
  for(int i=0;i<N;i++){
    cin>>c>>t;
    if(t<=T){
      mc=min(mc,c);
    }
  }
  if(mc==512411){
    cout<<"TLE"<<endl;
  }else
    cout<<mc<<endl;
}

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

int main() {
  
  string S, T; cin >> S >> T;
  
  for (int i = 0; i < S.size(); i++) {
    S = S.back() + S.substr(0, S.size() - 1);
    if (S == T) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	// 入力
	String c = sca.next();
	char d = c.charAt(0);

	System.out.println((char)(d + 1));

	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 23764
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var moji = Console.ReadLine().Trim();
            if (moji == "0") goto end;
            var result = 0;
            for (int  i = 0; i < moji.Length; i++)
            {
                result += int.Parse(moji[i].ToString());
            }
            Console.WriteLine(result);
            result = 0;
       }
        end:;
    }
}

Measured memory_bytes: 9116
#!/usr/bin/env python3
import sys
import numpy as np
import math

def solve(X: int):
    p = 100
    n = 1
    while(True):
        p = math.floor(p*1.01)
        if p>=X:
            print(n)
            return
        n+=1
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27132
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Main {

    private int n;
    private int m;
    private List<Long> primeFactors;
    private final long d = 1000000007;
    
    public static void main(String[] args) {
	Main f = new Main();
	System.out.println(f.solve());
    }

    private Main() {
	set();
    }

    private void set() {
	n = m = 0;
	try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
	    int[] nm = Arrays.stream(br.readLine().trim().split("[\\s]+")).mapToInt(Integer::parseInt).toArray();
	    n = nm[0];
	    m = nm[1];
	} catch(IOException e) {
	    e.printStackTrace();
	}
	primeFactors = new ArrayList<>();
	int num = m;
	for (long i=2;i<=num;i++) {
	    long count = 0;
	    while (num%i == 0) {
		count++;
		num /= i;
	    }
	    if (count > 0) primeFactors.add(count);
	    if (num == 1) break;
	}
    }

    private long solve() {
	long ans = 1;
	for (long v : primeFactors) {
	    ans = (ans*h(n,v))%d;
	}
	return ans%d;
    }

    private long h(long a,long b) {
	long p = a+b-1;
	long q = p-b < b ? p-b : b;
	long u = 1;
	long l = 1;
	for (long i=1;i<=q;i++) {
	    u *= p-i+1;
	    u %= d;
	    l *= i;
	    l %= d;
	}
	return (u*pinv(l,d-2))%d;
    }

    private long pinv(long l,long p) {
	if (p == 0) return 1;
	if (p%2 == 0) {
	    long h = pinv(l,p/2)%d;
	    return (h*h)%d;
	} else {
	    return (l*pinv(l,p-1))%d;
	}
    }
}

Measured memory_bytes: 28628
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T>> &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int N, L;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> N >> L;
  int total = N * (2 * L + (N - 1)) / 2;
  int ans = total, diff = INF;
  rep(i, L, L+N) {
    if (abs(diff) > i) {
      diff = i;
      ans = total - i;
    }
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 256
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

H, W = map(int, read().split())

print('GREATER' if H>W else 'LESS' if H<W else 'EQUAL')


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

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


  vector<int> ans(n);

  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    ans[x-1] = i+1;
  }

  for (int i = 0; i < ans.size(); i++) {
    if (i == 0) {
      cout << ans[i];
    } else {
      cout << " " << ans[i];
    }
  }
  cout << endl;


}

Measured memory_bytes: 1280
import sys
from collections import deque
input = sys.stdin.readline
N = int(input())
X = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    X[a-1].append((i, b-1))

Q = deque([(0, -1)])
ANS = [-1] * (N-1)
cmax = 0
while Q:
    x, c0 = Q.pop()
    c = 1
    for i, y in X[x]:
        if c == c0: c += 1
        ANS[i] = c
        Q.appendleft((y, c))
        c += 1
    cmax = max(cmax, c-1)

print(cmax)
for ans in ANS:
    print(ans)

Measured memory_bytes: 28200
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int ans[510][510];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int K=gi(),n=2;if(K==1)puts("1\n1\n"),exit(0);
	while(K>n*2)n+=2;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)ans[j][(i+j-1)%n+1]=i;
	for(int i=n+1;i<=K;++i)
		for(int j=1;j<=n;++j)
			if(j&1)ans[j][(i+j-1)%n+1]=i;
	printf("%d\n",n);
	for(int i=1;i<=n;++i,puts(""))for(int j=1;j<=n;++j)printf("%d ",ans[i][j]);
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main(){
  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];
    }
  }
  bool boolh[h],boolw[w];
  for (int i=0;i<h;i++){
    boolh[i]=false;
    for (int j=0;j<w;j++){
    	if(a[i][j]=='#')boolh[i]=true;
    }
  }
  for (int j=0;j<w;j++){
    boolw[j]=false;
    for (int i=0;i<h;i++){
    	if(a[i][j]=='#')boolw[j]=true;
    }
  }
  for (int i=0;i<h;i++){
    for (int j=0;j<w;j++){
    	if(boolh[i] && boolw[j])cout <<a[i][j];
    }
    if (boolh[i])cout <<endl;
  }
}

Measured memory_bytes: 256
from math import sqrt

def f(a, b):
    return max(len(str(a)), len(str(b)))


def main():
    n = int(input())
    min_f = 10
    for a in range(1, int(sqrt(n))+1):
        if n % a == 0:
            b = n // a
            min_f = min(min_f, f(a, b))
    print(min_f)


if __name__ == "__main__":
    main()



Measured memory_bytes: 39024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll a,b; cin >> a >> b;
    cout << (int)((a+b)/2.0 + 0.5) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
  int a = 0;
  cin >> a;
  int b = 0;
  b = a / 100;
  int c = 0;
  if(a <= b * 105 && a >= b * 100){
    c = 1;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn
import scala.math


object Main extends App {
  val n::d::_ = StdIn.readLine().split(' ').map(_.toInt).toList

  def norm(x:(Int,Int)):Double = math.sqrt(math.pow(x._1,2)+math.pow(x._2,2))

  val points = for(i <- 1 to n)yield{
    val x::y::_ = StdIn.readLine().split(' ').map(_.toInt).toList
    (x,y)
  }

  val out = points.map(norm).count(_ <= d)

  println(out)




}








Measured memory_bytes: 69376
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())


N,M,R = inpl()
rr = inpl()

weight = [[INF for i in range(N)] for j in range(R)]
for r in range(R):
	weight[r][rr[r]-1] = 0

lines = defaultdict(set)
for i in range(M):
	a,b,c = inpl()
	a -= 1
	b -= 1
	lines[a].add((b,c))
	lines[b].add((a,c))

def search (s,w_0,r):
	global weight
	global q
	for line in list(lines[s]):
		t = line[0]
		w = w_0 + line[1]
		if weight[r][t] > w:
			heapq.heappush(q, [w,t])
			weight[r][t] = w

for r in range(R):
	q = [ [0, rr[r]-1] ]
	heapq.heapify(q)
	while q:
		w_0,s = heapq.heappop(q)
		search(s,w_0,r)

ans = INF
for li in list(itertools.permutations(range(R))):
	tmp = 0
	for i in range(R-1):
		s = li[i]
		t = li[i+1]
		tmp += weight[s][rr[t]-1]
	ans = min(ans,tmp)

print(ans)

Measured memory_bytes: 14108
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;
 
int main()
{
    IOS();
    ll n,m,i,j,w=0;
    cin>>n>>m;
    multiset<ll,greater<ll>> s;
    f(i,0,n)
    {
      ll x;
      cin>>x;
      s.insert(x);
    }
    while(m--)
    {
      ll z=*s.begin();
      s.erase(s.begin());
      s.insert(z/2);

    }
    for(auto u : s)
      w+=u;
    cout<<w;


   return 0;

}

Measured memory_bytes: 4992