akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  
  int n, k;
  cin>>n>>k;
  
  int maxk = n * ( n - 1 ) / 2 - ( n - 1 );
  
  if( maxk < k ){
    cout<<-1<<endl;
    return 0;
  }
  
  typedef pair<int,int> P;
  
  set<P> used;
  
  for(int i=1;i<n;i++) used.insert( P( 0, i ) );
  
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      
      if( maxk == k ) break;
      
      if( used.count( P( i, j ) ) ) continue;
      
      used.insert( P( i, j ) );

      maxk--;
      
    }
  }
  
  cout<<used.size()<<endl;
  
  for(P edge : used){
    cout<<edge.first+1<<' '<<edge.second+1<<endl;    
  }
  
  return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


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

int main()
{

    ll K;
    cin >> K;

    ll sum = 0;
    REP(a,1,K+1) {
        REP(b,1,K+1) {
            REP(c,1,K+1) {
                sum += gcd(gcd(a,b),c);
            }
        }
    }
    _PR(sum);

    return 0;
}

/*



*/

Measured memory_bytes: 3636
#include<stdio.h>


int main()
{

    int a,b,nd=0,x,y,z,i,sum=0;

    scanf("%d",&a);

    int A[a];

    for(i=0;i<a;i++){

        scanf("%d",&A[i]);

    }




    for(i=0;i<a-2;i++)
    {
        x=A[i];
        y=A[i+1];
        z=A[i+2];

        if(x<y && y<z) sum++;
        else if(x>y && y>z) sum++;



    }

    printf("%d\n",sum);


    return 0;

}



Measured memory_bytes: 1668
object Main extends App {
  val s = scala.io.StdIn.readLine()
  var result = 0
  if (s == "SSS") {
    result = 0
  } else if (s == "RRR") {
    result = 3
  } else if (s == "RRS" || s == "SRR") {
    result = 2
  } else {
    result = 1
  }
  println(result)
}


Measured memory_bytes: 54556
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll x;
	cin >> x;
	ll ans = 1;
	if (x == 1) {
		ans = 0;
	}
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}



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

const int N = 19;
const int M = 60;

int dp[1 << N][M];
int a[N], b[N];

void update(int &a, int b){
    if (b == -1){
        return;
    }
    if (a == -1 || a > b){
        a = b;
    }
}

