akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ll n, m;
	cin >> n >> m;
	ll sum = 0;
	M00(i, m) {
		ll x;
		cin >> x;
		sum += x;
	}
	if(sum > n) {
		finish(-1);
	} else {
		finish(n - sum);
	}
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int ild[12][12];

void erase_island(int i, int j, int (&ild)[12][12])
{
	ild[i][j] = -1;
	
	if(i - 1 >= 0){
		if(ild[i - 1][j] == 1)
			erase_island(i - 1, j, ild);
	}
	if(i + 1 < 12){
		if(ild[i + 1][j] == 1)
			erase_island(i + 1, j, ild);
	}
	if(j - 1 >= 0){
		if(ild[i][j - 1] == 1)
			erase_island(i, j - 1, ild);
	}
	if(j + 1 < 12){
		if(ild[i][j + 1] == 1)
			erase_island(i, j + 1, ild);
	}
}

int main()
{
	string str;
	int cont = 0;
	int i, j;
	
	while(1)
	{
		for(i = 0; i < 12; i++){
			cin >> str;
			
			for(j = 0; j < 12; j++)
				ild[i][j] = (str[j] == '1')? 1: 0;
		}
		
		if(cin.eof()) break;
		
		for(i = 0; i < 12; i++){
			for(j = 0; j < 12; j++){
				if(ild[i][j] == 1){
					cont++;
					erase_island(i, j, ild);
				}
				else if(ild[i][j] == 0)
					ild[i][j] == -1;
			}
		}
		
		cout << cont << endl;
		
		cont = 0;
	}
	
	return 0;
}

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

long long indB, ans;
string s;

int main() {
	cin >> s;
	for(char ele: s){
      if(ele == 'B')
        indB++;
      else if(ele == 'W')
        ans += indB;
    }
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int main()
{
	int L,R,d;
	scanf("%d %d %d",&L,&R,&d);
	int count=0;
	for(int i=L;i<=R;i++){
		if(i%d==0){
			count++;
			continue;
		}
	}
	printf("%d\n",count);
}


Measured memory_bytes: 1704
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define mii map<int,int>
#define MOD 1000000007
using namespace std;
typedef long long ll;
map<int,int> m;
void sieve(vector<int> a)
{
	int n=a.size();
	int maxx=*max_element(all(a));
	for(int i=0;i<n;i++)
	{
		if(m[a[i]]==0)
		{
			for(int j=a[i]*2;j<=maxx;j+=a[i])
			{
				m[j]=1;
			}
		}
	}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
vector<int> a(n);
map<int,int> c;
for(int i=0;i<n;i++)
{
	cin>>a[i];
	c[a[i]]++;
}
sort(all(a));
sieve(a);
int ans=0;

for(int i=0;i<n;i++)
{
	if(m[a[i]]==0 && c[a[i]]==1)
	{
		ans++;
	}
}
cout<<ans<<endl;
return 0;
}
// Problem : D - Not Divisible
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



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

int n;
vector<string> s;

int solve();

int main(){
  cin >> n;
  s.resize(n);
  for(int i = 0;i < n;++i)
    cin >> s[i];
  cout << solve() << endl;
  return 0;
}

int solve(){
  int ans = 0;
  for(int a = 0;a < n;++a){
    bool ch = 1;
    for(int i = 0;i < n;++i)
      for(int j = 0;j < n;++j)
        if(s[(a+i)%n][j] != s[(a+j)%n][i])
          ch = 0;
    ans += ch;
  }
  return ans * n;
}

Measured memory_bytes: 384
object Main {

  import scala.collection.mutable.ArrayBuffer

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, Q = sc.nextInt()
    val G = Array.fill(N+1)(ArrayBuffer[Int]())
    (0 until N - 1) foreach { _ =>
      val a, b = sc.nextInt()
      G(a).append(b)
      G(b).append(a)
    }
    val PtoX = new Array[Long](N+1)
    (0 until Q). foreach { _ =>
      val p, x = sc.nextInt()
      PtoX(p) += x
    }

    val Counter = new Array[Long](N+1)
    val visited = new Array[Boolean](N+1)

    val stack = new scala.collection.mutable.Stack[Int]
    stack.push(1)
    while (stack.nonEmpty) {
      val u = stack.pop()
      visited(u) = true
      val thisCount = PtoX(u)
      Counter(u) += thisCount
      G(u).foreach { v =>
        if (!visited(v)) {
          stack.push(v)
          Counter(v) += Counter(u)
        }
      }
    }

    println(Counter.tail.mkString(" "))
  }

}


Measured memory_bytes: 155916
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=tf-8
#

"""
"""

from collections import defaultdict
import bisect

import sys
input = sys.stdin.readline

modulo = (10**9)+7

