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

using namespace std;

vector<int> a;

int left(int a){
    return 2*a;
}

int right(int a){
    return 2*a+1;
}

void maxHeapify(int i){
    int l = left(i);
    int r = right(i);
    //自分、左の子、右の子の中でもっとも多き値をもつ節点を保持する
    int largest = i;
    if(r < a.size() && a[largest] < a[r])largest = r;
    if(l < a.size() && a[largest] < a[l])largest = l;
    //iの子のほうが大きかったら、子を上のノードにやらなきゃなので交換してもっかい呼ぶ
    if(largest != i){
        swap(a[i], a[largest]);
        maxHeapify(largest);
    }
}

int main(void){
    int n;
    cin >> n;
    a.push_back(0);
    for(int i = 1; i <= n; i++){
        int t;
        cin >> t;
        a.push_back(t);
    }
    for(int i = n/2; 1 <= i; i--){
        maxHeapify(i);
    }
    a.erase(a.begin());
    for(auto i: a){
        cout << " " << i;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4904
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long total =0;
    for(int i = 1;i<n;i++){
      total = total+n-i;
    }
    System.out.println(total);
  }
}


Measured memory_bytes: 21844
N = int(input())
S = str(input())
cnt = 0

for i in range(10):
  l = S.find(str(i))
  if l == -1:
    continue
  for j in range(10):
    m = S.find(str(j), l + 1)
    if m == -1:
      continue
    for k in range(10):
      n = S.find(str(k), m + 1)
      if n == -1:
        continue
      cnt += 1
print(cnt)

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

#define N 100100

int n, q;
long long m;
int fa[N], a[N], b[N], c[N];

int find(int u) {
    return fa[u] == u ? u : fa[u] = find(fa[u]);
}

int main() {
    scanf("%d %lld %d", &n, &m, &q);
    if (m == n - 1) {
        while (q --) {
            int a, b, c;
            scanf("%d %d %d", &a, &b, &c);
            if (c) return puts("No"), 0;
        }
        return puts("Yes"), 0;
    }
    for (int i = 0; i < n; i ++) fa[i] = i;
    for (int i = 0; i < q; i ++) {
        scanf("%d %d %d", &a[i], &b[i], &c[i]);
        if (!c[i]) {
            int u = find(a[i]), v = find(b[i]);
            fa[u] = v;
        }
    }
    for (int i = 0; i < q; i ++) if (c[i] && find(a[i]) == find(b[i])) return puts("No"), 0;
    int k = 0;
    for (int i = 0; i < n; i ++) if (fa[i] == i) k ++;
    if (m <= n + 1ll * k * (k - 3) / 2) puts("Yes");
    else puts("No");

    return 0;
}