int main(){
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i){
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; ++ i){
        scanf("%d", &b[i]);
    }
    for (int i = 1; i < 1 << n; ++ i){
        for (int j = 0; j < n; ++ j){
            if (i >> j & 1){
                int pre = i ^ 1 << j;
                int pos = __builtin_popcount(i) - 1;
                int value = (pos - j) & 1 ? b[j] : a[j];
                int inv = 0;
                for (int k = 0; k < n; ++ k){
                    if (i >> k & 1){
                        inv += k > j;
                    }
                }
                for (int k = 0; k <= value; ++ k){
                    if (dp[pre][k] == -1){
                        continue;
                    }
                    update(dp[i][value], dp[pre][k] + inv);
                }
            }
        }
    }
    int ans = -1;
    for (int i = 0; i < M; ++ i){
        update(ans, dp[(1 << n) - 1][i]);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 123136
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//      debug shrine
//
// #######################
//     ##           ##
//   ###################
//     ##           ##
//     ##           ##
//     ##           ##
//     ##           ##
//     ##           ##

int main(int argc, char *argv[]) {
	string S;
	cin >> S; //同じ文字が二個連続 or XOXのように一つ挟んで同じ文字 を見つける

	char prev_2, prev_1;
	if (S.length() > 2) {
		prev_2 = S[0];
		prev_1 = S[1];
	}
	else {
		if (S[0] == S[1]) {
			cout << 1 << " " << 2 << endl;
		}
		else {
			cout << -1 << " " << -1 << endl;
		}
		return 0;
	}
	for (int i = 2; i < S.size(); i++) {
		if (prev_2 == S[i]) {
			cout << i - 1 << " " << i + 1 << endl;
			return 0;
		}
		else if (prev_1 == S[i]) {
			cout << i << " " << i + 1 << endl;
			return 0;
		}
		else {
			prev_2 = prev_1;
			prev_1 = S[i];
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
package main
 
import(
  "fmt"
  "math"
)

func solver(a int){
  flag := false
  for ;;{
    flag = judge(a)
    if flag == true{
      fmt.Println(a)
      break
    }
    a = a + 1
  }
}

func judge(a int) bool{
  sq := math.Sqrt(float64(a))
  for i:=2; i<int(sq)+1; i++{
    if a%i == 0{
      return false
    }
  }
  return true
}

func main(){
  a := 0
  fmt.Scan(&a)
  solver(a)
}

Measured memory_bytes: 512
def f(C):
    for k in range(10):
        for i in range(10):
            for j in range(10):
                if C[i][j] > C[i][k] + C[k][j]:
                    C[i][j] = C[i][k] + C[k][j]

    return C


def main():
    h, w = list(map(int, input().split()))
    C = []
    for i in range(10):
        C.append(list(map(int, input().split())))

    f(C)

    A = []
    for i in range(h):
        A.append(list(map(int, input().split())))

    res = 0

    for a in A:
        for i in a:
            if i < 0:
                continue
            res += C[i][1]

    print(res)
    return 0

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <iostream>

std::string in, out, tmp;

std::string removelast(std::string str) {
    tmp = "";
    if (str.length() >= 1) {
        for (int i=0; i<str.length()-1; ++i) 
            tmp += str[i];
    }
    return tmp;
}

void solve() {
    std::cin >> in;
    out = "";
    for (int i=0; i<in.length(); ++i) {
        if (in[i] == *"B") 
            out =  removelast(out);
        else
            out += in[i];
    }
    std::cout << out << std::endl;
}

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

Measured memory_bytes: 764
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Cryptography.X509Certificates;

namespace hello_world
{class Program
	{
		static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(" ");
			int A = int.Parse(input[0]);
			int B = int.Parse(input[1]);
			int C = int.Parse(input[2]);
			int K = int.Parse(input[3]);
			int sum = 0;

			if (A >= K)
				sum += K;
			else if (A + B >= K)
				sum += A;
			else if (A + B + C > K)
				sum = 2 * A + B - K;
			else if (A + B + C <= K)
				sum = A - C;
			Console.WriteLine(sum);
			
		}
	}

}

	

Measured memory_bytes: 27504
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect
import statistics
mod = 10**9+7

N, K  = list(map(int, input().split()))
ans = [0 for i in range(K+1)]

for i in range(K,0,-1):
    a = pow((K // i), N, mod)
    for j in range(2,K+1):
        if i*j <= K:
            a = (a - ans[i*j]) % mod
        else:
            break
    ans[i] = a % mod

# print(ans)

b = [i*ans[i] % mod for i in range(K+1)]
print(sum(b) % mod)





Measured memory_bytes: 85796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589;

int main(){
  int a,  b;
  cin >> a >> b;
  if(a > b) swap(a, b);
  rep(i, b) cout<<a;
  cout<<endl;
}

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

using namespace std;
int a,b;
int n= 0;


void solve(){

    return;
}

int main(){
    cin >> a >> b;

    cout << a / b << " " << a%b << " ";
    double f = 1.0 * a/b;
    printf("%.5f\n", f);

    return 0;
}


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

typedef long long int ll;
ll a, b, c, k;

int main() {
    cin >> a >> b >> c >> k;
    if(k <= a) cout << k << endl;
    else if(k <= a + b) cout << a << endl;
    else cout << a - min(c, (k - (a + b))) << endl;

    return 0;
}

Measured memory_bytes: 3628
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Activity = Tuple!(long, "sea", long, "mount", long, "home");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

auto dp = new long[][](100_100, 3);
void main()
{
    auto n = lread();
    auto act = new long[][](n, 3);
    foreach (i; iota(n))
    {
        long a, b, c;
        scan(a, b, c);
        act[i] = [a, b, c];
    }
    foreach(i; iota(n))
    {
        foreach(j; iota(act[i].length))
        {
            dp[i + 1][j] = act[i][j] + max(dp[i][(j + 1) % 3], dp[i][(j + 2) % 3]);
        }
    }
    dp[n].reduce!(max).writeln();
}

auto max_rm(T)(T[] a, T recent = -1)
{
    long maxnum = -INF;
    foreach (i; iota(a.length))
        if (i != recent)
            maxnum = max(a[i], maxnum);

    return maxnum;
}


Measured memory_bytes: 22268
def shuffle(s)
  s=s.split("")
  ($stdin.gets.to_i).times do
    s << s.shift($stdin.gets.to_i)
    s.flatten!
  end
  return s.join("")
end

  until ( iS=$stdin.gets.chomp ) =~ /-/ do
    puts shuffle(iS)
  end



Measured memory_bytes: 7012
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = unsigned long long;
const long long INF = 1LL << 60;
 
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 min(ll a, ll b){
    if(a < b) return a;
    else return b;
}
 
int main(void){
    int N; cin >> N;
    vector<int> A(N,0);
    map<int,int> mp;
    int MAX1 = 0, MAX2 = 0;
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
        mp[A.at(i)]++;
        if(A.at(i) > MAX1){
            MAX1 = A.at(i);
        }
    }
    for(int i = 0; i < N; i++){
        if(A[i] != MAX1){
            MAX2 = max(MAX2, A[i]);
        }
    }
    for(int i = 0; i < N; i++){
        //cout << "aa" << mp[A[i]] << endl;
        //cout << "num" << A[i] << "MAX1" << MAX1 << endl;
        if(A.at(i) == MAX1){
            if(mp[A.at(i)] > 1) cout << MAX1 << endl;
            else cout << MAX2 << endl;
        }else{
            cout << MAX1 << endl;
        }
    }
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			sum += a[i];
		}
		else {
			sum -= a[i];
		}
	}
	cout << sum << endl;

	return 0;
}

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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数
vector<long long> fact, fact_inv, inv;

//二項係数前処理計算量O(SIZE)
void init_nCk(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
    
//nCk　計算量(1)
ll nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n+1);
    vector<ll> flag(n+1,-1);
    ll s,t;
    REP(i,n+1){
        cin>>a[i];
        if(flag[a[i]]==-1){
            flag[a[i]]=i;
        }else{
            s=flag[a[i]];
            t=i;
        }
    }

    init_nCk(1000000);

    REP2(i,1,n+2){
        ll ans=nCk(n+1,i);
        if(i<=n-t+s+1) ans-=nCk(n-t+s,i-1);
        while(ans<0) ans+=MOD;
        cout<<ans<<endl;
    }
    

}

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

int c[3][3];

int main(void) {
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            if (c[i+1][j] - c[i][j] != c[i+1][j+1] - c[i][j+1]) {
              cout << "No" << endl;
              return 0;
            }
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

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

  int ans[3];
  for(int i=0; i<3; i++)  ans[i] = -1;

  for(int i=0; i<=n; i++)
    for(int j=i; j<=n; j++){
      int sum = 10000*i + 5000*(j-i) + 1000*(n-j);
      if(sum == y){
	ans[0] = i;
	ans[1] = j-i;
	ans[2] = n-j;
      }
    }

  for(int i=0; i<3; i++)
    printf("%d ", ans[i]);
  puts("");

  return 0;
}


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

int main(void)
{
  int n,input;
  int count=0;
  vector<int> d;

  cin>>n;

  for(int i=0;i<n;i++)
  {
    cin>>input;
    d.push_back(input);
  }

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

  for(int i=0;i<n;i++)
  {
    if(i != n-1)
    {
      if(d[i]!=d[i+1])
      {
        count++;
      }
    }
    else
    {
      count++;
    }
  }
  cout<<count<<endl;
}


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

int jump(int n,vector<int>& h,vector<int>& level)
{
    if(level[n] == -1)
    {
        int n_1 = abs(h[n] - h[n - 1]) + jump(n - 1,h,level); 
        int n_2 = abs(h[n] - h[n - 2]) + jump(n - 2,h,level);
        level[n] = n_1 < n_2 ? n_1 : n_2;
    }
    return level[n];
}

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

    vector<int> h(N + 1);
    vector<int> level(N + 1, -1);

    for(int i = 1;i <= N;i++)
    {
        cin >> h[i];
    }
    level[1] = 0; 
    level[2] = abs(h[2] - h[1]);
    
    cout << jump(N,h,level) << endl;

}

Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>

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