def solve(n):
    pow9 = 1
    pow8 = 1
    pow7 = 1
    for _ in range(n):
        pow9 = pow9*10%modulo
        pow8 = pow8*9%modulo
        pow7 = pow7*8%modulo
    print((pow9-2*pow8+pow7)%modulo)
            

def main():
    n = int(input())
    solve(n)


if __name__ == "__main__":
    main()

Measured memory_bytes: 67940
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        h1: i32,
        w1: i32,
    }
    input!{
        h2: i32,
        w2: i32,
    }
    println!("{}", h1 * w1 - h2 * w1 - h1 * w2 + h2 * w2)
}


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

int main(){
	int a,b,c,d,e,k;cin >> a >> b >> c >> d >> e >> k;
  	int mi,ma;
  	mi=min(a,min(b,min(c,min(d,e))));
  	ma=max(a,max(b,max(c,max(d,e))));
  	cout << (k>=ma-mi?"Yay!":":(");
  	return 0;
}


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

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

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

    string s;
    cin>>s;

    int cnt = 0;
    for (int i=1;i<(int)s.size();++i){
        if (s[i] == s[i-1]){
            cnt++;
            if (s[i] == '0') s[i] = '1';
            else s[i] = '0';
        }
    }
    cout<<cnt<<endl;

    return 0;
}

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

public class Main {
	Scanner sc = new Scanner(System.in);
	Person [][] personArray = new Person[3][8];
	Person [] nextwinner = new Person[18];
	int k = 0;
	public void doIt(){
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 8; j++){
				personArray[i][j] = new Person(sc.nextInt(),sc.next());
			}
		}
		for(int i = 0; i < 3; i++){
			Arrays.sort(personArray[i]);
		}
		for(int i = 0; i < 3; i++){
			for(int j = 2; j < 8; j++){
				nextwinner[k++] = new Person(personArray[i][j].number,personArray[i][j].time);
			}
		}
		Arrays.sort(nextwinner);
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 2; j++){
				System.out.println(personArray[i][j].number + " " + personArray[i][j].time);
			}
		}
		for(int i = 0; i < 2; i++){
			System.out.println(nextwinner[i].number + " " + nextwinner[i].time);
		}
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
	class Person implements Comparable<Person> { 
		int number;
		String time;
		Person(int number, String time){
			this.number = number;
			this.time = time;
		}
		public String tostring(){
			return "[" + number + "," + time + "]";
		}
		public int compareTo(Person p){
			return time.compareTo(p.time);
		}
	}
}

Measured memory_bytes: 26180
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))


N = int(input())
S, T = list(map(str, input().split()))


ans = []
for i in range(N):
    ans.append(S[i])
    ans.append(T[i])

print("".join(ans))

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

template<class T>
struct node{
  T val;
  node<T> *left,*right;
  node():left(nullptr),right(nullptr){}
  node(T v):val(v),left(nullptr),right(nullptr){}
};

template<class T>
struct tree{
  node<T>* root;
  size_t sz;
  tree():sz(0),root(nullptr){}
  void insert(T v){
    sz++;
    if(sz==1){
      root = new node<T>(v);
      return;
    }
    auto tmp = root;
    auto add = new node<T>(v);
    while(1){
      if(tmp->val == add->val){
        return;
      }
      else if(tmp->val < add->val){
        if(tmp->right)tmp = tmp->right;
        else {
          tmp->right = add;
          return;
        }
      }
      else{
        if(tmp->left)tmp = tmp->left;
        else{
          tmp->left = add;
          return;
        }
      }
    }
  }
  bool find(T v){
    auto tmp = root;
    while(tmp!=nullptr){
      if(tmp->val == v){
        return true;
      }
      else if(tmp->val < v){
        tmp = tmp->right;
      }
      else{
        tmp = tmp->left;
      }
    }
    return false;
  }
};

void solve(){
  //https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/4/ALDS1_4_B
  int n;cin>>n;
  tree<int> t;
  while(n--){
    int x;cin>>x;
    t.insert(x);
  }
  int q;cin>>q;
  int ans = 0;
  while(q--){
    int x;cin>>x;
    ans += t.find(x);
  }
  cout<<(ans)<<endl;
}

signed main(){
  solve();
}


Measured memory_bytes: 3320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int a; cin >> a;
    if (a >= 1200) out("ARC");
    else out("ABC");
}



Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
class MainClass
{
    static long N, A, B, C, D;
    static Dictionary<long, long> Dic = new Dictionary<long, long>();
    static void Main()
    {
        var T = int.Parse(Console.ReadLine());
        for (int i = 0; i < T; i++)
        {
            var r = Console.ReadLine().Split().Select(long.Parse).ToArray();
            N = r[0]; A = r[1]; B = r[2]; C = r[3]; D = r[4];
            Dic = new Dictionary<long, long>();
            Dic[N] = 0;
            d = (long)Log10(D);
            DFS(N, 0);
            Console.WriteLine(Dic[1] + D);
        }
    }