Measured memory_bytes: 1792
//
//  main.cpp
//  Code Festival 2017 Final ProblemF
//
//  Created by 范泽玥 on 2018/6/30.
//  Copyright © 2018年 范泽玥. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <queue>
#include <map>
using namespace std;
int a[44][44],t;
int main() {
    cout<<1407<<" "<<38<<endl;
    for (int j=1;j<=38;j++){
        for (int i=1;i<=37;i++){
            t++;
            a[i][j]=t;
        }
    }
    for (int i=1;i<=38;i++){
        cout<<1407<<" ";
        for (int j=1;j<=37;j++){
            cout<<a[j][i]<<" ";
        }
        cout<<endl;
    }
//    return 0;
    for (int st=0;st<37;st++){
        for (int i=1;i<=37;i++){
            int x=i;
            int y=i+st;
            if (y>37){
                y-=37;
            }
            for (int j=1;j<=37;j++){
                cout<<a[x][j]<<" ";//<<" "<<a[y][j+1]<<endl;
                x=y;
                y=x+st;
                if(y>37){
                    y-=37;
                }
            }
//            cout<<a[x][37]<<" "<<
            cout<<a[st+1][38]<<endl;
//            cout<<i<<" "<<38<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a,b,c=0,d=0,n,m1,n2,m2,min=100000,k=0,ans=0;
    string s,s2;
    cin >> n;
    int i =8;
    b = n;
    while(i){
        c += b % 10;
        i--;
        b /= 10;
    }
    if(n%c==0)
        cout << "Yes" <<endl; 
    else cout << "No" <<endl; 
    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int alpha[26];
  rep(i,26) alpha[i]=0;
  rep(i,s.size()) alpha[s[i]-'a']++;
  int flag = 0;
  rep(i,26){
    if(alpha[i]>1){
      flag++;
      break;
    }
  }

  if(!flag) cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}

int main(){
  solve();
  return 0;
}


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

int main(){
    string S; cin >> S;
    vector<ll> in(4);
    rep(i, 0, 4) in[i] = S[i] - '0';
    for(int bit = 0; bit < 8; bit++){
        ll tmp = in[0];
        string ans[3];
        for(int i = 0; i < 3; i++){
            if(bit & (1<<i)){
                tmp += in[i+1];
                ans[i] = '+';
            }else{
                tmp -= in[i+1];
                ans[i] = '-';
            }
        }
        if(tmp == 7){
            cout << in[0];
            rep(i, 0, 3) cout << ans[i] << in[i+1];
            cout << "=" << tmp << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
/**
 * B - Trick or Treat
 * https://atcoder.jp/contests/abc166/tasks/abc166_b
 */
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    // ある街に、N 人のすぬけ君(すぬけ君 1 、すぬけ君 2 、 ...、 すぬけ君 N )が住んでいます。
    int N, K;
    cin >> N >> K;

    map<int, bool> mp;
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;

        for (int j = 0; j < d; j++) {
            int A;
            cin >> A;
            mp[A] = true;
        }
    }

    // 高橋君は今からこの街を回り、お菓子を 1 つも持っていないすぬけ君にいたずらをします。このとき、何人のすぬけ君がいたずらを受けるでしょうか。
    cout << N - mp.size() << endl;
}
 

Measured memory_bytes: 3608
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;
//------------------------------- Libraries --------------------------------//

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    seika s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    cout << (s < t ? "Yes" : "No") << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1E9 + 7;
long long solve(vector<long long> v, int k)
{
	int n = v.size();
	sort(v.begin(), v.end());
	long long pro = 1;
	if (v[n - 1] == 0 && (k & 1))
		return 0;
	if (v[n - 1] < 0 && (k & 1))
	{
		for (int i = n - 1; i >= n - k; --i)
		{
			pro = ((pro * v[i]) % MOD + MOD) % MOD;
		}
		return pro;
	}
	long long i = 0, j = n - 1;
	if (k & 1)
	{
		pro *= v[j];
		j --;
		k --;
	}
	k >>= 1;
	for (int idx = 0; idx < k; ++idx)
	{
		long long lp = v[i] * v[i + 1];
		long long rp = v[j] * v[j - 1];
		if (lp > rp)
		{
			pro = ((pro * ((lp + MOD) % MOD)) % MOD + MOD) % MOD;
			i += 2;
		}
		else
		{
			pro = ((pro * ((rp + MOD) % MOD)) % MOD + MOD) % MOD;
			j -= 2;
		}
	}
	return pro;

}
int main(int argc, char const *argv[])
{
	int n, k;
	cin >> n >> k;
	vector<long long> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	cout << solve(a, k) << '\n';

	return 0;
}

Measured memory_bytes: 6276
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int n, num, digit, rev = 0;
     
     cin >> num;
     n = num;
     do
     {
         digit = num % 10;
         rev = (rev * 10) + digit;
         num = num / 10;
     } while (num != 0);
    
     if (n == rev)
         cout << "Yes";
     else
         cout << "No";
    return 0;
}

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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;

    int sum = a + b, cnt = 0, b_r = 1;
    for (int i = 0; i < n; i++) {
        if (s.at(i) == 'c') {
            cout << "No" << endl;
        } else {
            if (cnt < sum) {
                if (s.at(i) == 'a') {
                    cout << "Yes" << endl;
                    cnt++;
                } else if (s.at(i) == 'b' && b_r <= b) {
                    cout << "Yes" << endl;
                    cnt++;
                    b_r++;
                } else {
                    cout << "No" << endl;
                }
            } else {
                cout << "No" << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
 
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define all(c) (c).begin(), (c).end()
#define sz(x) ((int)(x).size())
 
 
template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}
 
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    for(int i = 0; i < v.size(); i++) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
 
#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
 
const ll MOD = 1e9 + 7; //998244353
constexpr ll INF = 1e18;
const int MX = 3010;

char grid[6][6];
int n, m, k;


int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m >> k;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m ; j++)
            cin >> grid[i][j];
    
    int ans = 0;

    for(int subrow = 0; subrow < (1 << n); subrow++){
        for(int subcol =  0;  subcol < (1 << m); subcol++){
            int bls = 0;
            for(int i = 0; i < n; i++){
                if(subrow & (1 << (n - 1 - i)))
                    continue;
                for(int j = 0; j < m; j++){
                    if(subcol & (1 << (m - 1 - j)))
                        continue;
                    bls += (grid[i][j] == '#' ? 1 : 0);
                }
            }
            ans += (bls == k ? 1 : 0);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){

    int n,k,s=0;
    cin>>n>>k;
    vector<int>v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    sort(v.begin(),v.end());
    for(int i=0;i<k;i++)
        s+=v[i];
    cout<<s<<endl;

}


Measured memory_bytes: 3576
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

	int q;
	double x;

	while(cin >> q) {
		if(q==-1)
			break;
		x=q/2;
		while(abs(x*x*x-q)>0.00001*q) {
			x=x-(x*x*x-q)/(3*x*x);
		}
		printf("%.6f\n", x);
	}

	return 0;

}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
  int m,f,r,i;
  for(i=0;;i++){
    scanf("%d %d %d",&m,&f,&r);
    if(m==-1&&f==-1&&r==-1){
      break;
    }else if(m==-1||f==-1||m+f<30){
      printf("F\n");
    }else if(80<=m+f){
      printf("A\n");
    }else if(65<=m+f&&m+f<80){
      printf("B\n");
    }else if((50<=m+f&&m+f<65)||r>=50){
      printf("C\n");
    }else if(30<=m+f&&m+f<50){
      printf("D\n");
    }
  }
  return 0;
}


Measured memory_bytes: 2140
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from collections import *
import math
from bisect import *
import functools
INF = float('inf')
mod = 10**9+7

N = int(input())
h = [int(x) for x in input().split()]
ans, cnt = 0, 0
for i in range(N-1):
    if h[i] >= h[i+1]:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
print(max(cnt, ans))


Measured memory_bytes: 14748
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  cout << n - k + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b,ans;;
  char op;
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='?'){
      break;
    }
    if(op=='+'){
      ans=a+b;
    }
    if(op=='-'){
      ans=a-b;
    }if(op=='*'){
      ans=a*b;
    }if(op=='/'){
      ans=a/b;
    }
    printf("%d\n",ans);
}
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#define N 100