typedef long long int lli;
using namespace std;
typedef pair<int, int> ii;
// #define int long long int

inline void swap(int &a, int &b) {
    int tmp = a;
    a = b;
    b = tmp;
}

struct Vertex {
    vector<ii> list; // v, cost
    int color; // 1: white, -1: black
};

signed main() {
    int N;
    cin >> N;
    vector<Vertex> V(N);
    for (int i = 0; i < N - 1; i++) {
        int _u, _v, _w; cin >> _u >> _v >> _w;
        V[_u - 1].list.push_back(ii(_v - 1, _w));
        V[_v - 1].list.push_back(ii(_u - 1, _w));

        V[i].color = 0;
    }

    queue<int> Q;
    V[0].color = 1;
    Q.push(0);
    while(!Q.empty()) {
        int v = Q.front(); Q.pop();
        for (int i = 0; i < V[v].list.size(); i++) {
            ii vw = V[v].list[i];

            if (V[vw.first].color == 0) Q.push(vw.first);

            if (vw.second % 2 == 0) {
                V[vw.first].color = V[v].color;
            } else {
                V[vw.first].color = V[v].color * -1;
            }
        }
    }

    for (int i = 0; i < N; i++) {
        cout <<( V[i].color == -1 ? 0 : 1) << endl;
    }
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define INF (ll)(1e10)

int main(){
	int n, m;
	cin >> n >> m;
	vector<ll> cost(1<<n, INF);
	cost[0]=0;

	for(int i=0; i<m; i++){
		int a, b;
		cin >> a >> b;
		int c=0;
		for(int j=0; j<b; j++){
			int t;
			cin >> t;
			t--;
			c+=(1<<t);
		}
		for(int j=0; j<(1<<n); j++){
			cost[j|c]=min(cost[j|c], cost[j]+a);
		}
	}
	if(cost[(1<<n)-1]!=INF) cout << cost[(1<<n)-1] << endl;
	else cout << -1 << endl;
	return 0;
}

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

int main(int argc, char const *argv[])
{
    string s;
    int sbegin, send;
    /* code */
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'A')
        {
            sbegin = i;
            break;
        }
    }
    for (int i = s.length() - 1; i >= 0; i--)
    {
        if (s[i] == 'Z')
        {
            send = i;
            break;
        }
    }
    cout << send - sbegin + 1;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<map>
