akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        var vals = new int[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
        var idx = int.Parse(Console.ReadLine()) - 1;
        Console.WriteLine(vals[idx]);
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		// input
		final int HEIGHT = scan.nextInt();
		final int WIDTH = scan.nextInt();
		char[][] canvas = new char[HEIGHT+2][WIDTH+2];
		for(int i = 1; i <= HEIGHT; i++){
			String input = scan.next();
			char[] temp = input.toCharArray();
			for(int j = 1; j <= WIDTH; j++){
				canvas[i][j] = temp[j-1];
			}
		}
		
		// search
		String answer = "Yes";
		loop: for(int i = 1; i <= HEIGHT; i++){
			for(int j = 1; j <= WIDTH; j++){
				if(canvas[i][j] == '#'){
					if(canvas[i-1][j] != '#' && canvas[i+1][j] != '#' && canvas[i][j-1] != '#' && canvas[i][j+1] != '#'){
						answer = "No";
						break loop;
					}
				}
			}
		}
		
		// answer
		System.out.println(answer);

	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int cnt[11];

int main(void){
    for(int i=0;i<4;i++){
        int a;
        scanf("%d",&a);
        cnt[a]++;
        //printf("%d\n",a);
    }
    if(cnt[1]==1 && cnt[4]==1 && cnt[7]==1 && cnt[9]==1){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.Point2D;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
//Loopで使う文字列の長さは固定！
//intで大丈夫？オーバーフローしない？
//Loop回数は本当に10⁹以内になってる？Loopは回る？？
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        int mod=1000000007;
        int n=sc.nextInt();
        int[] a=new int[n];
        for (int i = 0; i < n; i++) {
            a[i]=sc.nextInt();
        }
        HashMap<Integer,Integer> map=new HashMap<>();
        for (int i = 0; i < n; i++) {
            map.put(a[i],map.getOrDefault(a[i], 0)+1);
        }
        if((n%2==0&&map.get(0)!=null)||(n%2==1&&map.get(0)!=1)){
            out.println(0);
            exit(0);
        }
        for(int k:map.keySet()){
            if(k!=0&&map.get(k)!=2){
                out.println(0);
                exit(0);
            }
        }
        if(n%2==0){
            out.println(power(2,n/2)%mod);
        }else{
            out.println(power(2,(n-1)/2)%mod);
        }
    }
    static long power(long x,int n){
        long mod=1000000007;
        long ans=1;
        while (n>0) {
            if((n&1)==1){
                ans=(ans*x)%mod;
            }
            x=(x*x)%mod;
            n>>=1;
        }
        return ans;
    }
}

Measured memory_bytes: 53924
using System;

namespace ALDS1_1_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int x = int.Parse(str[0]);
            int y = int.Parse(str[1]);
            int surplus;

            if (y > x)
            {
                y = int.Parse(str[0]);
                x = int.Parse(str[1]);
            }

            while (y != 0)
            {
                surplus = x % y;
                x = y;
                y = surplus;
            }
            Console.WriteLine("{0}", x);
        }
    }
}


Measured memory_bytes: 17968
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    char in;
    char vowel[5] = {'a','e','i','o','u'};
    cin >> in;
    bool ans = false;
    REP(i,5) if(in == vowel[i]) ans = true;
    if(ans) cout << "vowel" << endl;
    else cout << "consonant" << endl;
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let buf = buf.trim_end();
    let n: i32 = buf.parse::<i32>().unwrap();
    if n >= 30 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2088
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++) cin >> A[i];
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        int minj = i;
        for(int j = i; j < N; j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        swap(A[i], A[minj]);
        if (i != minj) cnt++;
    }

    for (int i = 0; i < N; i++) (i != N-1) ? cout << A[i] << ' ' : cout << A[i] << endl;
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N, K;
  scanf("%d %d", &N, &K);
  
  vector<int> v(N);
  for(int i=0;i<N;i++){
    scanf("%d", &v[i]);
  }
  
  sort(v.begin(), v.end());
  int S = accumulate(v.begin(), v.begin()+K, 0);
  printf("%d\n", S);
  
  return 0;
}

Measured memory_bytes: 3796
package main

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