using namespace std;

int main() {
  int i, j, m, n, result;
  int A[N][N], B[N];

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

  for(i=0; i < n; i++) {
    result=0;
    for(j=0; j < m; j++) {
      result += A[i][j] * B[j];
    }
    cout << result << endl;
  }
  return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string s, p;
    cin >> s >> p;
    string ss = s + s;

    auto it = search(ss.begin(), ss.end(), p.begin(), p.end());
    if (it != ss.end()){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 1188
package main

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

func main() {
	sc = initScanner(os.Stdin)
	n := scanInt(sc)
	a := scanIntSlice(sc, n)

	resolve(n, a)
}

func resolve(n int, a []int) {
	t := make([]int, n)
	copy(t, a)
	sort.Ints(t)
	max1 := t[n-1]
	max2 := t[n-2]

	for i:=0; i<n;i++ {
		if a[i] == max1 {
			fmt.Println(max2)
		} else {
			fmt.Println(max1)
		}
	}
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}


Measured memory_bytes: 7608
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    string S;
    int N;
    cin >> N;
    map<string, int> cnt;
    rep(i, N) {
        cin >> S;
        cnt[S]++;
    }

    cout << "AC x " << cnt["AC"] << endl;
    cout << "WA x " << cnt["WA"] << endl;
    cout << "TLE x " << cnt["TLE"] << endl;
    cout << "RE x " << cnt["RE"] << endl;

    return 0;
}


Measured memory_bytes: 3664
def main():
    N, M = map(int, input().split())

    if N > M:
        N, M = M, N

    if (N, M) == (1, 1):
        print(1)
        return

    if N == 1:
        print(M - 2)
        return

    print((N - 2) * (M - 2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

ll dp[100002][2];
int main() {
  string s;
  cin>>s;
  dp[0][0]=1;
  dp[0][1]=0;
  for(int i=0;i<s.size();i++){
//      dp[i+1][0]+=dp[i][0];
//      dp[i+1][1]+=dp[i][1]*2;

      if(s[i]=='1'){

      // dp[i+1][1]+=dp[i][0]*2;
      dp[i+1][1]=(3ll*dp[i][1]+dp[i][0]);
      dp[i+1][0]=(2ll*dp[i][0]);

      }else{
          dp[i+1][1]=(3ll*dp[i][1]);
          dp[i+1][0]=dp[i][0];

      }
      //cout<<dp[i+1][0]<<" "<<dp[i+1][1]<<endl;
      dp[i+1][0]%=MOD;
      dp[i+1][1]%=MOD;
  }
  cout<<(dp[s.size()][1]+dp[s.size()][0])%MOD<<endl;








    return 0;
}


Measured memory_bytes: 2048
class Imos:
    def __init__(self, n):
        self.B = [0] * n
        self.n = n
        from itertools import accumulate
        self.ac = accumulate

    def __call__(self, l, r):
        l, r = max(l, 0), min(r, self.n - 1)
        self.B[l] += 1
        self.B[r + 1] -= 1

    def out(self):
        *res, = self.ac(self.B)
        # self.__init__(self.n)
        return res

from collections import defaultdict
d = defaultdict(list)
imos = Imos(10 ** 5 + 1)

(N, C), *D = [[*map(int, o.split())] for o in open(0)]
for s, t, c in D:
    d[c] += (s, t),
for p in d.values():
    p.sort()
    ps, pt = p[0]
    for s, t in p[1:] + [[0,0]]:
        if pt == s:
            pt = t
        else:
            imos(ps - 1, pt - 1)
            ps, pt = s, t
print(max(imos.out()))

Measured memory_bytes: 36696
#include<bits/stdc++.h>
#define N 100005
using namespace std;
vector<int>a[N];int d[N],Q[N],fa[N],n,m;
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m+n-1;i++){
		int x,y;scanf("%d%d",&x,&y);
		d[y]++;a[x].push_back(y);
	}
	int rt=0;
	for (int i=1;i<=n;i++)
		if (!d[i]) rt=i;
	int h=0,t=1;Q[1]=rt;
	while (h<t){
		int x=Q[++h];
		for (int i=0;i<a[x].size();i++)
			if (!(--d[a[x][i]]))
				fa[Q[++t]=a[x][i]]=x;
	}
	for (int i=1;i<=n;i++)
		printf("%d\n",i==rt?0:fa[i]);
}

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

class Program
{
	static void Main()
	{
		string st = null;
		List<int> m = new List<int>();
		
		while(true)
		{
			st = Console.ReadLine();
			if (st == null) break;
			
			m.Add(int.Parse(st));
		}
		
		if (m.Count != 0)
		{
			int[] ma = m.ToArray();
			Array.Sort(ma);
			Array.Reverse(ma);
			
			for (int i = 0; i < 3; i++)
			{
				Console.WriteLine(ma[i]);
			}
		}
	}
}



Measured memory_bytes: 13972
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i, H)cin >> S[i];
  rep(j, W+2)cout << "#";
  cout << endl;
  rep(i, H){
    cout << "#";
    rep(j, W){
      cout << S[i][j];
    }
    cout << "#"<<endl;
  }
  rep(j, W+2)cout << "#";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;