    static void DFS(long n, long m)
    {
        Dic[n] = m;
        if (n <= 1) return;

        long p = n % 2;
        if (Point(n / 2) > m + A + D * p)
            DFS(n / 2, Min(m + A + D * p, m + f(n - n / 2, D)));
        if (p > 0)
        {
            long min = Min(m + A + D * (2 - p), m + f(n - n / 2 - 1, D));
            if (Point(n / 2 + 1) > min)
                DFS(n / 2 + 1, min);
        }

        p = n % 3;
        if(n>=3)
        if (Point(n / 3) > m + B + D * p)
            DFS(n / 3, Min(m + B + D * p, m + f(n - n / 3, D)));
        if (p > 0)
        {
            long min = Min(m + B + D * (3 - p), m + f(n - n / 3 - 1, D));
            if (Point(n / 3 + 1) > min)
                DFS(n / 3 + 1, min);
        }


        if (n < 5) return;
        p = n % 5;
        if (Point(n / 5) > m + C + D * p)
            DFS(n / 5, Min(m + C + D * p, m + f(n - n / 5, D)));
        if (p > 0)
        {
            long min = Min(m + C + D * (5 - p), m + f(n - n / 5 - 1, D));
            if ( Point(n / 5 + 1) > min)
                DFS(n / 5 + 1, min);
        }

    }
    static long Point(long num)
    {
        if (!Dic.ContainsKey(num)) Dic[num] = long.MaxValue / 2;
        return Dic[num];
    }
    static long d;
    static long f(long a, long b)
    {
        if (Log10(a) + d + 2 >= 19)
        {
            return long.MaxValue / 2;
        }
        return a * b;
    }
}


Measured memory_bytes: 32912
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    char a;
    cin >> a;
    if(a == 'A') cout << 'T' << endl;
    else if(a == 'T') cout << 'A' << endl;
    else if(a == 'G') cout << 'C' << endl;
    else if(a == 'C') cout << 'G' << endl;
}

Measured memory_bytes: 3588
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    a, b = map(int, readline().split())

    ans = 0
    for i in range(1, 13):
        if i < a:
            ans += 1
        elif i == a and i <= b:
            ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
int main(){
  long int n,a=2,b=1;cin>>n;
  if(n==1)cout<<1<<endl;
  else{
    for(int i=1;i<n;i++){
      long int c=a+b;
      a=b;
      b=c;
    }
    cout<<b<<endl;
  }
}
  
  


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    if (abs(a - b) % 2 == 0)
        printf("Alice\n");
    else
        printf("Borys\n");
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int[] a = new int[n];
		StringTokenizer st = new StringTokenizer(reader.readLine());
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(st.nextToken());
		}
		int q = Integer.parseInt(reader.readLine());
		st = new StringTokenizer(reader.readLine());
		for (int i = 0; i < q; i++) {
			if (subsetSum(n, Integer.parseInt(st.nextToken()), a)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
		reader.close();
	}

	private boolean subsetSum(int n, int s, int[] a) {
		int[][] dp = new int[n+1][s+1];
		for (int i = 0; i < n; i++) {
			int v = a[i];
			for (int j = 0; j <= s; j++) {
				if (v == j || (v < j && dp[i][j-v] > 0)) {
					dp[i+1][j] = dp[i][j] + 1;
				} else  {
					dp[i+1][j] = dp[i][j];
				}
			}
		}
		return dp[n][s] > 0;
	}
}


Measured memory_bytes: 41576
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cstdlib>

using namespace std;

typedef long long ll;
ll A, B, C, K;

int main() {
    cin >> A >> B >> C >> K;
    if (K&1) cout << B-A << endl;
    else cout << A-B << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.array, std.range, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    string[] a = new string[n];
    foreach (i; 0 .. n) {
        string[] tmp = readln.split;
        string s = tmp[0];
        int p = 100 - tmp[1].to!int;
        string t = rightJustify(p.to!string, 3, '0');
        a[i] = s ~ t;
    }
    int[] b = iota(1, n+1).array;
    zip(a, b).sort!((t1, t2) => t1[0] < t2[0]);
    foreach (x; b) {
        x.writeln;
    }
}

Measured memory_bytes: 256
s=int(input())
if s<=10**9:
  print(0,0,s,0,0,1)
elif s==10**18:
  print(0,0,10**9,0,0,10**9)
else:
  x1,y1=0,0
  x2=s//(10**9)+1
  y3=10**9
  y2=10**9-(s%(10**9))
  x3=1
  print(x1,y1,x2,y2,x3,y3)


