akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
  int A, B;
  cin >> A >> B;
  int socket_num = 1;
  int count = 0;
  while(socket_num < B){
    --socket_num;
    socket_num += A;
    ++count;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <ctime>
#include <climits>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <cstdlib>

using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
long int limit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

//最大limit
//10^9+7    pow107
//素数pn
//n乗jou
//コンビネーションfactorial
//

int main(){
    long int n , k , t = 0;
    cin >> n >> k;
    vector<pair<int, int> > v;
    for(int i = 0; i < n; ++i){
        int a,b;
        cin >> a >> b;
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(),v.end());
    int i = 0;
    while(i < n && t < k){
        t += v[i].second;
        if(t >= k){
            cout << v[i].first << endl;
        }
        ++i;
    }
}

Measured memory_bytes: 1400
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var line = new int[5];
            for(int i = 0; i < 5; i++)
            {
                line[i] = int.Parse(Console.ReadLine());
            }
            int k = int.Parse(Console.ReadLine());
            Console.WriteLine(line[4] - line[0] <= k ? "Yay!" : ":(");
        }
    }
}

Measured memory_bytes: 13140
<?php

fscanf(STDIN, "%s", $str1);
fscanf(STDIN, "%s", $str2);
fscanf(STDIN, "%s", $str3);

$arr1 = str_split($str1);
$arr2 = str_split($str2);
$arr3 = str_split($str3);

$str = $arr1[0].$arr2[1].$arr3[2];



out::println($str);

class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}



?>


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

#define ll long long
#define ull unsigned long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;