ll A[200000];
ll sm(ll* A,ll n){
    ll s= 0;
    for (int i = 0; i < n; ++i) {
        s += A[i];
    }
    return s;
}
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    ll sum_t = A[0];
    ll sum = sm(A, n);
    ll mi = abs(2*A[0] - sum);
    for (int i = 1; i < n-1; ++i) {
        sum_t += A[i];
        mi = min(abs(2*sum_t - sum), mi);
    }
    cout << mi << "\n";




}

Measured memory_bytes: 1792
#include <stdio.h>
int main(){
  int k, a, b;
  scanf("%d", &k);
  scanf("%d%d", &a, &b);
  int o=(b/k)*k;
  if (a<=o){
    printf("OK");
    }
  else {
    printf("NG");
  }
 return 0;
 }

Measured memory_bytes: 1700
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmpArray = br.readLine().split(" ");
		int x = Integer.parseInt(tmpArray[0]);
		//int y = Integer.parseInt(tmpArray[1]);
		int h = x/3600;
		int m = (x%3600)/60;
		int s = x%60;
		System.out.println(h+":"+m+":"+s);
	}

}

Measured memory_bytes: 24280
#include<iostream>//cinなど
#include<string>//文字列
#include<algorithm>//sort など
#include<math.h>//paw(冪乗など)
#include<set>// 集合
#include<map>//写像
#include<stdio.h>//printf
#include<stack>