Measured memory_bytes: 3060
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int price,n[4]={};
  n[0]=-1;
  int i,j;

  while(1){
    cin>>price;
    if(price==0)break;
    if(n[0]>=0)cout<<endl;
    cin>>n[0]>>n[1]>>n[2]>>n[3];
    int n0=0,n1=0,n2=0,n3=0;
    int sum=n[0]*10+n[1]*50+n[2]*100+n[3]*500;
    sum-=price;
    while(sum>=500){
      n3++;
      sum-=500;
    }
    while(sum>=100){
      n2++;
      sum-=100;
    }
    while(sum>=50){
      n1++;
      sum-=50;
    }
    while(sum){
      n0++;
      sum-=10;
    }

    if(n[0]-n0>0)printf("10 %d\n",n[0]-n0);
    if(n[1]-n1>0)printf("50 %d\n",n[1]-n1);
    if(n[2]-n2>0)printf("100 %d\n",n[2]-n2);
    if(n[3]-n3>0)printf("500 %d\n",n[3]-n3);
  }
}

Measured memory_bytes: 3204
s = input()

for i in range(2 ** (len(s) - 1)):
    fml = ''
    for j in range(len(s) - 1):
        fml += s[j]
        fml += '+-'[int('{:0>10b}'.format(i)[::-1][j]) & 1]
    fml += s[-1]

    if eval(fml) == 7:
        fml += '=7'
        break
        
print(fml)

Measured memory_bytes: 3060
MOD = 10**9+7
n = int(input())
a = list(map(int, input().split()))

def make_inv(n, mod=10**9+7):
    inv = [0, 1] + [0] * (n-2)
    for i in range(2, n):
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
    return inv

def get_primes(lim):
    table = [True] * (lim+1)
    table[0:2] = False, False
    for i in range(2, int(lim**0.5)+1):
        if not table[i]: continue
        for j in range(i*2, lim+1, i):
            table[j] = False
    return [i for i in range(lim+1) if table[i]]

def factorize(x, primes):
    res = []
    for p in primes:
        if p ** 2 > x: break
        cnt = 0
        while not x % p:
            x //= p
            cnt += 1
        if cnt: res.append((p, cnt))
    if x > 1: res.append((x, 1))
    return res

inv = make_inv(10**6+1)
table = [0] * (10**6+1)
primes = get_primes(10**4)

for x in a:
    for i, num in factorize(x, primes):
        table[i] = max(table[i], num)

lcm = 1
for x, num in enumerate(table):
    if not num: continue 
    lcm *= pow(x, num, MOD)
    lcm %= MOD

ans = 0
for x in a:
    ans += lcm * inv[x]
    ans %= MOD

print(ans)


Measured memory_bytes: 51020
#include <stdio.h>
int selection(int A[],int N){
	int i,j,t,sw=0,minj;
	for(i=0;i<N-1;i++){
		minj = i;
		for(j=i;j<N;j++){
			if(A[j]<A[minj]){
			minj = j;
			}
		}
		t=A[i];A[i]=A[minj];A[minj]=t;
		if(i!=minj)sw++;
	}
	return sw;
}

int main(void){
	int A[100],N,i,sw;
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%d",&A[i]);
	
	sw = selection(A,N);
	
	for(i=0;i<N;i++){
		if(i>0)printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",sw);
	
	return 0;
}


Measured memory_bytes: 2104
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll INF = 1e+18;
const ld EPS = 1e-12L;
const ld PI = acos(-1.L);
inline ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
inline ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion


ll n, m;
const int MAX = 300;
ll a[MAX][MAX];

// minimum x (C(x) == true)
ll solve() {
  vll p(n, 0);
  set<ll> st;
  ll ans = INF;
  rep(i, m){
    vll cnt(m+1, 0);
    rep(j, n){
      cnt[a[j][p[j]]]++;
    }
    ll ma = 0;
    ll mai = 0;
    rep(j, m+1){
      if(chmax(ma, cnt[j])){
        mai = j;
      }
    }
    chmin(ans, ma);
    st.emplace(mai);
    rep(j, n){
      while(st.count(a[j][p[j]])){
        p[j]++;
      }
    }
  }
  return ans;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  cin >> n >> m;
  rep(i, n)rep(j, m) cin >> a[i][j];
  print(solve());
}


Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var x, y, ans string
	fmt.Scan(&x, &y)
	if x == y {
		ans = "="
	} else if byte(x[0]) < byte(y[0]) {
		ans = "<"
	} else {
		ans = ">"
	}
	fmt.Println(string(ans))
}