using ll = long long;
using namespace std;
int main(){
    ll n,m,cnt=0,x,y=0;
    cin >> n >> m;
    map<ll,ll> mod;
    mod[0]++;
    for(ll i=1;i<=n;i++){
         cin >> x;
         y=(x+y)%m;
         mod[y]++;
    }
    for(auto itr=mod.begin();itr!=mod.end();itr++){
        ll cal=itr->second;
        cnt+=cal*(cal-1)/2;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>
	
int n,k,max=0;
int array[100000];

int main(void){
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&array[i]);
	if(array[i]>max) max=array[i];
	}
	int left=0,right=1000000000;
	while(right-left>1){
		int mid=(left+right)/2;
		if(look(mid))right=mid;
		else left=mid;
	}
	printf("%d\n",right);
	return 0;
}

int look(int m){
    int i;
    int count=1,point=m;
    if(m<max) return 0;
    for(i=0;i<n;i++){
        if(point>=array[i]){
           point-=array[i];
        }else{
            count++;
            point=m-array[i];
        }
    }
    if(count>k) return 0;
    else return 1;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
using ll = long long;
int main() {
  
  int N,M;
  cin >> N >> M;
  int sum = 0;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
  cin >> vec.at(i);
    sum += vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  if(vec.at(M-1)*4*M >= sum){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
    return 0;
}

Measured memory_bytes: 256
from collections import deque
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
ab.sort()

ab = deque(ab)

ans = 0
m = 0
while m < M:
    a, b = ab.popleft()
    tm = min([b, M - m])
    ans += tm * a
    m += tm
print(ans)

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

using namespace std;

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

int N;
double dp[333][333][333];

double rec(int i, int j, int k) {
  if (dp[i][j][k] >= 0) return dp[i][j][k];
  if (i == 0 && j == 0 && k == 0) return 0.0;

  double res = 0.0;
  if (i > 0) res += rec(i - 1, j, k) * i;
  if (j > 0) res += rec(i + 1, j - 1, k) * j;
  if (k > 0) res += rec(i, j + 1, k - 1) * k;
  res += N;
  res *= 1.0 / (i + j + k);

  return dp[i][j][k] = res;
}

int main() {
  cin >> N;
  int one = 0, two = 0, three = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a == 1)
      one++;
    else if (a == 2)
      two++;
    else
      three++;
  }
  memset(dp, -1, sizeof(dp));
  printf("%.12f\n", rec(one, two, three));
  return 0;
}

Measured memory_bytes: 288768
#!/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()))

n = I()
b = LI()
flag = [True] * n
ans = []
for i in range(n):
    cnt = 0
    idx = -1
    for j in range(n):
        if flag[j]:
            cnt += 1
            if b[j] == cnt:
                idx = j
    if idx == -1:
        print(-1)
        quit() 
    flag[idx] = False
    ans.append(b[idx])
for i in ans[::-1]:
    print(i)

Measured memory_bytes: 68676
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
int mod = 1000000007;
int main(void){
    int x;cin >> x;
    cout << 1-x << endl;
	return 0;
}



Measured memory_bytes: 3620
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    vector<bool> V(8, false);
    int N; cin >> N;
    int n_free=0;
    REP(i, N)
    {
        int a; cin >> a;
        if (1<=a && a<400) V[0] =true;
        else if (400<=a && a<800) V[1] =true;
        else if (800<=a && a<1200) V[2] =true;
        else if (1200<=a && a<1600) V[3] =true;
        else if (1600<=a && a<2000) V[4] =true;
        else if (2000<=a && a<2400) V[5] =true;
        else if (2400<=a && a<2800) V[6] =true;
        else if (2800<=a && a<3200) V[7] =true;
        else if (3200<=a) n_free++;
    }
    int min_ans, max_ans;
    int sum_V = accumulate(ALL(V),0);
    max_ans =sum_V+n_free;
    min_ans = max(sum_V, 1);
    cout << min_ans << " " << max_ans << endl;
  
    return 0;
}



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

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N, M;
int A[100010];
int B[100010];
vector<int> G[100010];
bool used[100010];

void rec(int pos, int par, vector<int> &v){
    used[pos] = true;
    v.push_back(pos);
    for(int to : G[pos]){
        if(used[to]) continue;
        if(to == par) continue;
        rec(to, pos, v);
        break;
    }
}