using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(a*b,c*d)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Monad.Primitive (PrimState)
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

type BVec = MV.MVector (PrimState IO) Bool

main :: IO ()
main = do
    [n, m] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    mv1 <- MV.replicate n False :: IO BVec
    mv2 <- MV.replicate n False :: IO BVec
    replicateM_ m $ do
        [a, b] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
        when (a == 1) $ MV.unsafeWrite mv1 (b - 1) True
        when (b == n) $ MV.unsafeWrite mv2 (a - 1) True
    v1 <- V.unsafeFreeze mv1
    v2 <- V.unsafeFreeze mv2
    putStrLn $ if V.or (V.zipWith (&&) v1 v2) then "POSSIBLE" else "IMPOSSIBLE"


Measured memory_bytes: 1404
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s;
    cin >> s;
    string t = "keyence";
    int tmp = s.size() - 7;
    if (s == t)
    {
        cout << "YES" << endl;
        return 0;
    }
    rep(i, s.size())
    {
        bool f = true;
        int cnt = 0;
        rep(j, i)
        {
            if (s[j] != t[j])
                f = false;
        }
        Rep(j, i + tmp, s.size())
        {
            if (s[j] != t[j - tmp])
                f = false;
        }
        if (f)
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main()
{
	ll l, r;
	cin >> l >> r;

	if (r - l > 3000) 
	{
		ANS(0);
	}
	else
	{
		ll ans = INF;

		for (ll i = l; i < r; i++)
		{
			for (ll j = l + 1; j <= r; j++)
			{
				ans = min(ans, i * j % 2019);
			}
		}
		ANS(ans);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

constexpr long long INF = LLONG_MAX;
constexpr long long MOD = 1000000007;
constexpr long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void veccin(vector<T>& v) {
    for (auto && e : v) { cin >> e; }
}

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k, i, j;
ll ans = 0, sum = 0, cnt = 0;
//ld d;
string s/*1, s2, s3*/;
char c/*1, c2, c3*/;
bool flag = false;

/*--------------------template--------------------*/

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

    cin >> n >> m >> k >> i >> j;
	if(!n)
      ans = 1;
	else if (!m)
      ans = 2;
	else if (!k)
      ans = 3;
    else if (!i)
      ans = 4;
    else
      ans = 5;
    cout << ans << endl;
}


Measured memory_bytes: 3644
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int n;
string s;
int ile[300];
const int P = 1e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> s;
  R(i,n){
    ile[(int)s[i]]++;
  }
  int res = 1;
  R(i,300){
    res *= ile[i] + 1;
    res %= P;
  }
  cout << (res + P - 1) % P << "\n";
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
using namespace std;
int n,tot,root,cnt,res;
const int N=100010;
int head[N],to[N<<1],nt[N<<1],del[N],du[N],val[N],dp1[N],dp2[N];
char s[N];
void add(int f,int t)
{
	to[++tot]=t;nt[tot]=head[f];head[f]=tot;
}
void dfs(int x,int fa)
{
	del[x]=(s[x]=='B');
	for(int i=head[x];i;i=nt[i])
		if(to[i]!=fa)
		{
			dfs(to[i],x);
			if(!del[to[i]])++du[x],++du[to[i]];
			del[x]&=del[to[i]];
		}
}
void dp(int x,int fa)
{
	cnt+=du[x];
	if((du[x]+(s[x]=='B'))&1)val[x]=0;else val[x]=2,++cnt;
	int mx1=0,mx2=0,flag=0;
	for(int i=head[x];i;i=nt[i])
		if(to[i]!=fa&&!del[to[i]])
		{
			dp(to[i],x);
			flag=1;res=max(res,max(dp1[to[i]]+val[x]+mx2,dp2[to[i]]+val[x]+mx1));
			mx1=max(mx1,dp1[to[i]]);mx2=max(mx2,dp2[to[i]]);
		}
	dp1[x]=mx1+val[x];
	if(flag)dp2[x]=mx2+val[x];
	else dp2[x]=-1e9;
}
int main()
{
	cin>>n;if(!n)return puts("0")==2333;
	for(int i=1,x,y;i<n;++i)
		scanf("%d%d",&x,&y),add(x,y),add(y,x);
	scanf("%s",s+1);root=-1;
	for(int i=1;i<=n;++i)
		if(s[i]=='W'){root=i;break;}
	if(root==-1)return puts("0")==2333;
	dfs(root,0);dp(root,0);cout<<cnt-res;
	return 0;
}

Measured memory_bytes: 10496
import math
import fractions

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

g = fractions.gcd(A,B)

if g == 1:
    print(1)
    exit()

ans = 1

for i in range(2,math.floor(math.sqrt(g))+1):
    if g % i == 0:
        ans += 1
        while g % i == 0:
            g = g//i
if g != 1:
    ans += 1

print(ans)

Measured memory_bytes: 5688
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,su;
	string s;
	char a[200];
	while(1){
		cin >> s;
		if(s[0]=='-') break;
		cin >> n;
		for(int i=0;i<n;i++){
			cin >> su;
			for(int j=0;j<su;j++){
				a[j]=s[j];
			}
			for(int j=su;j<s.size();j++){
				s[j-su]=s[j];
			}
			for(int j=0;j<su;j++){
				s[s.size()-su+j]=a[j];
			}
		}
		cout << s << endl;
	}
}		


Measured memory_bytes: 3212
#include <iostream>
#include <limits.h>

#define el endl
#define fd fixed

using namespace std;

int main() {
  while (1) {
    int n;
    cin >> n;
    int m = n;
    if (n == 0) break;
    int max = INT_MIN;
    int min = INT_MAX;
    int ave = 0;
    while (m--) {
      int x;
      cin >> x;
      ave += x;
      if (x < min) min = x;
      if (x > max) max = x;
    }
    ave = ave - (max + min);
    ave = ave / (n-2);
    cout << ave << el;
  }
}

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

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int32_t main(){
    boost;    
    int n;
    cin >> n;
    
    cout << (n*(n+1))/2;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

long long pow_mod(long long b, long long p, long long mod = 1'000'000'007){
    long long ret = 1;
    while (p){
        if (p & 1) ret = (ret * b) % mod;
        b = (b * b) % mod;
        p >>= 1;
    }
    return ret;
}

long long inv_mod(long long n, long long mod = 1'000'000'007){
    return pow_mod(n, mod - 2, mod);
}

class ModuloMath{
private:
    long long N;
    long long mod;
    vector<long long> fac;
    vector<long long> invfac;
public:
    ModuloMath(long long N, long long mod = 1'000'000'007): N{N}, mod{mod}{
        fac.resize(N + 1, 1);
        invfac.resize(N + 1, 1);
        for (long long i = 1; i <= N; ++i) fac[i] = (fac[i - 1] * i) % mod;
        invfac[N] = pow_mod(fac[N], mod - 2, mod);
        for (long long i = N; i != 1; --i) invfac[i - 1] = (invfac[i] * i) % mod;
    }
    long long nCr(long long n, long long r){return (r > n or r < 0) ? 0 : (fac[n] * invfac[n - r] % mod * invfac[r] % mod);}
    long long nPr(long long n, long long r){return (r > n or r < 0) ? 0 : (fac[n] * invfac[n - r] % mod);}
    long long nHr(long long n, long long r){return nCr(n + r - 1, r);}
};

constexpr long long mod = 1'000'000'007;
constexpr int offset = 2002;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ModuloMath mm(offset * 4);
    int N;
    cin >> N;
    vector<pair<int, int>> AB(N);
    for (auto & p : AB) cin >> p.first >> p.second;
    vector<vector<long long>> dp(offset * 2, vector<long long>(offset * 2, 0LL));
    for (auto & p : AB) ++dp[offset - p.first][offset - p.second];
    for (int i = 1; i != offset * 2; ++i){
        for (int j = 1; j != offset * 2; ++j){
            dp[i][j] += (dp[i][j - 1] + dp[i - 1][j]) % mod;
        }
    }
    long long cum = 0LL;
    for (auto & p : AB) {
        cum = (cum + dp[offset + p.first][offset + p.second]) % mod;
        cum = (cum - mm.nCr((p.first + p.second) * 2, p.first * 2) + mod) % mod;
    }
    if (cum & 1) cum += mod;
    cout << (cum / 2) << endl;
    return 0;
}

Measured memory_bytes: 127360
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
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<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,K; cin >> N >> K;
    vector<ll> A(N); for(auto& in:A) cin >> in;

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

    if(K == 0) return A.back();


    auto ok = [&](double m){

        ll cnt = 0;
        for(int i = 0; i < N;i++){
            cnt += ceil(A[i]/m)-1;
            if(cnt > K) return false;
        }
        return true;
    };
    double l = 0.5, r = 2*INF;
    for(int i = 0; i < 300; i++){

        double m = (l+r)/2;

        if(ok(m)) r = m;
        else l = m;
    }
    res = ceil(r);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
   ll n,i,c=0,j,k,x;
  cin>>n;
  for(i=1;i<n;i++){
     if(n%i==0){
         x=(n/i)-1;
         c+=x;
     }
     else{
         x=(n/i);
         c+=x;
     }
  }
  cout<<c;
    return 0;
}

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