// define
var (
	sc = bufio.NewScanner(os.Stdin)
)

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func main(){
	var n int
	fmt.Scan(&n)
	arr := scanIntSplit(n)
	ans := 10000000
	for _, num := range arr{
		bin := fmt.Sprintf("%b", num)
		l, cnt := len(bin), 0
		for i:=1; i<=l; i++{
			if bin[l-i]-'0' == 0{
				cnt++
			} else {
				if cnt < ans{
					ans = cnt
				}
				break
			}
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 640
using System;

class Program
{
	static void Main()
	{
		while (true)
		{
			string[] D = Console.ReadLine().Split(' ');
			int a = int.Parse(D[0]), b = int.Parse(D[2]);
			switch (D[1])
			{
				case "+":
					Console.WriteLine(a + b);
					break;
				case "-":
					Console.WriteLine(a - b);
					break;
				case "*":
					Console.WriteLine(a * b);
					break;
				case "/":
					Console.WriteLine(a / b);
					break;
				default:
					return;
			}
		}
	}
}

Measured memory_bytes: 5704
n = int(input())
p = [item for sublist in [[int(input().split()[1])] if i != 0 else list(map(int, input().split())) for i in range(n)] for item in sublist]

def memolize(f):
    cache = {}

    def helper(x, y):
        if (x, y) not in cache:
            cache[(x, y)] = f(x, y)
        return cache[(x, y)]
    return helper

@memolize
def calcMatrixOrder(i, j):
    if i == j :
        return 0
    return min([calcMatrixOrder(i, k) + calcMatrixOrder(k + 1, j) + p[i]*p[k+1]*p[j + 1] for k in range(i, j)])

print(calcMatrixOrder(0, n - 1))



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

using namespace std;

int n;
int a[200000], b[200000];

bool allSame() {
    for(int i = 0; i < n; i++)
        if(a[i] != b[i])
            return false;
    return true;
}

int main() {
    scanf("%d", &n);

    long long sum = 0;
    for(int i = 0; i < n; i++) {
        scanf("%d %d", a+i, b+i);
        sum += a[i];
    }

    if(allSame()) {
        printf("0\n");
        return 0;
    }

    long long small = 1e9+7;
    for(int i = 0; i < n; i++)
        if(a[i] > b[i] && b[i] < small)
            small = b[i];

    printf("%lld\n", sum - small);
    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
//#include<bits/stdc++.h>
#include <iostream>
#include<vector>
#include<set>
#include<iterator>
#include<string>
#include<map>
#include<stack>
#include<cmath>
#include<algorithm>
#include <cstdio>
#include<cstdlib>
#include <cstring>
#include <unordered_map>
#include <iomanip>
#include <queue>
#include<numeric>
#define baap_coder17 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define   lli long long int
#define ld long double
#define  endl "\n"
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define ui unsigned int
#define mt make_tuple
#define t_(t)[(i)]  get<(i)>((t))
#define vsort(v) sort((v).begin(), (v).end())
#define vsortr(v) sort((v).rbegin(), (v).rend())
#define all(v)  (v).begin(), (v).end()
#define rall(v)  (v).rbegin(), (v).rend()
#define vdp(n,x) vector<vector<ll>>dp(n+1,vector<ll>(x+1));
const ld EPSILON=0.000000001;
const ld mod=1e9+7;
const lli AM=2e5+5;
const ld pi=3.14159265358979323846;
lli max(lli a,lli b){if(a>b)return a;else return b;}
using namespace std;
lli fact(lli n) {lli ans=1; for(lli i=1;i<=n;i++) ans*=i; return ans;}
lli powm(lli a, lli b, lli n){lli x=1, y=a; while (b > 0) {if (b%2 == 1) {x = (x*y) % n; } y = (y*y) % n; b /= 2;}return x % n;}
lli pow(lli x, lli y) { lli res = 1; while (y > 0) { if (y & 1) res = ((res) * (x)); y = y >> 1; x = ((x) * (x)); } return res; }
lli min(lli a,lli b) {if(a>b)return b;else return a;}
bool cmp(ld x,ld y){if(abs(x-y)<=EPSILON)return 1;return 0;}
 bool checkprime(lli n){ for(lli i=2;i*i<=n;i++) if(n%i==0)return false;   return true;}
lli gcd(lli a, lli b){return b ? gcd (b, a % b) : a;}
 int fun(pair<lli,lli> p1,pair<lli,lli> p2)
{
    if(p1.X<=p2.X)
        return 1;
    return 0;
}
lli lcm(lli a, lli b) { return (a * b) / gcd(a, b); }
lli modInverse(lli a, lli m) { lli g = gcd(a, m); return powm(a, m - 2, m); }


set<int> seg[2000009];
void build(int l,int r,int ind,int arr[])
{
    if(l==r)
    {
        seg[ind].insert(arr[l]);
        return;
    }
    int mid=(l+r)/2;
    build(l, mid, 2*ind+1, arr);
    build(mid+1, r, 2*ind+2, arr);
    seg[ind].insert(all(seg[2*ind+1]));
    seg[ind].insert(all(seg[2*ind+2]));
}
set<int> qry(int l,int r,int ql,int qr,int ind)
{
    set<int> left,right,result;
    if(r<ql || l>qr)
        return result;
    if(l>=ql and r<=qr)
        return seg[ind];
    int mid=(l+r)/2;
    left=qry(l, mid, ql, qr, 2*ind+1);
    result.insert(all(left));
    right=qry(mid+1, r, ql, qr, 2*ind+2);
    result.insert(all(right));
    return result;
}
void qry(int ql,int qr,int n)
{
    set<int> st=qry(0, n-1, ql, qr, 0);
    cout<<st.size()<<endl;
}


int main()
{
    int n; cin>>n;
    string s; cin>>s;
    int arr[n];
    arr[0]= (s[0]=='R'?1:0);
    for(int i=1;i<n;i++)
    {
        arr[i]=arr[i-1];
        if(s[i]=='R')
            arr[i]+=1;
    }
    int ans=arr[n-1];
    for(int i=0;i<n;i++)
        ans = min(ans, min(i-arr[i]+1,arr[n-1]-arr[i]) + max(i-arr[i]+1-min(i-arr[i]+1,arr[n-1]-arr[i]),arr[n-1]-arr[i]-min(i-arr[i]+1,arr[n-1]-arr[i])) );
    cout<<ans<<endl;
        
    return 0;
}



Measured memory_bytes: 98260
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def f(x):
    cnt = 0
    if x < 0:
        j = p-1
        for i in range(m)[::-1]:
            while j >= 0:
                if minus[i]*plus[j] <= x:
                    j -= 1
                else:
                    break
            cnt += p - j - 1
    else:
        j = p-1
        for i in range(p):
            while j >= 0:
                if plus[i]*plus[j] > x:
                    j -= 1
                else:
                    break
            cnt += max(0,j - i)
        j = 0
        for i in range(m)[::-1]:
            while j < m:
                if minus[i]*minus[j] > x:
                    j += 1
                else:
                    break
            cnt += max(0,i - j)
        cnt += (m+p)*zero + zero*(zero-1)//2 + m*p
    return cnt >= k
        
n,k = LI()
a = LI()
a.sort()
minus = [x for x in a if x < 0]
plus = [x for x in a if x > 0]
m = len(minus)
p = len(plus)
zero = bl(a,1) - br(a,-1)
ok = 10**18
ng = -10**18-1
while ok-ng > 1:
    mid = (ok+ng)//2
    if f(mid):
        ok = mid
    else:
        ng = mid
print(ok)


    


Measured memory_bytes: 87636
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();

    if (s.matches("^A?KIHA?BA?RA?$")) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }

}


Measured memory_bytes: 23124
package main

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

var sc *bufio.Scanner

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

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

type item struct {
	w int
	v int
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	n, W := nextInt(), nextInt()
	items := make([]item, n)
	for i := range items {
		w, v := nextInt(), nextInt()
		items[i] = item{w, v}
	}
	dp := make(map[int]int)
	dp[0] = 0
	for _, item := range items {
		dpNext := make(map[int]int)
		for w, v := range dp {
			wTmp, vTmp := w, v
			vNext, ok := dpNext[wTmp]
			if !ok || vTmp > vNext {
				dpNext[wTmp] = vTmp
			}

			wTmp, vTmp = w+item.w, v+item.v
			if wTmp > W {
				continue
			}
			vNext, ok = dpNext[wTmp]
			if !ok || vTmp > vNext {
				dpNext[wTmp] = vTmp
			}
		}
		dp = dpNext
	}

	ans := 0
	for _, v := range dp {
		if v > ans {
			ans = v
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		
		int arr[] = new int[N+1];
		for(int i=1;i<=N;i++) {
			arr[i] = scan.nextInt();
		}
		System.out.println(minIncurredCost(N,K,arr));
	}
	
	public static int minIncurredCost(int N, int k, int[]arr) {
		int dp[] = new int[N+1];
		dp[1] = 0;
		for(int i = 2;i<=N;i++) {
			dp[i] =  Integer.MAX_VALUE;
			//faced issue
			for(int j=i-1;j>=1 && (i-j)<=k;j--) {
				dp[i] = Math.min(dp[i],Math.abs(arr[i]-arr[j])+dp[j]);
			}
		}
		return dp[N];
	}
	
	
}

Measured memory_bytes: 51972
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
ll a[10];

int main() {
	for (int i = 0; i < 7; i++)
		nl(a[i]);
	ll ans = a[0] - (a[0] & 1) + a[1] + a[3] + a[4] - (a[3] & 1) - (a[4] & 1);
	if (a[0] && a[3] && a[4]) {
		a[0]--, a[3]--, a[4]--;
		ans = max(ans, a[0] - (a[0] & 1) + a[1] + a[3] + a[4] - (a[3] & 1) - (a[4] & 1) + 3);
	}
	prl(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define REPR(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORR(i, a, b) \
  for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)
#define ALL(f, x, ...) \
  ([&](auto& y) { return (f)(begin(y), end(y), ##__VA_ARGS__); })(x)
auto INDEX = [](auto& x, auto& xs) { return &x - &xs[0]; };
void async_io() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
const auto inf = INT_MAX / 3;
const auto pi = 2 * std::acos(0.0);
const auto eps = 1e-14;
using ll = signed long long;
using ull = unsigned long long;

signed main() {
  async_io();
  int n;
  while (true) {
    cin >> n;
    if (n == 0) return 0;
    auto sum = 0;
    for (int i = 2;; i++) {
      auto base = i * (i + 1) / 2;
      if (base > n) break;
      if ((base - n) % i == 0) sum++;
    }
    cout << sum << "\n";
  }
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

// debug
template <class T> ostream& operator<<(ostream &s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
// *************** TEMPLATE END *************** 

int n, MOD;
int mod_pow(int x, int n) {
  if (n == 0) return 1;
  int tmp = mod_pow(x, n / 2);
  return tmp * tmp % MOD * (n % 2 ? x : 1) % MOD;
}

int inv(int x) {
  return mod_pow(x, MOD - 2);
}

vector<int> fact, fact_inv, pows;
void init() {
  fact = vector<int>(n + 1, 1);
  fact_inv = vector<int>(n + 1);
  REP (i, n) {
    fact[i + 1] = fact[i] * (i + 1) % MOD;
  }
  fact_inv[n] = inv(fact[n]);
  for (int i = n; i >= 1; i--) {
    fact_inv[i - 1] = fact_inv[i] * i % MOD;
  }
  REP (i, n + 1) {
    assert(fact[i] * fact_inv[i] % MOD == 1);
  }

  pows = vector<int>(n + 1, 1);
  REP (i, n) {
    pows[i + 1] = pows[i] * 2 % MOD;
  }
}
int comb(int n, int r) {
  return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
}

signed main() {
  cin >> n >> MOD;
  int ans = 0;
  init();
  REPI (a, 1, n) {
    int b = n - a;
    int acc = 0;
    REPI (i, 1, b + 1) {
      int sign = (b - i) % 2 ? -1 : +1;
      acc += sign * comb(b, i) % MOD * mod_pow(pows[i] - 1, a) % MOD;
      (acc += MOD) %= MOD;
    }
    int tmp = (a * (a - 1) + b * (b - 1)) / 2 % MOD;
    ans += acc * comb(n, a) % MOD * mod_pow(2, tmp) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3284
import java.io.BufferedReader;
		import java.io.IOException;
		import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] nums = (br.readLine().split(" "));
		double num1 = Integer.parseInt(nums[0]);
		double num2 = Integer.parseInt(nums[1]);

		System.out.println((int)Math.ceil(num1/(num2*2+1)));
	}
}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
long long int N,M,D[10000],J[10000],dp[1011][1011];
int main(){
    cin>>N>>M;
    for(int a=0;a<N;a++){cin>>D[a];}
    for(int a=0;a<M;a++){cin>>J[a];}
    for(int a=0;a<1011;a++){
        for(int b=0;b<1011;b++){
            dp[a][b]=5000000000000000;
        }
    }
    dp[0][0]=0;
    for(int a=0;a<M;a++){
        for(int b=0;b<=N;b++){
            dp[a+1][b]=min(dp[a+1][b],dp[a][b]);
            dp[a+1][b+1]=min(dp[a+1][b+1],dp[a][b]+D[b]*J[a]);
        }
    }cout<<dp[M][N]<<endl;;
}

Measured memory_bytes: 11104
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> x;
  ans = 500 * n;
  if (ans >= x)
    Cout("Yes");
  else
    Cout("No");
  return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<pair<pair<int64_t, int64_t>, int64_t>> links;
    vector<vector<int64_t>> w(n, vector<int64_t>(n, 1L << 30));
    for (auto _ : irange(0L, m)) {
        int64_t a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        w[a][b] = c;
        w[b][a] = c;
        links.emplace_back(make_pair(a, b), c);
    }

    for (auto i : irange(0L, n)) {
        for (auto j : irange(0L, n)) {
            for (auto k : irange(0L, n)) {
                w[j][k] = min(w[j][k], w[j][i] + w[i][k]);
            }
        }
    }

    int64_t ans = 0;
    for (const auto& link : links) {
        if (w[link.first.first][link.first.second] != link.second) {
            ++ans;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
H = list(map(int, input().split()))
B = [True]*N
for _ in range(M):
    a, b = map(int, input().split())
    if H[b-1] > H[a-1]:
        B[a-1] = False
    elif H[a-1] > H[b-1]:
        B[b-1] = False
    else:
        B[a-1] = False
        B[b-1] = False
print(B.count(True))

Measured memory_bytes: 20028
// finish date: 2019/2/22

#include <bits/stdc++.h>

using namespace std;

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


int main() {
    int N, W;
    cin >> N >> W;
    vi w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vvl dp(N, vl(W + 1, 0));
    dp[0][w[0]] = v[0];
    ll ma = 0;
    FOR(i, 1, N) {
        dp[i][w[i]] = v[i];
        rep(j, W + 1) {
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            if (j + w[i] <= W && dp[i-1][j]!=0) dp[i][j + w[i]] = max(dp[i][j + w[i]], v[i] + dp[i - 1][j]);
        }
    }
    rep(i, N) rep(j, W + 1) ma = max(ma, dp[i][j]);
    cout << ma << endl;

    return 0;
}

Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;

int main(){
	int n,k;
	cin>>n>>k;
	int h[n];
	rep(i,n)cin>>h[i];
	int dp[n];
	dp[0]=0;
	for(int i=1;i<n;i++){
		int mn=divisor;
		for(int j=1;j<=k;j++){
			if(i-j<0)break;
			mn=min(mn,dp[i-j]+abs(h[i]-h[i-j]));
		}
		dp[i]=mn;
	}
	puts(dp[n-1]);
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll A, B; cin >> A >> B;
  cout << A*B << endl;

  return 0;
}



Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
long lcm(int a,int b) {
	long long gcd;
	long long c = max(a, b);
	long long d = min(a, b);
	while (true) {
		if (c % d == 0) {
			gcd = d;
			return a*b/gcd;
		}
		else {
			c -= d;
			if (c <= d) {
				swap(c, d);
			}
		}
	}
}
int main() {
	int n; cin >> n;
	long a, b; cin >> a >> b;
	a = lcm(a, b);
	for (int i = 0; i < n - 2; i++){
		cin >> b;
		a = lcm(a, b);
	}
	cout << a << endl;
}

Measured memory_bytes: 3076
#include<iostream>
#include<queue>
#include<cmath>
#include<vector>
#include<functional>

using namespace std;
typedef long long ll;

int Q;
ll B = 0;

priority_queue <ll> ls;
priority_queue <ll, vector<ll>, greater<ll>> rs;

ll ans = 0;
ll anspos = 0;

int main() {

	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int a;
		cin >> a;
		if (a == 1) {
			//更新クエリ
			ll b, c;
			cin >> b >> c;
			B += c;
			if (i == 0) {
				ls.push(b), rs.push(b);
				anspos = b;
			}
			else {
				ll lvalue, rvalue;
				lvalue = ls.top(), rvalue = rs.top();
				if (lvalue <= b && b <= rvalue) {
					ls.push(b), rs.push(b);
					//最小値の更新はなし

					//最小値をとる場所はbに更新する
					anspos = b;
				}
				else if(b < lvalue){
					ll tmp1;
					rs.push(ls.top()), ls.pop();
					ls.push(b), ls.push(b);
					
					//もともとの更新前の中央値番の点と今回入力された点の間で差分更新を行う

					ans += min(abs(lvalue - b), abs(b - rvalue));

					//最小値をとる場所は*ls.end()に更新
					anspos = ls.top();
				}
				else {
					ll tmp1;
					ls.push(rs.top()), rs.pop();
					rs.push(b), rs.push(b);

					//もともとの更新前の中央値番の点と今回入力された点の間で差分更新を行う
					ans += min(abs(lvalue - b), abs(b - rvalue));

					//最小値をとる場所は*ls.end()に更新
					anspos = ls.top();
				}
			}
		}
		else {
			//求値クエリ
			cout << anspos << " " << ans + B << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4588
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

# A以上B以下にXの倍数が幾つあるか？ 1 < A < B
def check(A, B, X):
    x = (A-1) // X
    y = (B-0) // X
    return y - x

import fractions

def main():
    A, B, C, D = i2nn()
    # A以上B以下の数
    n = B - A + 1
    # Cの倍数
    n -= check(A, B, C)
    # Dの倍数
    n -= check(A, B, D)
    # GCD(C, D)の倍数
    E = C * D // fractions.gcd(C, D)
    n += check(A, B, E)
    print(n)

main()


Measured memory_bytes: 65644
module Main where
import           Control.Applicative

main :: IO ()
main = do
    input <- words <$> getLine
    let [a, b, k] = map read input
    putStrLn $ solveSecond a b k

solveSecond :: Int -> Int -> Int -> String
solveSecond a b k = do
    let takahashi = a - k
    case takahashi of
        takahashi | takahashi > 0  -> (show takahashi) ++ " " ++ (show b)
                  | takahashi <= 0 -> "0 " ++ (show $ max 0 (b + takahashi))


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<double>arr(n);
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	vector<double>dp(n+1);
	dp[0]=1.0-arr[0];
	dp[1]=arr[0];
	for(int i=2;i<=n;i++){
		double head=arr[i-1];
		double tail=1.0-arr[i-1];
		dp[i]=head*dp[i-1];
		for(int j=i-1;j>0;j--){
			dp[j]=dp[j]*tail+dp[j-1]*head;
		}
		dp[0]*=tail;
	}
	int start_index=ceil(n/2.0);
	// for(int i=0;i<=n;i++){
	// 	cout<<dp[i]<<" ";
	// }
	// cout<<endl;
	double sum=0.0;
	for(int i=start_index;i<=n;i++){
		sum+=dp[i];
	}
	cout<<setprecision(12)<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  double x[n],y[n];
  double ans=0;
  for(int i=0;i<n;i++){
    cin >> x[i] >> y[i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<i;j++){
      ans += sqrt(pow((x[j]-x[i]),2)+pow((y[j]-y[i]),2));
    }
  }
  cout << fixed << setprecision(7);
  cout << ans*2/n << endl;
}
    

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

using namespace std;

int main(void)
{
	ios::sync_with_stdio(false);
	char c;
	cin >> c;
	if(c!='a'&&c!='e'&&c!='i'&&c!='o'&&c!='u')
	{
		cout << "consonant" << endl;
	}
	else
	{
		cout << "vowel" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vc= vector<char>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()

int main(){
  int n,k,ans=0;
  cin >> n >> k;
  vi h(n);
  rep(i,n){
    cin >> h[i];
    if(h[i]>=k)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = s; i < b; i+=d)
#define lpsb(i, s, b) for(size_t i = s; i < b; i++)
#define lpn(i, n) for(size_t i = 0; i < n; i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    auto p = vc(int, N);
    fa(i, p) cin >> i;
    int ans = 0;
    lpsb(i, 2, N) if ((p[i-2] > p[i-1] && p[i-1] > p[i]) || (p[i-2] < p[i-1] && p[i-1] < p[i])) ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
t=0
d=[list(map(int,input().split())) for i in range(n)]
for i in range(n-2):
    if d[i][0]==d[i][1] and d[i+1][0]==d[i+1][1] and d[i+2][0]==d[i+2][1]:
        t+=1
        break
if t==1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 62636
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();

    int a = k * x;
    int b = n - k;
    int c = b * y;

    if(n < k) {
      System.out.println(n * x);
    }else {
      System.out.println(a+c);
    }
  }
}


Measured memory_bytes: 8788
N,W = list(map(int,input().split()))
DP = [[0]*(W+1) for i in range(N+1)]
for i in range(1,N+1):
    w,v = list(map(int,input().split()))
    for j in range(W+1):
        DP[i][j] = max(DP[i-1][j],DP[i-1][j-w]+v) if w <= j else DP[i-1][j]
print(max(DP[N]))

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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> ds(n);
  for (auto &p : ds) cin >> p.first >> p.second;
  bool ok = false;
  for (int i = 0; i < n - 2; ++i) {
    if (ds[i].first == ds[i].second && ds[i + 1].first == ds[i + 1].second && ds[i + 2].first == ds[i + 2].second) {
      ok |= 1;
    }
  }
  cout << (ok ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t,a,b,c,d,e,flag=0,cnt=0,flag1=0;
    vector<int>vec;
    map<int,int>mp;

    cin>>a>>b;
    for(int i=0;i<b;i++){
        cin>>c;
        cnt+=c;
    }
    if(cnt>a){
        cout<<-1<<endl;
    }
    else cout<<a-cnt<<endl;
}


Measured memory_bytes: 3640
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int main()
{
    int A, B;
    std::cin >> A >> B;

    if (B % A == 0) {
        std::cout << A + B << std::endl;
    } else {
        std::cout << B - A << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = rm()
s = rr()
print(s[:b-1] + s[b-1].lower() + s[b:])


Measured memory_bytes: 26956
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    int A,B ,C,K;
    cin >> A >>B >> C >> K;

    ll ans=0;
    if(A <= K){
        ans += A * 1;
        K -= A;
    }
    else{
        ans += K;
        K -=K;
    }
    if(B <= K){
        
        K -= B;
    }
    else{
        
        K -=K;
    }
    if(C <= K){
        ans -= C * 1;
        K -= C;
    }
    else{
        ans -= K;
        K -=K;
    }
    cout << ans;
     
    

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T,class U>
ostream& operator << (ostream& os,pair<T,U>& p){
	os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
	is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		os << vec[i];
		if(i+1<vec.size())os << ' ';
	}
	return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
	for(int i=0;i<vec.size();i++)is >> vec[i];
	return is;
}
void fastio(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
}
int N,K;
int a[200100];
set<int> s;
int rmi[200100],rmx[200100];
bool sorted[200100];
int main(){
  cin >> N >> K;
  for(int i=0;i<N;i++){
    cin >>a[i];
  }
  int ans = 0;
  for(int i=0;i<K;i++)s.insert(a[i]);
  for(int i=K-1;i<N;i++){
    rmi[i] = *s.begin();
    rmx[i] = *s.rbegin();
    s.erase(a[i-K+1]);
    if(i+1<N)s.insert(a[i+1]);
  }
  int cnt = 1;
  for(int i=1;i<N;i++){
    if(a[i]>a[i-1])cnt++;
    else cnt = 1;
    if(cnt>=K)sorted[i] = true;
  }
  // for(int i=0;i<N;i++){
  //   cout << rmi[i] << ' ' << rmx[i] << endl;
  // }
  int s = 0;
  if(sorted[K-1])s = 1;
  else ans = 1;
  for(int i=K;i<N;i++){
    if(sorted[i]){
      s = max(1,s);
      continue;
    }
    if(rmi[i-1]!=a[i-K]||rmx[i]!=a[i])ans++;
  }
  cout << ans+s << endl;
	return 0;
}


Measured memory_bytes: 10368
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    if "RRR" in S:
        ans = 3
    elif "RR" in S:
        ans = 2
    elif "R" in S:
        ans = 1
    else:
        ans = 0

    print(ans)


if __name__ == "__main__":
    main()


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

int partition(int *A,int p,int r)
{
	int x = A[r];//基準値をxに格納
	int box,j,i = p-1;
	for( j = p ; j < r ; j++){//jがこれから探索する要素番号を示す
		if( A[j] <= x){//xより小さければ
			i = i+1;//iをインクリメントする
			box=A[i];//xより大きくかつ最後に追加した要素と入れ替える
			A[i]=A[j];
			A[j]=box;
		}
	}
	box=A[i+1];//基準値をiの位置に格納する
	A[i+1]=A[r];
	A[r]=box;
	
	return i+1;
}

int main(void)
{
	int mid,i,n,*A;
	scanf("%d",&n);
	A = (int*)malloc(sizeof(int)*n+1);
	for(i=0;i<n;i++) scanf("%d",&A[i]);
	
	mid=partition(A,0,n-1);
	
	for(i=0;i<n;i++) {
		if(i!=0) printf(" ");
		if(i==mid) printf("[");
		printf("%d",A[i]);
		if(i==mid) printf("]");
	}
	printf("\n");

	
	free(A);
	return 0;
}


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

const int N = 1e5 + 10;
struct node{
	int p, y, id;	
}a[N];

bool cmp1(node c1, node c2) {
	if(c1.p == c2.p) return c1.y < c2.y;
	else return c1.p < c2.p;	
}
bool cmp2(node c1, node c2) {
	return c1.id < c2.id;	
}
int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i=0;i < m; i++) {
		scanf("%d %d", &a[i].p, &a[i].y);
		a[i].id = i + 1;
	}
	sort(a, a + m, cmp1);
	int cnt = 1;
	for(int i = 0; i < m; i++) {
		if( i >= 1 && a[i].p == a[i - 1].p) {
			cnt++;
		} else {
			cnt = 1;
		}
		a[i].y = cnt;
	}
		sort(a, a + m, cmp2);
	for (int i = 0; i < m; i++) {
		printf("%06d%06d\n", a[i].p, a[i].y);
	}
	
	return 0;
}

Measured memory_bytes: 4984
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  
  vector<int> ans(n);
  
    for(int i=0;i<n;i++){
      ans.at(a.at(i)-1)=i+1;
    }
  
  for(int i=0;i<n;i++){
    cout << ans.at(i) ;
    if(i==n-1){
      cout << endl;
  }
    else cout << " ";
  }
}

Measured memory_bytes: 1536
# -*- coding: utf-8 -*-
def main():
    h,w = map(int, input().split())
    if h == 1 or w == 1:
        print(1)
        return
    if h*w %2 == 0:
        print(int(h*w/2))
    else:
        print(int((h*w+1)/2))
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 9080
import sys
import math
import fractions
import bisect
import queue
import heapq
import collections
import itertools
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint=====================================
N, K = map(int, input().split())
N, M = map(int, input().split())
A, B = map(int, input().split())

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

L, R = map(int, input().split())

1行のstring=================================
S, T = input().split()

1行の整数配列================================
P = list(map(int,input().split()))

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

D = list(map(int,input().split()))

L = list(map(int,input().split()))
R = list(map(int,input().split()))

T = list(map(int,input().split()))

改行あり整数==================================
X = []
Y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    X.append(x1)
    Y.append(y1)

A = []
for i in range(N):
    a=int(input())
    A.append(a)

Pair = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    Pair.append((x1, y1))
    
2次元整数配列=====================================
A = []
for i in range(N):
    tmp = list(map(int,input().split()))
    A.append(tmp)


N行M列の初期化====================================
dp = [[VAL] * RETU for i in range(GYO)]

'''



N, K = map(int, input().split())
D = list(map(int,input().split()))

use = [True]*10
for d in D:
    use[d] = False

for pay in range(N, N*1000):
    
    can = True
    pay_string = str(pay)
    for p in pay_string:
        if not use[int(p)]:
            can = False
            break

    if can:
        print(pay)
        sys.exit()
    







Measured memory_bytes: 5076
# 拡張ユークリッド互除法
# ax + by = gcd(a,b)の最小整数解を返す
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

T = int(input())
for _ in range(T):
    A, B, C, D = map(int, input().split())
    if D < B or A < B:
        print("No")
    else:
        g = egcd(B, D)[0]
        mA = A % g
        mC = C % g
        k = C + (mA - mC if mA - mC > 0 else mA - mC + g)
        k -= B
        if k >= 0:
            print("Yes")
        else:
            print("No")


Measured memory_bytes: 3064
/*
Author : icewizard99
Created: 17:30:19 27-06-2020
*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define int long long int
#define ull unsigned long long
#define FastAF ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ff first
#define ss second
#define pb push_back
#define FOR(a,L,R) for(int i=L;i<R;i++)
#define all(v) v.begin(),v.end()
#define rev(v) reverse(all(v))
#define sot(v) sort(all(v))
#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a) printa(a,0,a.size())
#define print2d(a,row,col) for(int i=0;i<row;i++) for(int j=0;j<col;j++) cout<<a[i][j]<<(j==col-1?'\n':' ')
#define mem(a,x) memset(a,x,sizeof(a))


int32_t main(){
    FastAF;

    ll a;
    cin>>a;
    ll b = a;
    b+=(a*a);
    b+=(a*a*a);
    cout<<b;
    return 0;
}



Measured memory_bytes: 3600
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<string>
#define ll long long
#define INF 0x3f3f3f3f
#define N 100005
using namespace std;
int main()
{
	long long a[N],k=0,i,n;
	for(i=1;i<100000;i++)
	{
		if(i*i>(long long)1e9)
		break;
		else
		a[k++]=i*i;
	}
	scanf("%lld",&n);
	for(i=k-1;i>=0;i--)
	if(a[i]<=n)
	{
		printf("%lld\n",a[i]);
		break;
	}
}

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

int main(){
	string a;
	cin>>a;
	for(int i=0;i<a.size();i++){
		if(a[i]=='9'){
			cout<<"Yes"<<endl;
			return 0;
        }
	}
	cout<<"No";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())

oh = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for tr in range(n):
    b, f, r, v = map(int, input().split())
    oh[b - 1][f - 1][r - 1] += v
    
for k in range(4):
    for j in range(3):
        tmp = ''
        for i in range(10):
            tmp += (' ' + str(oh[k][j][i]))
        print(tmp)
    if k < 3:
        print('#' * 20)

Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	vector<int> G[610];
	int n,m,a[200000],b[200000];
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		cin >> a[i] >> b[i]; a[i]--;b[i]--;
		G[a[i]].push_back(b[i]);
	}
	double p[610] = {1},e[610] = {};
	for(int i = 0;i < n;i++){
		for(int to : G[i]){
			p[to] += p[i] / G[i].size();
		}
	}
	for(int i = n - 1;i >= 0;i--){
		for(int to : G[i]){
			e[i] += (e[to] + 1) / G[i].size();
		}
	}
	double mi = e[0];
	for(int i = 0;i < n;i++){
		if(G[i].size() == 1) continue;
		double ea = 0,ma = 0;
		for(int to : G[i]){
			double add = (e[to] + 1) / (G[i].size() - 1);
			ea += add;
			ma = max(ma,add);
		}
		chmin(mi,e[0] + p[i] * (ea - ma - e[i]));
	}
	printf("%.12lf\n",mi);
}


Measured memory_bytes: 5504
from collections import deque

n,m = map(int,input().split())
stores = []
for _ in range(n):
    a,b = map(int,input().split())
    stores.append((a,b))
stores.sort()
stores = deque(stores)

count = m
ans = 0
while count != 0:
    a,b = stores.popleft()
    quantity = min(count,b)
    ans += a*quantity
    count -= quantity
print(ans)

Measured memory_bytes: 17656
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+1];
        for(int i=0; i<=n; i++) {
            a[i] = sc.nextInt();
        }

        long res = 0;
        long[] max = new long[n+1];
        max[0] = 1 - a[0];
        if(max[0] < 0) {
            System.out.println(-1);
            return;
        }
        long ln = 100000000000000L;
        for(int i=1; i<=n; i++) {
            max[i] = Math.min(max[i-1]*2 - a[i], ln);
            if(max[i] < 0) {
                System.out.println(-1);
                return;
            }
        }

        res = a[n];
        long[] b = new long[n+1];
        b[n] = a[n];
        for(int i=n-1; i>=0; i--) {
            b[i] = Math.min(max[i], b[i+1]) + a[i];
            res += b[i];
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 58904