int main(){
    int a[] = {1, 3, 5, 7, 8, 10, 12};
    int b[] = {4, 6, 9, 11};
    int m, n;
    cin >> m >> n;
    if(m == 2 || n == 2){
        cout << "No";
    }
    else{
        if(!(binary_search(a, a+7, m) ^ binary_search(a, a+7, n))){
            cout << "Yes";
        }
        else{
            cout << "No";
        }
    }
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <algorithm>
using namespace std;
int main(){
    long long K;
    cin >> K;
    long long ans = 0;
    for(int i = 1; i < K + 1; i++){
        for(int j = 1; j < K + 1; j++){
            for(int k = 1; k < K + 1; k++){
                ans += gcd(i, gcd(j, k));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3672
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 17 10:26:25 2020

@author: 17664
"""

balls = {}
s, t = input().split()
balls[s], balls[t] = [int(num) for num in input().split()]
balls[input()] -= 1

print(balls[s], balls[t])


Measured memory_bytes: 2940
def C_DividetheProblems():
    N = int(input())
    d = list(map(int, input().split()))
    d.sort()
    ans = 0
    mod = N // 2
    ans = d[mod] - d[mod-1]
    print(ans)

if __name__ == "__main__":
    C_DividetheProblems()

Measured memory_bytes: 13992
function Main(input){
	var xs = input.trim().split('').map(v=>parseInt(v,10));
    var ans = 0;
    for(var i =0; i<xs.length; i++){
    	if(xs[i]==9){
        ans += 1;
        }else{
        ans += 0;
        }
    }
    if(ans !=0){
    console.log('Yes');
    }else{
    console.log('No');
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
static const double pi=3.141592653589793238462643383279;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int n;
    cin >> n;
    if(n<1000) cout << "ABC" << endl;
    else cout << "ABD" << endl;
}

Measured memory_bytes: 256
#入力した文書の中にアルファベット数字をいくつはいっているかをわかるプログラム
text = gets("").downcase    #テキストに小文字をとる

for alphabet in "a".."z"           #sをA から　Zまで２６回繰り返す
  puts "#{alphabet} : #{text.count(alphabet)}"      #まずAからZまで繰り返して　テキストの中のアルファベットをカウントする
end


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

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

int H,W;
int fld[10][10];
int lim;
bool change(int y,int x,int c,int f){
    fld[y][x]=c;
    for(int d=0;d<4;d++){
        int ny=y+dy[d],nx=x+dx[d];
        if(ny<0||ny>=H||nx<0||nx>=W||fld[ny][nx]!=f)continue;
        change(ny,nx,c,f);
    }

}

bool dfs(int t=0){
    if(lim==t){
        bool ok=true;
        for(int i=0;i<H;i++)for(int j=0;j<W;j++){
            if(fld[0][0]!=fld[i][j])ok=false;
        }
        return ok;
    }

    int _fld[10][10];
    memcpy(_fld,fld,sizeof(_fld));

    bool ret=false;
    for(int k=0;k<3;k++)if(k!=fld[0][0]){
        change(0,0,k,fld[0][0]);
        ret|=dfs(t+1);
        memcpy(fld,_fld,sizeof(fld));
    }

    return ret;
}
int main(){
    while(cin>>W>>H,W||H){
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                char c;
                cin>>c;
                switch(c){
                case 'R':fld[i][j]=0;break;
                case 'G':fld[i][j]=1;break;
                case 'B':fld[i][j]=2;break;
                }
            }
        }

        for(lim=0;;lim++)if(dfs())break;
        cout<<lim<<endl;
    }

    return 0;
}

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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
#define size(v) (signed)v.size()
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
    #define debug true
    #define ln << endl
#else
    #define debug false
    #define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '

signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    int N;
    scanf("%d", &N);
    int A[100000];
    times(N, i) scanf("%d", &A[i]);
    sort(A, A + N);

    int l = 0, r = N;
    times(100, o_) { // 100回: max/EPS <= 1e30
        int i = (l + r) / 2;
        long k = A[i];
        times(i, j) k += A[j];
        bool f = true;
        uptil(i+1, N, j) {
            if(A[j] > 2*k) f = false;
            k += A[j];
        }

        if(debug) cout << i << ":" << f sp;

        if(f) r = i;
        else  l = i;
    }

    cout << N - r ln;

    return 0;
}


Measured memory_bytes: 640
import bisect

#動的計画法だった
N = int(input())
ue = (list(map(int, input().split())))
mid = (list(map(int, input().split())))
bot = (list(map(int, input().split())))
ue.sort()
mid.sort()
bot.sort()

ans = 0
for i in mid:
    ans += bisect.bisect_left(ue, i) * (len(bot) - bisect.bisect_right(bot, i))
print(ans)


Measured memory_bytes: 23360
# nの約数を求める
def divisor(n):
    d = []
    for i in range(int(n**(0.5)+1))[1:]:
        if n % i == 0:
            d.append(i)
            if i * i != n:
                d.append(int(n / i))
    return d


N, M = map(int, input().split())
# d はnの約数のベクター
d = divisor(M)
g = int(M / N)
d = [x for x in d if x <= g]
print(max(d))


Measured memory_bytes: 38896
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
 
 
using namespace std;
 
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
 
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}
 
#define int long long
#define left left228
#define right right228
#define prev prev228
#define list list228
#define mp make_pair
#define all(v) v.begin(), v.end()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define firn(i, n) for (int i = 1; i < (int)n; ++i)
#define x first
#define y second

const int N = 100 * 1000 + 228;

vector<int> g[N];
int color[N];
bool bip = 1;
int sz = 0;

void dfs(int v, int col = 1) {
    color[v] = col;
    ++sz;
    for (int to : g[v]) {
        if (!color[to]) {
            dfs(to, 3 - col);
        }
        if (color[to] == color[v]) {
            bip = 0;
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v); g[v].push_back(u);
    }
    int one = 0, two = 0;
    int isol = 0;
    for (int i = 1; i <= n; ++i) {
        if (!color[i]) {
            bip = 1;
            sz = 0;
            dfs(i);
            if (sz == 1) {
                ++isol;
            } else {
                if (bip) {
                    ++two;
                } else {
                    ++one;
                }
            }
        }
    }
    cout << one * one + (one + two) * two * 2 + isol * (n - isol) * 2 + isol * isol << '\n';
    return 0;
}


Measured memory_bytes: 11520
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner s=new Scanner(System.in);
		
		int N=s.nextInt();//学生
		int M=s.nextInt();//チェックポイント
		long a[]=new long[N];//学生の位置
		long b[]=new long[N];
		long c[]=new long[M];//チェックポイントの位置
		long d[]=new long[M];
		long min=0;
		int l=0;
		
		int i=0,j=0;
		
		for(i=0;i<N;i++){
			a[i]=s.nextInt();
			b[i]=s.nextInt();
		}
		for(i=0;i<M;i++){
			c[i]=s.nextInt();
			d[i]=s.nextInt();
		}
		
	    for(i=0;i<N;i++){
	    	min=Math.abs(a[i]-c[0])+Math.abs(b[i]-d[0]);
	    	l=0;
	    	for(j=0;j<M;j++){
	    		if(min>Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j])){
	    			min=Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j]);
	    			l=j;
	    		}
	    	}
	    	System.out.println(l+1);
	    	
	    }

	}

}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
#pragma GCC target ("sse4.2")
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define time cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";


int main()
{


    fast;

    lli a,b;
    cin>>a>>b;
    //cout<<a<<b;
    string s="",s1="";
    char x=a+'0';
    char y=b+'0';
    //cout<<x<<y;
    for(lli i=0;i<a;i++)
    {
        s+=y;
    }
    for(lli i=0;i<b;i++)
    {
        s1+=x;
    }
    //cout<<s<<" "<<s1<<"\n";






    if(s>s1)
        cout<<s1;
    else
        cout<<s;











    return 0;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		String s;
		int m, h;
		Scanner sc = new Scanner(System.in);
		while (true) {
			s = sc.next();
			if(s.equals("-"))
				break;
			m = sc.nextInt();
			for(int i = 0; i < m; i ++){
				h = sc.nextInt();
				s = s.substring(h) + s.substring(0, h);
			}
			System.out.println(s);
		}
	}

}

Measured memory_bytes: 18284
import bisect
N=int(input())
A=[int(x) for x in input().split()]
A=sorted(A)
maxA=max(A)
ans=0
so_list=[1]*(maxA+1)
index=0
i=0

while(i<N):
    flag=0
    now=A[i]
    if so_list[now]==1:
        index=0
        flag=1
        while(index+now<=maxA):
            so_list[index+now]=0
            index+=now
    right=bisect.bisect_right(A,now)#同じ数字はいくつある？
    if right-i==1:
        if flag==1:
            ans+=1
            #print(now)
        i=right
    else:
        i+=1

print(ans)

Measured memory_bytes: 32020
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 506
using namespace std;
int m,p1,p2,a[N],b[N],ans[N];long long n;
int main()
{
	scanf("%lld",&n);n++;m=100;
	while(n>1){
		if(n&1)n--,a[++p1]=m--;
		else n>>=1,b[++p2]=m--;
	}
	printf("%d\n",2*(p1+p2));
	for(int i=1;i<=p1;i++)printf("%d ",a[i]);
	for(int i=p2;i>=1;i--)printf("%d ",b[i]);
	for(int i=100-p1-p2+1;i<=100;i++)printf("%d ",i);puts("");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main() {
	int a, b, c, x;
	scanf("%d%d%d%d", &a, &b, &c, &x);
	int ans = 0;
	for (int i = 0; i <= a; ++i) {
		for (int j = 0; j <= b; ++j) {
			for (int k = 0; k <= c; ++k) {
				if (i * 500 + j * 100 + k * 50 == x) ans++;
			}
		}
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });            var N = Sarray()[0];
            var N = Sarray()[0];
            var Ai = Sarray();
            var max = Ai.Max();
            var min = Ai.Min();
            long ans = 200 * 200 * 100;
            for (var i = min; i <= max;++i)
            {
                var sum = 0L;
                foreach(var a in Ai)
                    sum += (a - i) * (a - i);
                ans = Min(ans, sum);
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>

typedef struct re {
    int adj[500];
    int cnt;
} graph;

graph g[100100];
int dp[100100];

int max(int a, int b) {
    return (a > b ? a : b);
}

int cal(int v) {
    if (!dp[v]) {
        for (int i = 0; i < g[v].cnt; i++) {
            dp[v] = max(dp[v], cal(g[v].adj[i]));
        }
        dp[v]++;
    }
    return dp[v];
}

int n, m;
 
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) {
        g[i].cnt = 0; 
    }

    for (int i = 0; i < m; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        u--, v--;
        g[u].adj[g[u].cnt++] = v;
    }

    int res = 0;
    for (int i = 0; i < n; i++) res = max(res, cal(i));

    printf("%d\n", res - 1);
}

Measured memory_bytes: 198272
import fractions
 
def gcd(a,b):
    return fractions.gcd(a,b)
a,b,c,d = map(int, input().split())

cd = gcd(c,d)
cd = c*d //cd
c_able = b//c - (a-1)//c
d_able = b//d - (a-1)//d
cd_able = b//(cd) - (a-1)//(cd)

print(b- a + 1 - (c_able + d_able - cd_able))

Measured memory_bytes: 5048
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N;
	cin >> N;
	int A[100000];
	for(int i=0; i<N; i++) cin >> A[i];
	sort(A,A+N);
	if(N%2 == 0){
		for(int i=0; i<N; i++){
			if(A[i] != (i/2)*2+1){
				cout << 0 << endl;
				return 0;
			}
		}
		int ans = 1;
		for(int i=0; i<N/2; i++){
			ans *= 2;
			ans %= MOD;
		}
		cout << ans << endl;
	}
	else{
		for(int i=0; i<N; i++){
			if(A[i] != ((i+1)/2)*2){
				cout << 0 << endl;
				return 0;
			}
		}
		int ans = 1;
		for(int i=0; i<N/2; i++){
			ans *= 2;
			ans %= MOD;
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll read(){ll x=0,f=1;char ch=getchar();for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-48;return x*f;}
inline void write(ll x){if(x>9)write(x/10);putchar('0'+x%10);}
inline void writeln(ll x){write(x);puts("");}
ll n;
ll ans=1,x;
ll gcd(ll a,ll b)
{
	if(b==0)return a;
	return gcd(b,a%b);
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++){
		x=read();
		ans=ans/gcd(ans,x)*x;
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
    ull n,ans;
    while(cin >> n && n){
      vector<ull> m(n);
      rep(i,n) cin >> m[i];
      sort(all(m));
      ans=0;
      rep(i,n) ans+=m[i]*(n-i-1);
      cout <<  ans << endl;
      m.clear();
    }
}

Measured memory_bytes: 1276
//
//AOJ volume11 1130
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1130&lang=jp
//20170605
//640009E
//Yang Bo
//

#include <iostream>
#include <vector>

using namespace std;

int w, h;
int starty, startx;
vector< vector<char> > a(20, vector<char>(20, 'a')); //??£??\??????

int recursion(char iny, char inx)
{
  a[iny][inx] = '#';
  int number = 0;
  if (inx < w - 1)
    if (a[iny][inx + 1] == '.')
      number += recursion(iny, inx + 1);
  if (iny < h - 1)
    if (a[iny + 1][inx] == '.')
      number += recursion(iny + 1, inx);
  if (inx > 0)
    if (a[iny][inx - 1] == '.')
      number += recursion(iny, inx - 1);
  if (iny > 0)
    if (a[iny - 1][inx] == '.')
      number += recursion(iny - 1, inx);
  number += 1;
  return number;
  //cout << " recursion(" << iny << ", "<< inx << ") = " << number << endl; 
}

int main()
{
  while (cin >> w >> h) {
    if (w == 0)
      break;
    else {
      for (int i = 0; i < h; i++) {
	for (int j = 0; j < w; j++) {
	  cin >> a[i][j]; //??\???
	  if (a[i][j] == '@') {
	    starty = i;
	    startx = j;
	    //cout << "i = " << i << ", j = " << j << endl;
	  }
	}
      }
      int ans = recursion(starty, startx);
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <array>

using namespace std;

#define forange(counter, end) forstep(counter, 0, end)
#define forstep(counter, begin, end) forstep_type(size_t, counter, begin, end)
#define forange_type(type, counter, end) forstep_type(type, counter, 0, end)
#define forstep_type(type, counter, begin, end) for (type counter = begin, forstep_type_end_##counter = end; counter < forstep_type_end_##counter; counter++)

const int D = 365;
const int C = 26;

array<int, C> contest;
array<array<int, C>, D> satisfaction;

int decr(const int c, const int last, const int now) {
	return contest[c] * (now - last);
}

int getScore(const array<int, C>& last, const int open, const int day) {

	int score = 0;

	forange(c, C)
	{
		if (c == open)
		{
			score += satisfaction[day][c];
		}
		else
		{
			score -= decr(c, last[c], day);
		}
	}

	return score;
}

array<int, D> think() {

	array<int, D> cont;
	cont.fill(0);

	array<int, C> last;
	last.fill(0);

	forange(d, D)
	{
		int maxC = 0;
		int maxScore = getScore(last, maxC, d);

		forstep(c, 1, D)
		{
			int score = getScore(last, c, d);

			if (maxScore < score)
			{
				maxC = c;
				maxScore = score;
			}
		}

		last[maxC] = d;
		cont[d] = maxC;
	}

	return cont;
}

int main() {

	int d;
	cin >> d;

	for (auto& c : contest)
	{
		cin >> c;
	}

	forange(d, D)
	{
		forange(s, C)
		{
			cin >> satisfaction[d][s];
		}
	}

	const auto ans = think();

	for (const auto& a : ans)
	{
		cout << (a + 1) << endl;
	}

	return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,a,b,c,d;
int main()
{
    cin>>n;
    a=n/1000;
    b=(n%1000)/100;
    c=(n%100)/10;
    d=n%10;
    if(b==a&&b==c)
    {
        cout<<"Yes"<<endl;
    }
    else if(c==b&&c==d)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;


signed main() {
    int N, D;
    cin >> N >> D;
    int ans = 0;
    REP(i, N) {
        int x, y;
        cin >> x >> y;
        if(x * x + y * y <= D * D) {
            ++ans;
        }
    }
    out(ans);
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<pair<double,int>> finalist;
  vector<pair<double,int>> rest;
  rep(i,3){
    vector<pair<double,int>> list(8);
    rep(j,8){
      cin >> list[j].se >> list[j].fi;
    }
    sort(all(list));
    finalist.pb(list[0]);
    finalist.pb(list[1]);
    REP(i,2,8){
      rest.pb(list[i]);
    }
  }
  sort(all(rest));
  finalist.pb(rest[0]);
  finalist.pb(rest[1]);
  rep(i,8){
    fcout(2) << finalist[i].se << " " << finalist[i].fi<<endl;
  }
  return 0;
}

Measured memory_bytes: 3124
k, s = gets.chomp.split(" ").map(&:to_i)

count = 0
xStart = (s-2*k < 0) ? 0 : (s-2*k)
xEnd = (s < k) ? s : k
for x in xStart..xEnd do
  yStart = (s-x-k < 0) ? 0 : (s-x-k)
  yEnd = (s < x+k) ? (s-x) : k
  for y in yStart..yEnd do
    z = s-x-y
    count += 1 if 0 <= z && z <= k
  end
end
puts count

Measured memory_bytes: 14320
S = input()
ans = len(S)
cntS = 0
for i in range(len(S)):
    if (S[i] == 'S'):
        cntS += 1
    else:
        if (cntS > 0):
            cntS -= 1
            ans -= 2
        else: cntS = 0
print(ans)

Measured memory_bytes: 3500
import collections
N = list(input())
cnt = 0
ans = []
for i in range(len(N)-1):
    if N[i] == N[i+1]:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
ans.append(cnt)
for i in ans:
    if i >= 2:
        print('Yes')
        exit()
print('No')  

Measured memory_bytes: 3316
#include<stdio.h>

int main (void){
	
	int x,n[10000];
	int i,j;
	for(i=0;i<10000;i++){
		scanf("%d",&x);
		n[i]=x;
		if(n[i]==0){
			break;
		}
	}
	
	for(j=1;j<=i;j++){
		printf("Case %d: %d\n",j,n[j-1]);
	}
	return 0;
}
		

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <string>
using namespace std;
string a[2];
int main()
{
	ios_base::sync_with_stdio(false);
	long long N,left,right,mid;
	string s;
	cin>>N;
	cout<<0<<"\n";
	cin>>s;
	if(s=="Vacant")
		return 0;
	else if(s=="Male")
	{
		a[0]="Male";
		a[1]="Female";
	}
	else
	{
		a[0]="Female";
		a[1]="Male";
	}
	left=1;
	right=N-1;
	while(left<=right)
	{
		mid=(left+right)/2;
		cout<<mid<<"\n";
		cin>>s;
		if(s=="Vacant")
			return 0;
		else if(s==a[mid%2])
		{
			left=mid+1;
		}
		else
			right=mid-1;
	}
	return 0;
}




Measured memory_bytes: 852
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<string> a(n), b(m);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> b[i];
  for (int i = 0; i + m <= n; i++) {
    for (int j = 0; j + m <= n; j++) {
      bool ok = true;
      for (int ii = 0; ii < m; ii++) {
        for (int jj = 0; jj < m; jj++) {
          if (a[i + ii][j + jj] != b[ii][jj]) {
            ok = false;
          }
        }
      }
      if (ok) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
bool pr[1000007];
void sieve(){pr[0]=1;pr[1]=1;for(int i=2;i<sqrt(1000007);i++){for(int j=2*i;j<=1000007;j+=i){pr[j]=1;}}}
ll fashtpower(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x;res%=MOD;y=y>>1;x=x*x;x%=MOD;}return res;}
ull lopow(ll x,ll y){ull res=1ULL;while(y){if(y&1)res*=(ull)x;y>>=1;x*=x;}return res;}
map<ll,ll> m;
int main(){
	ios_base::sync_with_stdio(0);
		int n;
		cin>>n;
		for(int i=0;i<n;i++){
			ll a,b;
			cin>>a;
			m[a]++;
		}
		
map<ll,ll> :: iterator itr;
ll ans=0;
for(itr=m.begin();itr!=m.end();itr++){
	ans+=(*itr).se%2;
}	cout<<ans;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

const int mod = 1000000007;

long long frac(long long n) {
  if(n==1) return 1;
  return (n*frac(n-1))%mod;
}

int main() {
  int n;
  long long ans = 1;
  string s;
  cin >> n;
  cin >> s;
  n *= 2;
  vector<bool> cell(n);

  for (int i=0; i<n; i++) {
    cell[i] = (s[i] == 'B');
    if(!(i%2)) cell[i] = !cell[i];
    // cout << cell[i] << " ";
  } //cout << endl;

  int cnt = 0;
  for (int i=0; i<n; i++) {
    if(!cell[i]) cnt++;
    else {
      if(!cnt) {
        puts("0");
        return 0;
      }
      else {
        // cout << "*" << cnt << endl;
        ans *= cnt--;
      }
    }
    ans %= mod;
  }
  ans *= frac(n/2);
  ans %= mod;
  cout << (cnt ? 0 : ans) << endl;
}


Measured memory_bytes: 2172
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
        int i;
        String s[] = new String[n];
        int c[] = new int[4];
		for(i = 0;i < n; i++){
        	s[i] =   sc.next();
        }
      	for(i = 0;i < n; i++){
        	if(s[i].equals("AC")){
              c[0] += 1;
            }else if(s[i].equals("WA")){
              c[1] += 1;
            }else if(s[i].equals("TLE")){
              c[2] += 1;
            }else if(s[i].equals("RE")){
              c[3] += 1;
            }
        }
        System.out.println("AC" + " x " + c[0]);
        System.out.println("WA" + " x " + c[1]);
        System.out.println("TLE" + " x " + c[2]);      
        System.out.println("RE" + " x " + c[3]);     
      
    }
}

Measured memory_bytes: 64648
#include <bits/stdc++.h>
#define K 38
#define N 1407
using namespace std;

vector<int> bp[N+100]; int tot=K;
int main()
{
	printf("%d %d\n",N,K);
	for(int i=1;i<=K;i++) bp[i].push_back(1);
	for(int i=2;i<=tot;i++) bp[1].push_back(i);
	for(int i=2;i<=K;i++)
		for(int j=1;j<K;j++)
			bp[(i-1)*(K-1)+1+j].push_back(i);
	for(int i=2,gp=0;i<=K;i++,gp++)
	{
		for(int j=2;j<=K;j++)
		{
			bp[i].push_back(++tot);
			for(int t=2,p=j-1;t<=K;t++,p+=gp,p=(p%(K-1)==0? K-1:p%(K-1)))
				bp[(t-1)*(K-1)+1+p].push_back(tot);
		}
	}
	for(int i=1;i<=N;i++)
	{
		for(int j=0;j<bp[i].size();j++)
			printf("%d ",bp[i][j]);
		puts("");
	}

}

Measured memory_bytes: 896
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    char str[5]={0};
    scanf("%s", str);
    sort(str+0, str+4);
    if(str[0]==str[1] && str[2]==str[3] && str[1]!=str[2]) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


std::map<long long, int> prime_factors(long long n) {
  std::map<long long, int> map;

  for (long long i = 2; i * i <= n; i ++)
    for ( ; n % i == 0; n /= i)
      map[i] ++;

  if (n != 1)
    map[n] = 1;

  return std::move(map);
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  long long N, P;

  std::cin >> N >> P;

  std::map<long long, int> map = prime_factors(P);

  long long lcm = 1;

  for (const auto& kv : map)
    for (int c = kv.second; c >= N; c -= N)
      lcm *= kv.first;

  std::cout << lcm << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    ll A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;

    ll p=0,q=100*A;

    for(int a=0; a<=30; a++)
    {
        for(int b=0; b<=30; b++)
        {
            ll water=a*100*A+b*100*B;
            ll mx_sugar=water*E/100;
            if(water<=F)
            {
                ll baki=min(F-water,mx_sugar);
                for(int c=0; c*C<=baki; c++)
                {
                    ll sugar=c*C;
                    ll extra=(baki-sugar)/D;
                    extra*=D;
                    sugar+=extra;
                    if(sugar*q>water*p)
                    {
                        p=sugar;
                        q=water;
                    }
                }

            }
        }
    }
    cout<<q+p<<' '<<p;
}



Measured memory_bytes: 3636
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( '\n' );
  var output = [];
  for( var index=0; index<data.length; index++ ) {
    var nums = data[index].split( ' ' ).map( Number );
    if( 0 == nums[0] && 0 == nums[1] ) { break; }
    
    var row = [];
    var r = Array( nums[1]+1 ).join( '#' )+'\n';
    var r2 = '#'+Array( nums[1]-1 ).join( '.' )+'#'+'\n';
    row.push( r );
    for( var i=0; i<nums[0]-2; i++ ) {
      row.push( r2 );
    }
    row.push( r );
    output.push( row.join( '' ) );
  }
  console.log( output.join( '\n' )  );
});

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

int main() {
  int aliceCard,bobCard;
  
  cin >> aliceCard >> bobCard;
  
  if(aliceCard == 1) aliceCard += 13;
  if(bobCard == 1) bobCard += 13;
  
  if(aliceCard > bobCard) cout << "Alice";
  else if(aliceCard < bobCard) cout << "Bob";
  else cout << "Draw";
}


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

#define reb(i,b,n) for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n) reb(i,0,n)
#define rreb(i,b,n) for(int i = b-1; i >= n; i--)
#define rrep(i,n) reb(i,n,0)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v) for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vall(x) (x).begin(), (x).end()
#define rvall(x) (x).rbegin(), (x).rend()
#define vsort(v) sort(vall(v))
#define rvsort(v) sort(rvall(v))
#define len(array) (sizeof (array) / sizeof *(array))
#define aall(x) x, x+len(x)
#define asort(x) sort(aall(x))
#define rasort(a, type) sort(aall(a), greater<type>())
#define afill(a, v) fill(aall(a), v)
#define afill2(a, v, type) fill((type *)a, (type *)(a + len(a)), v)
#define sz(x) (int)(x).size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pb push_back
#define _USE_MATH_DEFINES
#define priArr(table, n) rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define priAr2(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;

using namespace std;
using std::stringstream;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class F, class T> inline void convert(const F &f, T &t){stringstream ss;ss<<f;ss>>t;}
template<class T> inline T sqr(T x) {return x*x;}

typedef long long ll; typedef unsigned long long ull;
typedef pair <int, int> P; typedef pair <int, P> PP;
typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<string> vs;
typedef vector<ll> vl; typedef vector<P > vP; typedef vector<char> vc;
typedef long double ld;

const static int INF = 0x3f3f3f3f;
const static ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const static double EPS = 1e-9;
const static ll MOD = 1000000007LL;

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

int main(int argc, char *argv[])
{
    int a, b;
    string s;
    string ans="Yes";

    cin >> a >> b >> s;

    for (int i=0; i<s.size(); i++) {
        if (i<a || i > a) {
            if (s[i] == '-') {
                ans = "No";
                break;
            }
        } else {
            if (s[i] != '-') {
                ans = "No";
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

ll GetMinValue(ll x, ll k, ll d)
{
	x = abs(x);
	ll n = x / d;
	if (k < n) return x - k * d;
	else if (n == k) {
		return x - n * d;
	}
	else if (n < k) {
		if (n % 2 == k % 2) return x - n * d;
		else return min(x - (n - 1) * d, abs(x - (n + 1) * d));
	}
}

int main()
{
	ll x, k, d;
	cin >> x >> k >> d;
	if (x == 0) {
		if (k % 2 == 0) cout << 0 << endl;
		else cout << d << endl;
	}
	else cout << GetMinValue(x, k, d) << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int main(){
	

	int t = 1;
	//cin >> t;
	while(t--){
		int n, m;
		cin >> n >> m;
		if(n == m) cout << "Yes";
		else cout << "No";	
	}
	return 0;
}

Measured memory_bytes: 256
S = input()
flag = 0
for i in range(len(S)):
	if i%2 == 0 and S[i] != 'h':
		flag = 1
	if i%2 == 1 and S[i] != 'i':
		flag = 1
if flag == 1 or len(S)%2 == 1:
	print('No')
else:
	print('Yes')

Measured memory_bytes: 38256
#include <stdio.h>

 #define MAX 100000

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

int parent(int i){return i/2;}

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

int main(){
  int H,i,A[MAX+1];

  scanf("%d",&H);

  for(i=1;i<=H;i++)
    scanf("%d",&A[i]);
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1)
      printf("parent key = %d, ",A[parent(i)] );
    if(left(i)<=H)
      printf("left key = %d, ",A[left(i)]);
    if(right(i)<=H)
      printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }

  return 0;}



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

const int max_S=1e5+10;

int s[max_S];

int main(){
    for(int i=0; i<max_S; i++){
        s[i]=0;
    }
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int q;
    cin >> q;
    int b[q], c[q];
    for(int i=0; i<q; i++){
        cin >> b[i] >> c[i];
    }
    for(int i=0; i<n; i++){
        s[a[i]]++;
    }
    long long sum=0;
    for(int i=0; i<n; i++){
        sum+=a[i];
    }
    for(int i=0; i<q; i++){
        sum+=s[b[i]]*(c[i]-b[i]);
        s[c[i]]+=s[b[i]];
        s[b[i]]=0;
        
        cout << sum << endl;
    }
    return 0;

}

Measured memory_bytes: 5172
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
ll tako[55]={0};
int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++) cin>>tako[i];
  ll ans=0;
  for(int i=1;i<n;i++){
    for(int j=i+1;j<=n;j++) ans+=tako[i]*tako[j];
  }
  cout<<ans<<endl;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

ll N, K;
vector<ll> neg;
vector<ll> negr;
vector<ll> pos;
vector<ll> posr;

// 積が x 未満になるような組み合わせの個数を返す
ll solve(ll x) {
    ll ans = 0;

    // 負 * 正
    for (int i = 0; i < neg.size(); ++i) {

        ll left = -1; // ここを-1にすると、全部がxをオーバーしているか確認できる
        ll right = posr.size();

        while (right - left > 1) {
            ll mid = (right - left) / 2 + left;

            // 全部が該当するケース
            if (mid < 0) {
                left = mid;
            }

            else {
                if (neg[i] * posr[mid] >= x) right = mid;
                else left = mid;
            }
        }

        ans += right;
    }

    // 負 * 負
    for (int i = 0; i < negr.size(); ++i) {

        ll left = i;
        ll right = negr.size();

        while (right - left > 1) {
            ll mid = (right - left) / 2 + left;

            if (mid <= i) {
                left = mid;
            }
            else {
                if (negr[i] * negr[mid] >= x) {
                    right = mid;
                }
                else {
                    left = mid;
                }
            }

        }

        ans += left - i;
    }

    // 正 * 正
    for (int i = 0; i < pos.size(); ++i) {

        ll left = i;
        ll right = pos.size();

        while (right - left > 1) {
            ll mid = (right - left) / 2 + left;

            if (pos[i] * pos[mid] >= x) {
                right = mid;
            }
            else {
                left = mid;
            }

        }

        ans += left - i;
    }

    return ans;
}

int main(void) {

    cin >> N >> K;
    rep(i, N) {
        ll a;
        cin >> a;
        if (a < 0) {
            neg.push_back(a);
            negr.push_back(a);
        }
        else {
            pos.push_back(a);
            posr.push_back(a);
        }
    }

    sort(ALLOF(pos));
    sort(ALLOF(neg));
    sort(ALLOF(posr));
    reverse(ALLOF(posr));
    sort(ALLOF(negr));
    reverse(ALLOF(negr));

    ll left = -2000000000000000005LL;
    ll right=  2000000000000000005LL;
    while (right - left > 1) {
        ll mid = (right - left) / 2 + left; // x

        ll ans = solve(mid);

        if (ans >= K) {
            right = mid;
        }
        else {
            left = mid;
        }

    }

    cout << left << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	int ma, mi, a, b, c;
	cin >> a >> b >> c;
	ma = max(max(a,b),c);
	mi = min(min(a,b),c);

	cout << ma - mi << "\n";

	return 0;
}


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

int main() {
	char x, y;

	cin >> x >> y;

	if (x < y) {
		cout << "<" << endl;
	}
	else if (x == y) {
		cout << "=" << endl;
	}
	else {
		cout << ">" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		long Q = sc.nextLong();
		long H = sc.nextLong();
		long S = sc.nextLong();
		long D = sc.nextLong();
		long N = sc.nextLong();
		long C;
		
		H=Math.min(2*Q, H);
		S=Math.min(2*H, S);
		
		if(2*S<D) {
			C=S*N;
		}
		else {
			C=N/2*D+N%2*S;
		}
		System.out.println(C);
	}
}


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

int main(int argc, const char * argv[]) {
    int N;
    int counter = 0;
    cin >> N;
    while (N > 0) {
        int mod = N % 10;
        if (mod == 2) {
            counter++;
        }
        N /= 10;
    }
    cout << counter << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main ()
{
	int a,b,c,d;
	char s[107];
	char t[107];
	char u[107];
	scanf ("%s",s);
	scanf ("%s",t);
	scanf ("%d%d",&a,&b);
	scanf ("%s",u);
	if (strcmp(u,s)==0)
	{
		printf ("%d %d\n",a-1,b);
	}
	else

	{
		printf ("%d %d\n",a,b-1);
	}
	return 0;
}

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

int main() {
    vector<int> a(11,-1);
    ll n;
    cin >> n;
    for(int i = 0; i < 11; i++) {
        int x;
        if(n%26!=0){
            x = n%26;
        }
        else{
            x = 26;
        }
        a[10-i]=x;
        n -= x;
        if(n==0) break;
        n /= 26;
    }

    for(int i = 0; i < 11; i++) {
        if(a[i]!=-1){
            cout << (char)(96+a[i]);
        }
    }
    cout << endl;

    return 0;
}

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

using namespace std;


signed main(){

    
    int a,b;
    cin >> a >> b;
    int ans;
    
    ans = a+b;
    
    if(a-b > ans)ans = a-b;
    if(a*b > ans)ans = a*b;
    
    cout<<ans;


 }


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

r = s.count('R')
g = s.count('G')
b = s.count('B')
all_count = r*g*b

reduce = 0
for i in range(1, n-2+1):
    for j in range(i+1, (n+i)//2+1):
        k = 2*j -i
        if k > n: continue
        if s[i-1] != s[j-1] and s[i-1] != s[k-1] and s[j-1] != s[k-1]:
            reduce += 1
print(all_count - reduce)

Measured memory_bytes: 9132
#include <iostream>

using namespace std;

int n,ans = 0;

void dfs(long long x, int a, int b, int c){
    if(x > n){
        return;
    }
    if(a&&b&&c) ans++;
    dfs(x*10+3,1,b,c);
    dfs(x*10+5,a,1,c);
    dfs(x*10+7,a,b,1);
}

int main(){
    cin >> n;
    dfs(0,0,0,0);
    cout << ans << endl;
}


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

using namespace std;

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

#define mm 100005
#define nn 1005
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define cases int t;  cin>>t;   while(t--)
#define check(a,n) forn(iiii,int(n)) cout<<ll(a[iiii])<<" "; cout<<endl
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vi g[2*mm];


int main()
{
    fast_io;
    int n,m,v,u;
    cin>>n>>m;
    forn(i,m)
        cin>>v>>u,g[v].pb(u),g[u].pb(v);
    for(auto i:g[1])
    {
        for(auto j:g[i])
            if(j==n)
               return cout<<"POSSIBLE",0;
    }
    cout<<"IMPOSSIBLE";
    return 0;
}


Measured memory_bytes: 12016
<?php

fscanf(STDIN, "%s%s", $a,$b);
fscanf(STDIN,"%s",$s);

$array = str_split($s);
$count = substr_count($s,"-");

if ($array[$a] == "-" && $count == 1){
    echo "Yes";
}else{
    echo "No";
}

Measured memory_bytes: 4732
H, W = map(int, input().split())
As =[input() for _ in range(H)]
cnt = 0
for i in range(H):
    for j in range(W):
        if As[i][j] == '#':
            cnt += 1
if cnt == H+W-1:
    print('Possible')
else:
    print('Impossible')


Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string s;
  cin >> s;
  int first = stoi(s.substr(0, 1));
  int second = stoi(s.substr(1, 1));
  int third = stoi(s.substr(2, 1));
  cout << first + second + third << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
h = list(map(int, input().split()))

cnt = [0]*n
for i in range(1, n):
    j = max(0,i-k)
    cnt[i] = min(abs(h[m]-h[i])+cnt[m] for m in range(j,i))
print(cnt[n-1])


Measured memory_bytes: 53600