Measured memory_bytes: 512
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l,n,x,ans=0;
    cin>>n;
    vector<pair<string,ll>>v(n);
    string s,target;
    while(n--){
    cin>>s>>x;
    v.push_back(make_pair(s,x));
    }
    cin>>target;
    bool ok=0;
    for(i=0;i<v.size();i++)
    {
        if(ok) ans+=v[i].second;
        if(target==v[i].first){
            ok=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}





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

using namespace std;

int main() {
    int N, K, S;
    cin >> N >> K >> S;

    for (int i = 0; i < K; i++) {
        cout << S << " ";
    }

    int t = S + 1;
    if (S == 1e9) t = 1;
    for (int i = K; i < N; i++) {
        cout << t << " ";
    }
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
 
int main() {
	char now;
	string s;
	int cnt = 0;
	cin >> s;
	now = s[0];
	for(int i = 1;i < s.length();i++){
		if(now != s[i]) {
			now = s[i];
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

int h, w;
bool island[51][51];

bool func(int y, int x){
	if(!island[y][x]) return false;
	island[y][x] = false;

	for(int i = -1; i <= 1; ++i){
		for(int j = -1; j <= 1; ++j){
			if(i == 0 && j == 0) continue;
			if(y + i < 0 || y + i >= h || x + j < 0 || x + j >= w) continue;
			if(!island[y + i][x + j]) continue;
			func(y + i, x + j);
		}
	}

	return true;
}

int main(){
	while(std::cin >> w >> h, h + w){
		for(int i = 0; i < h; ++i)
			for(int j = 0; j < w; ++j){
				std::cin >> island[i][j];
			}

		int cnt = 0;
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				cnt += func(i, j);
			}
		}

		std::cout << cnt << std::endl;
	}

	return 0;
}

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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L=A+B;
  R=C+D;
  if(L>R){
    cout << "Left" << endl;
  }
  else if (L<R){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, floor
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
A = LIST()
a = 0
ans = INF

for i in range(-100, 101):
    a = 0
    for j in range(n):
        a += (A[j]-i) ** 2

    ans = min(ans, a)
print(ans)

    





exit()
ave = sum(L)/n
if ave == int(ave):
    print(int(ave))
    a = ave
    for i in range(n):
        ans += (L[i] - a) ** 2
    print(int(ans))
    exit()
left = 0
if ave != int(ave):
    for i in range(n):
        if L[i] < ave:
            left = i + 1
    print(left)
    right = n - left
    if left < right:
        a = ceil(ave)
    else:
        #print(floor(ave))
        a = floor(ave)
    print(a)
    for i in range(n):
        ans += abs(L[i] - a) ** 2
    print(ans)


Measured memory_bytes: 5260
a = list()
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
sum = 0
min = 10
for i in range(0, 5):
	if a[i] % 10 == 0:
		a[i] = a[i] - 10
	else:
		if a[i] % 10 < min:
			min = a[i] % 10
	a[i] = a[i] - a[i] % 10
	sum = sum + a[i]
sum = sum + min + 40
print(sum)


Measured memory_bytes: 3064
n = gets.chomp.to_i
count = 0
(1..n).each do |i|
  a = 0;
  if i % 2 != 0
  (1..n).each do |k|
    if i  %  k == 0
      a += 1
    end
  end
end
  count += 1 if a == 8
end
puts count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  string S, T;
  cin >> S >> T;
  vector<char> StoT(26, '.'), TtoS(26, '.');
  bool can = true;
  for (int i = 0; i < S.size(); i++) {
    if (StoT[S[i]-'a'] == '.') StoT[S[i]-'a'] = T[i];
    else {
      if (StoT[S[i]-'a'] != T[i]) {
        can = false;
        break;
      }
    }
    if (TtoS[T[i]-'a'] == '.') TtoS[T[i]-'a'] = S[i];
    else {
      if (TtoS[T[i]-'a'] != S[i]) {
        can = false;
        break;
      }
    }
  }
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 1e5+5;
ll dp[100][M];
pair<ll,ll> a[100];
ll n,w;
ll solve(ll current_weight,int i){
	if(i >= n)return 0;
	if(current_weight + a[i].first > w){
		return solve(current_weight,i+1);
	}
	if(dp[i][current_weight] != -1)return dp[i][current_weight];
	
	return dp[i][current_weight] = max(solve(current_weight,i+1),solve(current_weight+a[i].first,i+1)+a[i].second);
}
int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n>>w;
	for(int j=0;j<n;j++){
		cin>>a[j].first>>a[j].second;
	}
	cout << solve(0,0) << '\n';
	return 0;
}

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

int MOD = 1000000007;

int64_t solve(int a, int b) {
    int n = min(a, b);
    int64_t ans = 1;
    rep(i,n) {
        ans *= (i+1);
        ans %= MOD;
        ans *= (i+1);
        ans %= MOD;
    }
    if (a == b) ans *= 2;
    else ans *= max(a, b);
    ans %= MOD;
    return ans;
}

int main() {
    int n, m;
    cin >> n >> m;
    int ans;
    if (abs(n - m) > 1) ans = 0;
    else ans = solve(n, m);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    
    if(a==b){
        cout<<a*2<<endl;
    }else{
        cout<<max(a,b)+max(a,b)-1<<endl;
    }
    
 return 0;   
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
#define inf 2147483647
#define B 200
using namespace std;


int find(int x, int y, vector<int> &a, vector<int> &b){
    int ans = inf;
    int i = x;
    y++;
    while(i < y){
        if(i % B == 0 && i + B <= y){
            ans = min(ans, b[i / B]);
            i += B;
        }else{
            ans = min(ans, a[i]);
            i++;
        }
    }
    return ans;
}

void update(int n, int x, int y, vector<int> &a, vector<int> &b){
    a[x] = y;
    b[x / B] = inf;
    for(int i = x - x % B; i < min(x - x % B + B, n); i++){
        b[x / B] = min(b[x / B], a[i]);
    }
}

int main(){
    int n, q;
    while(cin >> n >> q){
        vector<int> a(n,inf), b(n / B + 1,inf);
        rep(i,q){
            int com, x, y;
            cin >> com >> x >> y;
            if(com) cout << find(x,y,a,b) << endl;
            else update(n,x,y,a,b);
        }
    }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
int n;
double t, x;
double a[1003];
int ans;

int main() {
	cin >> n >> t >> x;
	for(int i = 1; i <= n; i++) cin >> a[i];
	double minT = Inf;
	for(int i = 1; i <= n; i++) {
		double tmp = t - a[i] * 0.006;
		double tt = fabs(x - tmp);
		if(tt < minT) {
			minT = tt;
			ans = i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
// 2分ヒープ
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_H 250
const int INV = -2147483645;

int main(void)
{
    int H, parent, left, right;
    int ary_BinaryHeap[MAX_H + 1];

    for(int i = 0; i < MAX_H; i++)
    {
        // 配列の初期化
        ary_BinaryHeap[i] = INV;
    }

    cin >> H;

    for(int i = 1; i <= H; i++)
    {
        // ノードの値を格納
        cin >> ary_BinaryHeap[i];
    }

    // 結果を表示
    for(int i = 1; i <= H; i++)
    {
        cout << "node " << i << ": ";
        cout << "key = " << ary_BinaryHeap[i] << ", ";

        parent = i / 2;         // 親のNo.
        left = 2 * i;           // 左のNo.
        right = ( 2 * i ) + 1;  // 右のNo.

        if( parent > 0 )
        {
            cout << "parent key = " << ary_BinaryHeap[parent] << ", ";
        }

        if( left <= H
            && ary_BinaryHeap[left] != INV )
        {
            cout << "left key = " << ary_BinaryHeap[left] << ", ";
        }

        if( right <= H
            && ary_BinaryHeap[right] != INV )
        {
            cout << "right key = " << ary_BinaryHeap[right] << ", ";
        }

        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    int L,R,d;
    int count=0;
    cin >> L >> R >> d;
    for(int i=L;i<=R;i++){
        if(i%d==0){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  char op[7 + 1];
  int stack[100];
  int in = 0;
  int len = 0;
  int tmp1, tmp2;

  while ((op[len] = getchar()) != EOF) {
    if (op[len] == ' ' || op[len] == '\n') {
      op[len] = '\0';
      if (atoi(op) != 0) {
	stack[in++] = atoi(op);
	len = 0;
      } else {
	switch (op[0]) {
	case '0':
	  stack[in++] = atoi(op);
	  break;

	case '+':
	  tmp1 = stack[--in];
	  tmp2 = stack[--in];
	  stack[in++] = tmp2 + tmp1;
	  break;
	  
	case '-':
	  tmp1 = stack[--in];
	  tmp2 = stack[--in];
	  stack[in++] = tmp2 - tmp1;
	  break;

	case '*':
	  tmp1 = stack[--in];
	  tmp2 = stack[--in];
	  stack[in++] = tmp2 * tmp1;
	  break;

	default:
	  break;
	}
	len = 0;
      }
    } else len++;
  }

  printf("%d\n", stack[0]);

  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,x,ans = 0;
    cin >> n >> x;
    int l,d[n];
    d[0] = 0;
    nfor(i, 1, n + 1){
        cin >> l;
        d[i] = d[i - 1] + l;
    }
    rep(i, n + 1){
        if (d[i] <= x) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int w,a,b;
    cin>>w>>a>>b;
    if(a>b)swap(a,b);
    if(a+w>=b)cout<<0<<endl;
    else cout<<b-(a+w)<<endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int time = 0;
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String song = sc.next();
            time += sc.nextInt();
            map.put(song, time);
        }
        System.out.println(time - map.get(sc.next()));
    }
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  vector<int> a(3); rep(i,3) cin >> a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  int ans = a[0]*10+a[1]+a[2];
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3628
import Control.Applicative
import Control.Monad
import Data.List
import Data.Maybe

tuple a b = (a, b)
apply2 f [a, b] = f a b

main = map read . words <$> getLine >>= \[n, t] -> map (apply2 tuple . map read . words) <$> replicateM n getLine >>= putStrLn . fromMaybe "TLE" . fmap show . listToMaybe . sort . map fst . filter ((<=t) . snd)

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

ll ans, n, l, i;

void upd(ll x, ll y) {
  if ((i = __gcd(x,y) > 1 ? 0 : atcoder::inv_mod(x,y)) > 0)
    ans = min({ans, i * x - 1, (y-i) * x});
}

int main() {
  cin >> n; ans = n + (n % 2 == 0);
  for (ll d = 1; d * d <= n; d++)
    if (n % d == 0)
      upd(2 * d, n / d), upd(2 * n / d, d);
  cout << ans << "\n";
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    double a,b,h,m,ahx,ahy,bmx,bmy,ans,pi;
    cout << fixed << setprecision(12);
    pi=3.141592653589;
    cin>>a>>b>>h>>m;
    ahx=a*cos((h+m/60)*pi/6);
    ahy=a*sin((h+m/60)*pi/6);
    bmx=b*cos(2*m*pi/60);
    bmy=b*sin(2*m*pi/60);
    ans=(ahx-bmx)*(ahx-bmx)+(ahy-bmy)*(ahy-bmy);
    cout<<sqrt(ans)<<endl;
}
   
    

   



Measured memory_bytes: 4104
def solve():
    def dfs(ring, chain_len=1):
        unchecked[ring] = False
        unvisited[ring] = False
        len_rec[ring] = max(len_rec[ring], chain_len)
        for r in adj_list[ring]:
            if unvisited[r]:
                dfs(r, chain_len + 1)
        unvisited[ring] = True
    
    import sys
    file_input = sys.stdin
    
    while True:
        n = int(file_input.readline())
        if n == 0:
            break
        
        rings = []
        adj_list = [[] for _ in range(101)]
        for _ in range(n):
            a, b = map(int, file_input.readline().split())
            adj_list[a].append(b)
            adj_list[b].append(a)
            rings.extend([a, b])
        rings = set(rings)
        
        len_rec = [1] * 101
        unchecked = [True] * 101
        unvisited = [True] * 101
        
        for r in rings:
            if unchecked[r]:
                dfs(r)
        dfs(len_rec.index(max(len_rec)))
        
        print(max(len_rec))

solve()


Measured memory_bytes: 5644
fun main(args: Array<String>) {
    arc091d()
}

fun arc091d() {
    val (n, k) = readLine()!!.split(' ').map { it.toLong() }

    if (k==0L) return println(n*n)
    
    var answer = 0L

    for (b in k + 1..n) {
        answer += (n / b) * (b - k) + max((n % b) - (k - 1), 0)
    }

    println(answer)
}

private fun max(a: Long, b: Long) = Math.max(a, b)


Measured memory_bytes: 38296
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 1e5+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 998244353;

ll a[maxN];
ll b[maxN],c[maxN];
int main()
{
	int n;
	scanf("%d",&n);
	unordered_map<int,int> mp;
	ll sum = 0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		mp[a[i]]++;
		sum += a[i];
	}
	int Q;
	scanf("%d",&Q);
	for(int i=1;i<=Q;i++)
	{
		//scanf("%lld%lld",&b[i],&c[i]);
		ll x,y;
		scanf("%lld%lld",&x,&y);
		int cnt = mp[x];
		sum -= cnt * x;
		sum += cnt * y;
		mp[x] = 0;
		mp[y] += cnt;
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 8176
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    cout << ((v - w)* t - (max(a,b) - min(a,b)) >= 0 ? "YES" : "NO")  << endl;
}

Measured memory_bytes: 3640
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

main :: IO ()
main = do
  n <- readInt
  k <- readInt
  print $ iterate (\x -> min (x + k) (x * 2)) 1 !! n

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"


Measured memory_bytes: 380
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;

int main(void){
	int a,b;
	string s;
	bool j=true;
	cin >> a;
	cin >> b;
	cin >> s;
	int lp=0;
	int count=0;
	while(s[lp]!='-' && lp<(int)s.size()){
		lp++;
		count++;
	}
	//cout << count << endl;
	if(count!=a) j=false;
	lp++; count=0;
	while(s[lp]!='-' && lp<(int)s.size()){
		lp++;
		count++;
	}
	//cout << s.size() <<endl;
	if(count!=b) j=false;
	
	if(j==true){
		cout << "Yes" << endl;
	}else{
		cout <<"No" << 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 REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin>>a[i];

    sort(ALL(a));
    a.push_back(INF);

    int ans=0;

    REP(i,n){
        if(i!=0 && a[i-1]==a[i]) continue;
        int j=i,v=0;
        while(a[j]<=a[i]+2){
            v++;
            j++;
        }
        ans=max(ans,v);
    }

    cout<<ans<<endl;

	return 0; 
}


Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	ringing()
}

func ringing() {
	var a,b,c int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	if a>=b && a>=c {
		fmt.Println(b+c)
	} else if b>=a && b>=c {
		fmt.Println(c+a)
	} else {
		fmt.Println(a+b)
	}
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;

ll fact[222222];
ll ppow(ll a, ll b){
	ll res = 1;
	while (b){
		if (b & 1)(res *= a) %= MOD;
		(a *= a) %= MOD;
		b >>= 1;
	}
	return res;
}
ll route(ll h, ll w){
	ll an1 = fact[h + w];
	ll an2 = fact[h] * fact[w] % MOD;
	an2 = ppow(an2, MOD - 2);
	return an1*an2%MOD;
}

int main(){
	ll  h, w, a, b;
	ll res = 1;
	scanf("%lld%lld%lld%lld", &h, &w, &a, &b);
	fact[0] = 1;
	for (int i = 1; i < h + w; i++){
		(res *= i) %= MOD;
		fact[i] = res;
	}
	res = 0;
	for (int i = b; i < w; i++)
		(res += route(h - a - 1, i)*route(a - 1, w - i - 1) % MOD) %= MOD;
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-                                                         
n, k, q = map(int, input().split())
a_list = [0] * n
for i in range(q):
    a_list[int(input())-1] += 1

for count in a_list:
    if k - q + count > 0:
        print('Yes')
    else:
        print('No')


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

using Weight = int;
struct Edge {
    ll src, dst;
    Weight weight;
    Edge(ll src, ll dst, Weight weight) :
        src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
using Edges = vector<Edge>;
using Graph = vector<Edges> ;

using Array = vector<Weight>;
using Matrix = vector<Array>;

ostream& operator <<(ostream& os, Edge& dt) { return os << "[" << dt.src << "] " << "--" << dt.weight << "-->" << " [" << dt.dst << "]"; }

int main() {
    ll V; cin >> V; // 頂点数
    ll E = V - 1;   // 辺の数

    ll Q; cin >> Q; // 操作回数

    Graph graph(V);
    rep (i, E) {
        ll a, b;
        cin >> a >> b;
        graph[a-1].push_back(Edge(a-1, b-1, 0)); // 0-インデックスにする
        graph[b-1].push_back(Edge(b-1, a-1, 0)); 
    }

    vector<int> p(V, 0);
    rep (i, Q) {
        ll v; cin >> v;
        ll x; cin >> x;
        p[v-1] += x;
    }

    vector<int> visited(V, 0);

    queue<Edge> que;
    visited[0] = 1;
    rep (i, graph[0].size()) {
        que.push(graph[0][i]);
    }

    vector<ll> cnts(V, 0);
    cnts[0] = p[0];
    while (!que.empty()) {
        Edge now = que.front(); que.pop();
        cnts[now.dst] += cnts[now.src] + p[now.dst];
        visited[now.dst] = 1;
        rep (i, graph[now.dst].size()) {
            if (visited[graph[now.dst][i].dst]) { continue; }
            que.push(graph[now.dst][i]); // next
        }
    }

    rep (i, V) {
        cout << cnts[i] << (i == V-1 ? "\n" : " ");
    }

    return 0;
}


Measured memory_bytes: 26668
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;



int main(){
  int N;
  cin >> N;
  int a[N];
  vector<int> v;
  REP(i, 0, N){
    cin >> a[i];
    v.push_back(a[i]);
  }
  sort(v.begin(), v.end(), greater<int>());

  vector<int>::iterator itr = v.begin();

  int ans;
  REP(i, 0, N){
    if (a[i] == *itr) {
      ++itr;
      ans = *itr;
      --itr;
    }
    else {
      ans = *itr;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::unordered_set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N, K; cin >> N >> K;
  vector<char> S(N);
  for(auto& s : S) cin >> s;

  ll unhapi{};
  char last{};
  ui numR{};
  ui numL{};
  ll hapi{};
  for(ui i = 0; i < N; ++i)
  {
    if(S[i] == 'L'){
      if(i == 0 || S[i - 1] != 'L'){
        unhapi += 1;
        ++numL;
      }
      else ++hapi;
    }else{
      if(i == N - 1 || S[i + 1] != 'R'){
        unhapi += 1;
        ++numR;
      }
      else ++hapi;
    }
  }
  while (K)
  {
    if(numR && numL)
    {
      --numR; --numL;
      unhapi -= 2;
    }
    --K;
  }
  if(!unhapi) unhapi++;

  cout << (N - unhapi) << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 384