int main(){

    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]);
        G[B[i]].push_back(A[i]);
    }

    vector<int> v1, v2;
    // back
    {
        rec(0, -1, v1);
    }
    // front
    {
        used[0] = false;
        rec(0, -1, v2);
    }

    reverse(v1.begin(), v1.end());
    
    vector<int> ans = v1;
    for(int a : v2){
        if(a == 0) continue;
        ans.push_back(a);
    }
    
    cout << ans.size() << endl;
    for(int a : ans){
        cout << a + 1 << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 10896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
const int U=2e5+5;
 
int main() {
  int i,j,k;
  string ans="No";
  int bin[3][3];
  rep(i,3) rep(j,3) cin >> bin[i][j];
  int N; cin>>N; int b[N];
  rep(i,N){
    cin>>b[i];
    rep(j, 3) rep(k, 3) if (bin[j][k] == b[i]) bin[j][k] = 0;
  }
  rep(i,3) if(bin[i][0]==0&&bin[i][1]==0&&bin[i][2]==0) ans="Yes";
  rep(i,3) if(bin[0][i]==0&&bin[1][i]==0&&bin[2][i]==0) ans="Yes";
  if(bin[0][0]==0&&bin[1][1]==0&&bin[2][2]==0) ans="Yes";
  if(bin[2][0]==0&&bin[1][1]==0&&bin[0][2]==0) ans="Yes";
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    string ans = "Good";
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) ans = "Bad";
    cout << ans << endl;    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int x[5];
	for(int i = 0; i < 5; i++)
		cin >> x[i];

	for(int i = 0; i < 5; i++)
		if(x[i]==0)
		{
			cout<<i+1<<endl;
			break;
		}
	return 0;
}

Measured memory_bytes: 3188
import java.util.Scanner;

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

    public static void main(String[] args) {
        char[] cs = in.next().toCharArray();
        int[] a = new int[26];
        
        for(int i = 0; i < cs.length; i++){
            a[cs[i] - 'a']++;
        }
        boolean f = true;
        for(int i = 0; i < a.length; i++){
            if(a[i] % 2 == 1){
                f = false;
                break;
            }
        }
        System.out.println(f ? "Yes" : "No");
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<iomanip>
#include <cmath>
using namespace std;

using std::cout;
using std::cin;
using std::endl;

int main(void){
  string S;
  int N;
  cin >> N;
  cin >> S;
  for (int i = 0; i < S.length();i++){
   	 S.at(i) += N;
    if(S.at(i) > 90){
      S.at(i) -= 26;
    }
    cout << S.at(i);
  }
  
}
  

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

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

    vector<int> bList;
    for (int i = 0; i < n - 1; ++i)
    {
        int input;
        cin >> input;
        bList.push_back(input);
    }

    int sum = bList.at(0);
    for (int i = 1; i < n - 1; ++i)
    {
        sum += min(bList.at(i - 1), bList.at(i));
    }
    sum += bList.at(n - 2);

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e6 + 5;
const ll LINF = 1e18 + 5;
char s[N], t[N];
int n, m;
int nxt[N], in[N], dp[N];
bool ok[N];
vector <int> G[N];
void kmp_pre(char s[],int m,int nxt[])
{
	int i = 0, j = nxt[0] = -1;
	while(i<m)
	{
		while(j!=-1&&s[i]!=s[j]) j = nxt[j];
		nxt[++i] = ++j;
	}
}
void kmp_work(char s[],int m,char t[],int n) 
{
	int i = 0, j = 0;
	kmp_pre(s, m, nxt);
	while(i<n)
	{
		while(j!=-1&&t[i]!=s[j]) j = nxt[j];
		i++; j++;
		if(j>=m)
		{
			ok[i-m] = 1;
			j = nxt[j];
		}
	}
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> s >> t;
 	n = strlen(s), m = strlen(t);
 	int nn = n;
 	while(nn<n+m)
 	{
 		for(int i=nn, j=0; j<n; i++, j++) s[i] = s[j];
 		nn += n;
 		s[nn] = 0;
 	}
 	kmp_work(t, m, s, nn);
 	for(int i=0; i<n; i++)
 	{
 		if(ok[i] && ok[(i+m)%n]) 
 		{
 			in[(i+m)%n]++;
 			G[i].pb((i+m)%n);
 		}
 	}
 	queue <int> q;
 	for(int i=0; i<n; i++) 
 	{
 		if(!in[i]) 
 		{
 			q.push(i);
 			dp[i] = ok[i];
 		}
 	}
 	while(sz(q))
 	{
 		int u = q.front(); q.pop();
 		for(int v : G[u])
 		{
 			in[v]--;
 			if(!in[v])
 			{
 				q.push(v);
 				dp[v] = dp[u] + 1;
 			}
 		}
 	}
 	int ans = 0;
 	bool cycle = 0;
 	for(int i=0; i<n; i++) if(in[i]) cycle = 1;
 	if(cycle) ans = -1;
 	else ans = *max_element(dp, dp+n);
 	cout << ans;
	return 0;
}


Measured memory_bytes: 77312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    vector<ll> color(9);
    ll n; cin>>n;
    rep(i,n){
        ll a; cin>>a;
        chmin(a, 3599ll);
        color[a/400]++;
    }
    ll res=0;
    rep(i,8){
        if(color[i]>0) res++;
    }
    cout<<max(res, 1ll)<<' '<<res+color[8]<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

type part struct {
	category rune
	size     int
}

type parts []part
type byCategory struct{ parts }
type bySize struct{ parts }

func (p parts) Len() int                { return len(p) }
func (p parts) Swap(i, j int)           { p[i], p[j] = p[j], p[i] }
func (b byCategory) Less(i, j int) bool { return b.parts[i].category < b.parts[j].category }
func (b bySize) Less(i, j int) bool     { return b.parts[i].size < b.parts[j].size }

func main() {
	io := newIo()
	n := io.nextInt()

	seq := []part{}
	for i := range make([]struct{}, 3) {
		for range make([]struct{}, n) {
			seq = append(seq, part{rune('A' + i), io.nextInt()})
		}
	}
	sort.Stable(sort.Reverse(byCategory{seq}))
	sort.Stable(bySize{seq})

	var ans, i, j int
	for _, v := range seq {
		switch v.category {
		case 'A':
			i++
		case 'B':
			ans += i * (n - j)
		case 'C':
			j++
		}
	}
	fmt.Println(ans)
}

type io struct {
	reader    *bufio.Reader
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
	}
}