using namespace std;

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

#define pb push_back
#define mp make_pair

int n;
int a[123456];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    ll sum = 0;
    ll ans = 0;
    for(int i = 0; i < n - 1; i++){
        sum += a[i];
        if(sum * 2 < a[i + 1]){
            ans = i + 1;
        }
    }
    cout << n - ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  string t;
  cin>>s>>t;
  int si=s.size();
  rep(i,si){
    if(s[i]!=t[i]){
      cout<<"No"<<'\n';
      return(0);
    }
  }
  cout<<"Yes"<<'\n';
  return(0);
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define req(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define qer(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=10000000000000000;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int main(){
	int n,ans=0;cin>>n;
    req(i,1,n)ans+=(n-1)/i;cout<<ans;
    return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	ll x, glad = 0; cin >> x;
	while (x >= 500)
	{
		x -= 500;
		glad += 1000;
	}
	while (x >= 5)
	{
		x -= 5;
		glad += 5;
	}

	cout << glad;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  int n;
  cin >> n;
  set<int> st;
  rep(i, n){
    int num;
    cin >> num;
    if(st.find(num) == st.end()){
      st.insert(num);
    }else{
      st.erase(num);
    }
  }
  cout << st.size() << endl;
  return 0;
}
      
      

Measured memory_bytes: 4864
A, B, K = map(int, input().split())

yakusuu=[]
yakusuuA = []
yakusuuB = []
for i in range(1,A+1):
  if A% i == 0:
    yakusuuA.append(i)
  
for j in range(1,B+1):
  if B%j == 0:
    yakusuuB.append(j)
    
yakusuu = list(set(yakusuuA) & set(yakusuuB))
yakusuu.append(1)     
print(sorted(yakusuu, reverse=True)[K-1])

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  

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

n, m = list(map(int, input().split()))

ans = 1
num = int(m**0.5)+1

for i in range(1, num):
    if m % i != 0:
        continue
    j = m//i
    if i >= n:
        ans = max(ans, j)
    if j >= n:
        ans = max(ans, i)
print(ans)


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

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		long[] team=new long[N*3];
		for(int i=0; i<3*N; i++) {
			team[i]=sc.nextLong();
		}
		Arrays.sort(team);
		long res=0;
		for(int i=0; i<N; i++) {
			res+=team[3*N-1-(2*i+1)];
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 97968
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: ident) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let n: usize = parse!(it);
    let x: Vec<isize> = parse!(it, n);
    let m = (x.iter().sum::<isize>() as f64) / (n as f64);
    let m = if m - m.floor() < 0.5 {
        m.floor() as isize
    } else {
        m.ceil() as isize
    };
    println!("{}", x.iter().map(|&x| (x - m) * (x - m)).sum::<isize>());
}


Measured memory_bytes: 4480
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

using P = tuple<int, int>;
int main() {
  int n;
  cin >> n;

  vector<P> bots(n);
  rep(i, n) {
    int x, L;
    cin >> x >> L;

    bots[i] = P(x + L, x - L);
  }

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

  int last = -2'000'000'000;
  int result = 0;
  rep(i, n) {
    int l, r;
    tie(r, l) = bots[i];
    if (l >= last) {
      last = r;
      result++;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
cd=[list(map(int,input().split())) for i in range(m)]
for i in range(n):
  x=[0]*m
  for j in range(m):
    x[j] = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
  print(x.index(min(x))+1)

Measured memory_bytes: 3064