func (io *io) nextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) nextString() string {
	for io.nextToken >= len(io.tokens) {
		line := io.nextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) nextInt() int {
	i, _ := strconv.Atoi(io.nextString())
	return i
}


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

S = input()

num = []

for i in range(len(S) - 2):
    num.append(S[i] + S[i+1] + S[i+2])

num_int = list(map(int, num))

for i in range(len(num_int)):
    num_int[i] = abs(num_int[i] - 753)

output = min(num_int)

print(output)

Measured memory_bytes: 3060
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ld = long double;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e15;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_root_nodes = power(base, exponent / 2); return root_root_nodes * root_root_nodes % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
template<typename T, typename F> ll sum(T begin, T end, F func) {return accumulate(begin, end, 0ll, func);}
struct combination{ vector<ll> fact, inv; combination(int size) : fact(size + 1), inv(size + 1){ fact[0] = 1; for(int i = 1; i <= size; i++){ fact[i] = fact[i - 1] * i % mod; } inv[size] = power(fact[size], mod - 2); for(int i = size - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;

vector<vector<int>> g;
map<Pair, int> edge_no;
map<Pair, int> edge_co;

int dfs(int from_color, int current) {
  int color = 1;
  int max_c = color;
  for(auto next: g[current]) {
    if(color == from_color) color++;
    if(edge_co[{current, next}] > 0) {
      continue;
    }
    edge_co[{current, next}] = edge_co[{next, current}] = color;
    max_c = max(dfs(color, next), max_c);
    color++;
  }
  return max_c;
} 

signed main() {
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(12);
  ll n;
  cin >> n;
  g.resize(n);
  vector<int> a(n), b(n);
  REP(i, n-1) {
    int x, y;
    cin >> x >> y;
    x--;y--;
    g[x].push_back(y);
    g[y].push_back(x);
    a[i] = x;
    b[i] = y;
    edge_no[{x, y}] = i;
    edge_no[{y, x}] = i;
  }
  int k = dfs(0, 0);
  cout << max_element(all(edge_co), [](const auto& a, const auto& b){return a.second < b.second;})->second << endl;
  vector<int> ans(n-1);
  for(auto const& x: edge_co) {
    ans[edge_no[x.first]] = x.second;
  }
  REP(i, n-1) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 32256
#include <iostream>
#include <set>

using namespace std;

int main(void) {
    int a, b,c;
    set<int> st;
    cin >> a >> b >> c;
    st.insert(a);
    st.insert(b);
    st.insert(c);
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>

using namespace std;
using ll = long long;
const ll res = 1000000007;

int main() {
	int k;
	cin >> k;
	vector<ll> a{ 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 };
	cout << a[k-1] << endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  bool bl = true;
  rep(i, N) {
    if (A[i]%2 == 0 && (A[i]%3 != 0 && A[i]%5 != 0)) {
      bl = false;
    }
  }
  if (bl) puts("APPROVED");
  else puts("DENIED");
  return 0;
}

Measured memory_bytes: 3604
let [| S; T |] = stdin.ReadLine().Split()
let [| A; B |] = stdin.ReadLine().Split() |> Array.map int

stdin.ReadLine()
|> fun x ->
    match x with
    | x when x = S -> printfn "%d %d" (A - 1) B
    | x when x = T -> printfn "%d %d" A (B - 1)


Measured memory_bytes: 14160
lngs = input()

ACGT = ["A", "C", "G", "T"]
out_list = []
out_list_long = []


for lng in lngs:

    if lng in ACGT:
        out_list += lng
    else:
        if len(out_list) > len(out_list_long):
            out_list_long = []
            out_list_long = out_list
        out_list = []

if len(out_list) > len(out_list_long):
    out_list_long = []
    out_list_long = out_list

print(len(out_list_long))


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)



int main(){

    lli n;
    cin>>n;
    if(n==1)cout<<"Hello World"<<endl;
    else{
        lli a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;i++)
using ll =long long;
using namespace std;


int main() {
	int n, p;
	cin >> n >> p;
	string s;
	cin >> s;
	if (10 % p == 0) {
		ll ans = 0;
		rep(r, n) {
			if ((s[r] - '0') % p == 0) {
				ans +=r + 1;
			}
		}
		cout << ans << endl;
		return 0;
	}
	
	vector<int> d(n + 1);
	int ten = 1;
	for (int i = n - 1; i >= 0; --i) {
		int c = s[i] - '0';
		ll a = static_cast<ll>(c);
		a *= ten;
		a %= p;
		d[i] = (d[i+1] + a) % p;
		ten *= 10;
		ten %= p;
	}

	vector<int>cnt(p);
	ll ans = 0;
	for (int i = n; i >=0; --i) {
		ans += cnt[d[i]];
		cnt[d[i]]++;
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 1412
def main():
    N, A, B = map(int, input().split())
    X = list(map(int, input().split()))
 
    cost = 0
    for i in range(N-1):
        distance = abs(X[i] - X[i+1])
        if distance * A < B:
            cost += distance * A
        else:
            cost += B
    print(cost)
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 19996
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = Long.parseLong(sc.next());
    long j =1, min =N, x =N;
    for (long i =1; i<=Math.sqrt(N); i++) {
      if (N % i == 0) {
        j = N / i;
        x = F(i,j);
        min = Math.min(x,min);
      }
    }
    System.out.println(min);
  }
  
  public static int F(long a, long b) {
    String aa = String.valueOf(a);
    String bb = String.valueOf(b);
    return Math.max(aa.length(),bb.length());
  }
}

Measured memory_bytes: 23252
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    
    String S = sc.next();
    String T = sc.next();
    Boolean f = false;
    int l = S.length();
    
    for(int i=0; i<=l; i++) {
      if(S.equals(T)) {
        f = true;
        break;
      } else {
        S = S.substring(l-1, l) + S.substring(0, l-1);
      }
    }
    if(f) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 39336
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<(n);i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<iostream>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    int x, y, z, K;
    cin>>x>>y>>z>>K;

    vector <ll> a(x);
    vector <ll> b(y);
    vector <ll> c(z);

    rep(i, x){
        cin>>a[i];
    }
    rep(j, y){
        cin>>b[j];
    }
    rep(l, z){
        cin>>c[l];
    }

    sort(a.begin(), a.end(), greater<ll>());
    sort(b.begin(), b.end(), greater<ll>());
    sort(c.begin(), c.end(), greater<ll>());
    
    priority_queue <ll> q;

    rep(i, x){
            rep(j,y){
                int tmp_z=min(z, K/(i+1)/(j+1));
                rep(l, tmp_z){
                    q.push(a[i]+b[j]+c[l]);
                    
                }
            }
        }

    rep(i, K){
        cout<<q.top()<<endl;
        q.pop();
    }

    return 0;

}

Measured memory_bytes: 1532
#include<bits/stdc++.h>
using namespace std;
pair<int, int>l[100009], q[200009];
bool cmp(pair<int, int>&a, pair<int, int>&b) { return a.first < b.first; }
int main()
{
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) scanf("%d%d", &l[i].first, &l[i].second);
	for (int i = 1; i <= n; i++)q[i].first = q[i].second = i;
	sort(l + 1, l + m + 1, cmp);
	for (int i = 1; i <= m; i++) {
		int k = l[i].second;
		q[k].first = q[k + 1].first = min(q[k].first, q[k + 1].first);
		q[k].second = q[k + 1].second = max(q[k].second, q[k + 1].second);
	}
	for (int i = 1; i <= n; i++)printf("%d%c", q[i].second - q[i].first + 1, i == n ? '\n' : ' ');
}

Measured memory_bytes: 5540
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	long N,M; cin >> N >> M;
	long K; cin >> K;
	
	vector<long> A(N+1,0);
	for (int i = 1; i <= N; i++) {
		int a; cin >> a;
		A[i] = A[i-1] + a;
	}

	vector<long> B(M+1,0);
	for (int i = 1; i <= M; i++) {
		int b; cin >> b;
		B[i] = B[i-1] + b;
	}

	long ans = 0;
	long best = M;
	for (int i = 0; i <= N; i++) {
		if (A[i] > K) {
			break;	
		}
		
		while (0 < best and B[best] > K - A[i]) {
			best--;		
		}
		ans = max(ans, i+best);

	}
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 6436
#!/usr/bin python3
# -*- coding: utf-8 -*-

s = input()
t = input()
sl = len(s)
tl = len(t)

def cnt(a,b):
    ret = 0
    for i in range(len(a)):
        ret += a[i]!=b[i]
    return ret

ans = 1000
for i in range(sl-tl+1):
    ans = min(ans, cnt(s[i:i+tl], t))
print(ans)


Measured memory_bytes: 9040
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main(){
	int d;
	while(cin >> d){
		vector<int> sec;
		for(int i = d; i < 600; i += d){
			int y, z;
			y = i * i;
			z = y * d;
			sec.push_back(z);
		}
		int sum = accumulate(sec.begin(), sec.end(), 0);
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 
int main()
{
 int t; cin >> t;
 string s; int c1=0,c2=0,c3=0,c4=0;
 
 for(int i=0;i<t;i++){
     cin >>  s;
     if(s=="AC")c1++;
     else if(s=="WA")c2++;
     else if(s=="TLE")c3++;
     else c4++;
 }
 
     cout << "AC x " <<c1 <<endl;
     cout << "WA x " <<c2<<endl;
     cout << "TLE x "<<c3<<endl;
     cout << "RE x "<<c4<<endl;
 
   
}

Measured memory_bytes: 3628
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

immutable int INF = 114514810;

// ari 196
struct Edge {
    int to, cap, rev;
}
Edge[][] G;
bool[] used; // dfs したか

// 増加パスを探す
int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    foreach (ref e; G[v]) {
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

immutable int VMAX = 300;
int max_flow(int s, int t) {
    int flow;
    used.length = VMAX;
    while (1) {
        fill(used, false);
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
    assert(false);
}

void add_edge(int from, int to, int cap) {
    G[from] ~= Edge(to, cap, G[to].length.to!int);
    G[to]   ~= Edge(from, 0, G[from].length.to!int - 1);
}

struct Point { int x, y; }

void main() {
    int n = readint();
    G.length = VMAX;
    auto ps = new Point[2 * n];
    foreach (ref p ; ps) readf("%d %d\n", &p.x, &p.y);

    int s = 2 * n, t = s + 1;
    foreach (i; 0..n) {
        add_edge(s, i, 1);
        add_edge(n + i, t, 1);
    }
    foreach (i; 0..n) foreach (j; 0..n) {
        if (ps[i].x < ps[n + j].x && ps[i].y < ps[n + j].y)
            add_edge(i, n + j, 1);
    }

    writeln(max_flow(s, t));
}

Measured memory_bytes: 508
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

typedef long long ll;

int GCD(int a, int b) {
  return b ? GCD(b ,a%b) : a;
}

int main() {
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin>>A[i];
  vector<int> L(N+1,0),R(N+1,0);
  L[0] = R[N] = 0;
  for(int i = 0; i < N; i++) L[i+1] = GCD(L[i],A[i]);
  for(int i = N-1; i >= 0; i--) R[i] = GCD(R[i+1],A[i]);
  int ans; ans = 0;
  for (int i = 0; i < N; i++) ans = max(ans,GCD(L[i],R[i+1]));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1408
L,R=map(int,input().split())
if R-L >= 2018:
    print(0)
else:
    m=float('inf')
    for i in range(R-L):
        for j in range(R-L-i):
            m=min(m,(i+L)*(i+L+j+1)%2019)
    print(m)


Measured memory_bytes: 41836
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int sum=0;
	for(int i=0;i<s.size();i++){
		if(s[i] == 'o')sum+=1;
		
	}
	sum+= 15-s.size();
	if(sum>=8)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	map<ll, ll> mp;
	REP(i, N){
		ll x;
		cin >> x;
		mp[x]++;
	}
	ll M;
	cin >> M;
	REP(i, M){
		ll x;
		cin >> x;
		if(mp[x]==0){
			cout << "NO" << endl;
			return 0;
		}
		mp[x]--;
	}
	cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 12800
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,s,a[200040];
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k>>m;
	n=abs(n);
	if(n/m>=k)cout<<n-k*m;
	else
	{
		if(n/m-k&1)cout<<abs(n%m-m);
		else cout<<n%m;
	}
}

Measured memory_bytes: 3652