akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var k = Read().Int();
            for (int i = 0; i <= 9; i++)
            {
                Dfs(i.ToString());
            }
            d.Sort();
            WriteRead(d[k - 1]);
        }

        private static List<long> d = new List<long>();
        private static void Dfs(string v)
        {
            var a = v.Long();
            if (("1" + v).Long() > 93234566667) return;
            if (a > 93234566667) return;
            if (v[0] != '0')
            {
                d.Add(a);
            }
            Dfs(v[0] + v);
            if (v[0].Int() != 9)
            {
                var h = v[0].Int() + 1;
                Dfs(h.ToString() + v);
            }
            if (v[0].Int() != 0)
            {
                var l = v[0].Int() - 1;
                Dfs(l.ToString() + v);
            }
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 18932
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> mochi(N);
    for(int i=0;i<N;i++){ cin >> mochi.at(i); }
    
    //配列の中身を数字が小さい順に並び変え
    for(int i=0;i<N;i++){
        if(i+1 < N){//次のmochiが存在し
            if(mochi.at(i) > mochi.at(i+1)){//次のmochiの方が数が小きかったら
                int change = mochi.at(i);   //
                mochi.at(i) = mochi.at(i+1);//入れ替える
                mochi.at(i+1) = change;     //
                i=-1;//再度、最初からチェック
            }
        }
    }
    
    int count = 1;
    for(int i=0;i<N;i++){
        if(i+1 < N){
            if(mochi.at(i) < mochi.at(i+1)){ count++; }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<cstdio>
	using namespace std;
	int a[100050];
	int main(){
		int n,k;
		scanf("%d%d",&n,&k);
		for (int i=1;i<=n;i++) scanf("%d",&a[i]);
		int ans=0,last=0;
		for (int i=1;i<=n;i++) 
		if (a[i]==1) {
			if ((i-1-last)%(k-1)==0) {
				ans+=(i-1-last)/(k-1);
				last=i;
			}else {
				ans+=(i-1-last)/(k-1)+1;
				last=i+k-1-(i-1-last)%(k-1);
			}
		}
		for (int i=last;i<n;i+=k-1) ans++;
		printf("%d",ans); 
} 

Measured memory_bytes: 512
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;
#define ASCII 48

int main() {
	int n;
	int weight[100];

	int weight_sum = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> weight[i];
		weight_sum += weight[i];
	}

	float sep = weight_sum / 2;
	float sub = 100000000;
	int weight_sum2 = 0;

	for (int i = 0; i < n; i++) {
		weight_sum2 += weight[i];
		weight_sum -= weight[i];
		if (sub > abs(weight_sum - weight_sum2))sub = abs(weight_sum - weight_sum2);
		else {
			cout << sub;
			break;
		}
	}


	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math/rand"
	"time"
)

type dice struct {
	t, s, e, w, n, b int
}

func (d *dice) rotate(s string) {
	switch s {
	case "E":
		d.t, d.e, d.w, d.b = d.w, d.t, d.b, d.e
	case "W":
		d.t, d.e, d.w, d.b = d.e, d.b, d.t, d.w
	case "S":
		d.t, d.s, d.b, d.n = d.n, d.t, d.s, d.b
	case "N":
		d.t, d.s, d.b, d.n = d.s, d.b, d.n, d.t
	}
}

// サイコロ2
func main() {
	var t, s, e, w, n, b int
	fmt.Scan(&t, &s, &e, &w, &n, &b)
	d := dice{t: t, s: s, e: e, w: w, n: n, b: b}

	var q int
	fmt.Scan(&q)

	dirs := []string{"E", "W", "S", "N"}
	// s := ""
	for i := 0; i < q; i++ {
		var qt, qs int
		fmt.Scan(&qt, &qs)
		for {
			if d.t == qt && d.s == qs {
				fmt.Println(d.e)
				break
			}
			rand.Seed(time.Now().UnixNano())
			dir := dirs[rand.Intn(3)]
			d.rotate(dir)
		}
	}
}



Measured memory_bytes: 1164
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  s = InputLine.to_s
  t = InputLine.to_s

  m = 1e+12.to_i
  (s.size - t.size + 1).times do |i|
    c = 0
    t.size.times do |j|
      c += 1 if s[i + j] != t[j]
    end
    m = [m, c].min
  end
  puts m.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14392
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> o(n);
  for(int i=1;i<=n;i++){
    int p;
    cin>>p;
    o.at(p-1)=i;
  }
  set<int> s;
  s.insert(0);
  s.insert(n+1);
  int64_t a=0;
  for(int i=n-1;i>=0;i--){
    auto l=prev(s.lower_bound(o.at(i)));
    auto r=s.lower_bound(o.at(i));
    int64_t xl=(*l==0?0:(int64_t)(*l-*prev(l))*(*r-o.at(i)));
    int64_t xr=(*r==n+1?0:(int64_t)(o.at(i)-*l)*(*next(r)-*r));
    a+=(xl+xr)*(i+1);
    s.insert(o.at(i));
  }
  cout<<a<<endl;
}

Measured memory_bytes: 8320
#include <algorithm>
#include <cstdio>

int main() {
  int x[4];
  for (int i = 0; i < 4; ++i) {
    scanf("%d", x + i);
  }
  std::sort(x, x + 4);
  bool ok = x[0] == 1 && x[1] == 4 && x[2] == 7 && x[3] == 9;
  puts(ok ? "YES" : "NO");
  return 0;
}

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

int main()
{
  string S;
  cin >> S;

  int len = S.length();
  string tl = S.substr(0,1);
  int l = 1;
  int ans = 1;
  for (int r=1; r<len; r++) {
    string tr = S.substr(l, r-l+1);
    if (tl != tr) {
      l = r+1;
      tl = tr;
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 644
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int, int>;
int main()
{
    string s;
    cin >> s;

    long long sum = 0;
    int n = s.size();

    for (int bit = 0; bit < (1 << n - 1); bit++) //2^n-1繰り返す
    {
        long long temp = s[0] - '0'; //最初の文字を数値にしてtempに代入

        for (int i = 0; i < n - 1; i++) //数値の間分繰り返す
        {

            if (bit & (1 << i))
            { //1が立っていれば, プラス記号を入れる場所とみなす
                sum += temp; //まずは合計にtempを加算し
                temp = s[i + 1] - '0'; //プラス記号なので、次の桁を数値に変換して終わり
            }
            else
            {
                temp *= 10; //プラス記号にならなかったので、tempに入ってる数字に桁を足し ex.s = 125, 1 * 10 = 10
                temp += s[i + 1] - '0'; //次の桁を加算する ex. 10 + 2 = 12
            }
        }
        sum += temp; //最後にプラスだったところとなかったところを全部足す
    } //これを全通り行う

    cout << sum << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s;
    cin >> s;
    int res = 0;
    int l = 0, r = s.size() - 1;
    while (l < r) {
        if (s[l++] != s[r--]) res++;
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())

if (M <= N):
    print(0)
else:
    Xs = list(map(int, input().split()))
    Xs.sort()
    W = Xs[-1] - Xs[0]
    Ds = [Xs[i+1]-Xs[i] for i in range(M-1)]
    Ds.sort(reverse=True)

    gaps = 0
    for i in range(N-1):
        gaps += Ds[i]

    print(W-gaps)

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

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

int main(void) {
  int num = 0;
  int N;
  int K;
  string S;
  int A[100000];

  cin >> N >> K;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  num = (int)std::ceil((double)(N - 1) / (double)(K - 1));

  cout << num << endl;
  return 0;
  
}


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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

double prob[16][16];
double dp[1<<16][17];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M; cin >> M >> N;
  REP(i,M) REP(j,N) cin >> prob[i][j];

  double ans = 0.;
  FOR(b,1,1<<M)
	dp[b][N] = 1.;
  for(int i=N-1;i>=0;--i){
	for(int b=0;b<1<<M;++b){
	  for(int j=0;j<M;++j){
		if((b>>j&1) == 0) continue;
		double p = 1., sum = 0.;
		for(int k=i;k<N;++k){
		  sum += p * (1. - prob[j][k]) * dp[b&~(1<<j)][k];
		  p *= prob[j][k];
		}
		sum += p * dp[b][N];
		dp[b][i] = max(dp[b][i], sum);
	  }
	}
  }

  ans = dp[(1<<M)-1][0];
  cout << fixed << setprecision(10) << ans << endl;

  return 0;
}

Measured memory_bytes: 11940
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


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

    // ifstream fin(".in");
    // ofstream fout(".in");
double p;
i64 n,k,ans=0;
cin>>n>>k;
forn(i,n)
{
  i64 h;
  cin>>h;
  if(h>=k)ans++;
}
cout<<ans;
    return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main() {
	cin.sync_with_stdio(0);
	ll n, K;
	cin >> n >> K;
	vl logs(n);
	ll lmax = 0;
	FOR(i,0,n) {
		cin >> logs[i];
		lmax = max(lmax, logs[i]);
	}

	ll min = 0;
	ll max = lmax;

	while (max - min > 1) {
		ll mid = (max + min) / 2;

		ll cuts = 0;
		FOR(i,0,n) {
			cuts += (logs[i] + mid - 1) / mid - 1;
		}

		if (cuts <= K) {
			max = mid;
		} else {
			min = mid;
		}
	}

	cout << max << endl;
}


Measured memory_bytes: 4824
n = int(input())
list = []
for i in range(5):
    a = int(input())
    list.append(a)

cnt = 0

min = 10**16
min_ind = 0
for i in range(5):
    if min > list[i]:
        min = list[i]
        min_ind = i


if n % list[min_ind] == 0:
    print(4 - min_ind + n // list[min_ind] + min_ind)
else:
    print(5 - min_ind + n // list[min_ind] + min_ind)

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

unsigned long euqulid(unsigned long i, unsigned long j){
    unsigned long r = 1;
    unsigned long gcm;

    if(i < j){
        unsigned long x = i;
        i = j;
        j = x;
    }
    
    while(r != 0){
        r = i % j;
        gcm = j;
        i = j;
        j = r;
    }
    return gcm;
}

int main(){
    long n;
    cin >> n;
    long an = 0;

    for(long i = 1; i <= n; ++i){
        for(long j = i; j <= n; ++j){
            for(long k = j; k <= n; ++k){
                long count;

                long ans__ = euqulid(i, j);
                long ans_ = euqulid(ans__, k);
                if(i == j && j == k){
                    count = 1;
                }
                else if(i == j || j == k){
                    count = 3;
                }
                else{
                    count = 6;
                }
                an += ans_ * count;
            }
        }
    }
    cout << an << endl;
}

Measured memory_bytes: 3636
import collections
N = int(input())
D = list(map(int,input().split()))
D_ = collections.Counter(D)
ans = 1
ans_ = 1
for i in range(len(D_)):
    temp = D_[i]
    if D[0] != 0:
        print(0)
        ans_ = 0
        break
    elif i == 0 and temp > 1:
        print(0)
        ans_ = 0
        break
    elif temp ==0:
        print(0)
        ans_ = 0
        break
    elif i > 0:
        ans *= D_[i-1] ** D_[i]
        ans %= 998244353
if ans_:
    print(ans)

Measured memory_bytes: 62388
# frozen_string_literal: true

# Fenwick Tree
class FenwickTree
  def initialize(arg)
    case arg
    when Array
      @size = arg.size
      @data = Array.new(@size + 1) { 0 }
      arg.each.with_index(1) { |e, i| add(i, e) }
    when Integer
      @size = arg
      @data = Array.new(@size + 1) { 0 }
    else
      raise ArgumentError
    end
  end

  def add(i, x)
    while i <= @size
      @data[i] += x
      i += (i & -i)
    end
  end

  def sum(l, r)
    _sum(r) - _sum(l)
  end

  def _sum(i)
    res = 0
    while i > 0
      res += @data[i]
      i -= (i & -i)
    end
    res
  end
end

FeTree            = FenwickTree
BinaryIndexedTree = FenwickTree

n, q = gets.split.map { |e| e.to_i }
a    = gets.split.map { |e| e.to_i }
 
ft = FeTree.new(a)
 
ans = []
q.times do
  t, u, v = gets.split.map { |e| e.to_i }
 
  if t == 0
    ft.add(u + 1, v)
  else
    ans << ft.sum(u, v)
  end
end

puts ans

Measured memory_bytes: 59700
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, c;
    cin >> n >> c;
    long long mod = 1e9 + 7;
    vector<int>a(n + 3), b(n + 3);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int mx = 0;
    for(int i = 1; i <= n; i++){
        cin >> b[i];
        mx = max(mx, b[i]);
    }
    long long pref[mx + 3][c + 3], dp[n + 3][c + 3], power[mx + 3][c + 3];
    for(int i = 0; i <= c; i++){
        power[0][i] = 0;
        pref[0][i] = 0;
    }
    for(int i = 1; i <= mx; i++){
        power[i][0] = 1;
        for(int j = 1; j <= c; j++){
            power[i][j] = (1LL * i * power[i][j - 1]) % mod;
        }
    }
    for(int i = 1; i <= mx; i++){
        for(int j = 0; j <= c; j++){
            pref[i][j] = (pref[i - 1][j] + power[i][j]) % mod;
        }
    }
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= c; j++){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= c; j++){
            for(int k = 0; k <= j; k++){
                long long r = (pref[b[i]][j - k] - pref[a[i] - 1][j - k] + 5 * mod) % mod;
                dp[i][j] = (dp[i][j] + (dp[i - 1][k] * r) % mod) % mod;
            }
        }
    }
    cout << dp[n][c];
    return 0;
}

Measured memory_bytes: 7424
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a <= 9 && b <= 9){
			System.out.println(a*b);
		}
		else {
			System.out.println(-1);
		}

	}

}


Measured memory_bytes: 21844
import java.util.Scanner;
import java.util.Queue;
import java.util.ArrayDeque;
import java.util.Arrays;
 
public class Main {
	static int cnt = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		if(x==0) {
			System.out.println(1);
		}else {
			System.out.println(0);
		}
		
	}

}

Measured memory_bytes: 27076
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	X := nextInt64()
	for i := int64(0); i <= 10000; i++ {
		for j := int64(0); j < i; j++ {
			pi := pow(i, 5)
			pj := pow(j, 5)
			if pi-pj == X {
				fmt.Println(i, j)
				return
			}
			if pi+pj == X {
				fmt.Println(i, -j)
				return
			}
		}
	}
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

// -*-*-*-*-*-*-*-*-*-*-*-*-*-
// * Algorithms Utility Zone *
// -*-*-*-*-*-*-*-*-*-*-*-*-*-

// -*-*-*-*-*-*-*-
// * 1. nibutan  *
// -*-*-*-*-*-*-*-
func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a int64, b int) (ret int64) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


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

int main() {
  int N;
  int M;
  int z;
  cin >> N >> M;
 int sum=0;
  vector<int> vec(N);
 for(int i=0;i<N;i++){
   cin >> vec.at(i);
   sum=sum + vec.at(i);
 }
  int count=0;
  for (int i=0;i<N;i++){
    if(4*M*vec.at(i) >= sum){
     count = count+1; 
    }
  }
  
  if(count >= M){
   cout << "Yes" << endl; 
  }
  
  else{
   cout << "No" << endl; 
  }
  return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second

Int INF = 1e18;
//Int mod = 1e9+7;
Int mod = 998244353;

bool dp1[20000];
bool dp2[20000];
bool tmp[20000];

int main() {
    string s;
    cin >> s;
    Int x, y;
    cin >> x >> y;
    Int n = s.size();
    vector<pair<char, Int>> rl;
    char a = s[0];
    Int cnt = 0;
    Int i = 0;
    while (i < n) {
        a = s[i];
        cnt = 0;
        while (i < n and a == s[i]) {
            i++;
            cnt++;
        }
        rl.emplace_back(a, cnt);
    }
    for (Int i = 0; i < rl.size(); i++) {
        if (rl[i].fi == 'T') {
            rl[i].se %= 4;
        }
    }
    Int start = 0;
    if (rl[0].fi == 'F') {
        x -= rl[0].se;
        start = 1;
    }
    vector<Int> xs, ys;
    bool x_mode = true;
    for (Int i = start; i < rl.size(); i++) {
         if (rl[i].fi == 'T') {
            if (rl[i].se % 2 == 1) {
                x_mode = not x_mode;
            }
         }
         else {
             if (x_mode) {
                 xs.emplace_back(rl[i].se);
             }
             else {
                 ys.emplace_back(rl[i].se);
             }
         }
    }
    
    dp1[10000] = dp2[10000] = true;

    for (Int i = 0; i < xs.size(); i++) {
        for (Int j = 0; j < 20000; j++) {
            tmp[j] = false;
        }
        for (Int j = 5000; j >= -5000; j--) {
            if (dp1[10000 + j]) {
                tmp[10000 + j + xs[i]] = true;
            }
        }
        for (Int j = -5000; j < 5000; j++) {
            if (dp1[10000 + j]) {
                tmp[10000 + j - xs[i]] = true;
            }
        }
        for (Int j = 0; j < 20000; j++) {
            dp1[j] = tmp[j];
        }
    }
    for (Int i = 0; i < ys.size(); i++) {
        for (Int j = 0; j < 20000; j++) {
            tmp[j] = false;
        }
        for (Int j = 5000; j >= -5000; j--) {
            if (dp2[10000 + j]) {
                tmp[10000 + j + ys[i]] = true;
            }
        }
        for (Int j = -5000; j < 5000; j++) {
            if (dp2[10000 + j]) {
                tmp[10000 + j - ys[i]] = true;
            }
        }
        for (Int j = 0; j < 20000; j++) {
            dp2[j] = tmp[j];
        }
    }
    dump((dp1[10000 + x] and dp2[10000 + y]) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double rada = 2 * M_PI * (h / 12. + 1. / 12 * m / 60.);
  double radb = 2 * M_PI * m / 60.;
  double y = a * cos(rada) - b * cos(radb);
  double x = a * sin(rada) - b * sin(radb);
  cout << fixed << setprecision(20) << sqrt(x * x + y * y) << endl;
}

Measured memory_bytes: 4052
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;

    int a[500500];
    memset(a, 0, sizeof a);

    int t = 0;
    for (int i = s.length(); i >= 0; --i) {
        if (s[i] == '>') {
            t += 1;
            a[i] = t;
        } else {
            t = 0;
        }
    }
    t = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == '<') {
            t += 1;
            a[i + 1] = max(a[i + 1], t);
        } else {
            t = 0;
        }
    }

    // rep(i, s.length() + 1) cerr << a[i] << ' '; cerr << '\n';

    int64 ans = 0;
    rep(i, s.length() + 1) ans += a[i];
    print(ans);

    return 0;
}



Measured memory_bytes: 2844
N, M = input().split(' ')

N = int(N)
M = int(M)

vote_of_item = [int(x) for x in input().split(' ')]
total_votes = sum(vote_of_item)
frac_of_item = [vote/total_votes for vote in vote_of_item]
threshold = 1 / (4 * M)

selectable = 0
for i in range(len(frac_of_item)):
    if frac_of_item[i] >= threshold:
        selectable += 1


if selectable >= M:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
    int N,A,R,E;
    R=0;
    E=0;
    cin>>N;
    for(int t=1;t<=N;t++)
    {
    	cin>>A;
    	if(A%2==0)
    	E++;
		else
		E+=0; 
    	if((A%2==0) && (A%3==0 || A%5==0))
    	R++;
		else
		R+=0;
	}
	if(R==E)
    cout<<"APPROVED";
	else
	cout<<"DENIED"; 
    return 0;
}

Measured memory_bytes: 256
import sys
INPUT = sys.stdin.readline
#入力関数
def SORO_INT(): return int(INPUT())
def MULT_INT_LIST(): return list(map(int, INPUT().split()))
def MULT_INT_MAP(): return map(int, INPUT().split())
def SORO_STRING(): return INPUT()
def MULT_STRING(): return INPUT().split()

r = SORO_INT()
x = 3*r*r
print(x)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,x;
    cin>>k>>x;
    if(x+k<=10000 && x-k>=-10000)
    {
        for(int j=x-k+1;j<x;j++)
            cout<<j<<" ";
        for(int i=x;i<k+x;i++)
            cout<<i<<" ";

        cout<<endl;
    }
    else
    {
        for(int i=-10000,j=0;j<=k;i++,j++)
            cout<<i<<" ";
        cout<<endl;
    }
    return 0;

}

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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int h, w, m;
	cin >> h >> w >> m;
	map<pair<int, int>, bool> z;
	vector<pair<int, int>> a(h), b(w);
	for (int i = 0; i < h; i++) a[i] = {0, i};
	for (int i = 0; i < w; i++) b[i] = {0, i};
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		z[{x, y}] = 1;
		a[x].first++, b[y].first++;
	}
	
	sort(b.rbegin(), b.rend());
	while (b.back().first < b[0].first) b.pop_back();
	sort(a.rbegin(), a.rend());
	while (a.back().first < a[0].first) a.pop_back();
	long long x = a.size(), y = b.size();
	if (x*y > m) cout << a[0].first + b[0].first;
	else {
		for (int i = 0; i < x; i++) {
			for (int j = 0; j < y; j++) {
				if (!z[{a[i].second, b[j].second}]) {
					cout << a[0].first + b[0].first;
					return 0;
				}
			}
		}
		cout << a[0].first + b[0].first - 1;
	}
}

Measured memory_bytes: 26676
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define MOD 10000007
#define PB push_back

using namespace std;



int main(){

    string s,t;
    cin >> s >> t;

    cout << t << s <<endl;
    
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

import numpy as np

# Aへの加算は、imos法でまとめて行える。
# +[1,2,3,4,5]
# 階差：[-4,1,1,1,1]
# 総回数と最終的な階差から、回数分布がわかる

N = int(input())
A = np.array(input().split(), dtype=np.int64)

total_op = A.sum() // (N*(N+1)//2)

diff = np.empty_like(A)
diff[1:] = np.diff(A)
diff[0] = A[0] - A[-1]

# 操作の起点となる回数
op = (total_op - diff)//N

bl = True
bl &= (total_op * (N*(N+1)//2) == A.sum())
bl &= (N*op + diff == total_op).all()
bl &= (op >= 0).all()

answer = 'YES' if bl else 'NO'
print(answer)

Measured memory_bytes: 25940
# -*- coding: utf-8 -*-
"""
C - Factors of Factorial
https://atcoder.jp/contests/arc067/tasks/arc067_a

"""
import sys



from collections import Counter

def prime_factor(N):
    factors = Counter()
    for i in range(2, int(N**0.5)+1):
        while N % i == 0:
            factors[i] += 1
            N //= i
    if N != 1:
        factors[N] = 1
    return factors


def solve(N):
    f = Counter()
    for i in range(1, N+1):
        f += prime_factor(i)

    MOD = 10**9 + 7
    ans = 1
    for k, v in f.items():
        ans = ans * (v+1) % MOD
    return ans


def main(args):
    N = int(input())
    ans = solve(N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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


int main() {

  int n,m ; cin >> n >> m ;
  vector<int> vec(m)  ; 
  
  for ( int i = 0 ; i < n ; i++ ){
     int k ; cin >> k ;
     for ( int j = 0 ; j < k ; j++ ){
       int x ; cin >> x ; vec.at(x-1)++ ; 
     }
  }
  
  int ans = 0 ; 
  for ( int i : vec ){
  	if ( i == n ) ans++;
  }
  cout << ans << endl ;

}

Measured memory_bytes: 384
<?php

fscanf(STDIN, '%d', $n);

$fill10 = array_fill(0, 10, 0);
$dorm = array($fill10, $fill10, $fill10);
$arr = array($dorm, $dorm, $dorm, $dorm);

for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, '%d %d %d %d', $b, $f, $r, $v);
    $arr[$b - 1][$f - 1][$r - 1] += $v;
}

foreach ($arr as $i => $dorm) {
    foreach ($dorm as $arr2) {
        printf(' %s%s', implode(' ', $arr2), PHP_EOL);
    }

    if ($i !== 3) {
        echo str_repeat('#', 20), PHP_EOL;
    }
}

Measured memory_bytes: 6620
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<string> S(N);
  for(int i=0;i<N;++i) cin>>S[i];
  int ans = 0;
  bool ok;
  for(int i=0;i<N;++i) {
    ok = true;
    for(int j=0;j<N;++j) {
      for(int k=0;k<N;++k) {
        if(S[(j+i)%N][k]!=S[(k+i)%N][j]) ok = false;
      }
    }
    if(ok) ans += N;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3732
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdlib>

using namespace std;

typedef pair<int,int> pos;

const int infty = 1<<29;

int MHdist(pos A, pos B){
  return abs(A.first-B.first)+abs(A.second-B.second);
}

int solve( int start,
	   vector< vector< pair<pos,int> > > & PM,
	   const pos &S,
	   const pos &G ){

  start++;
  start %= 5;
  int end = (start + 3) % 5;

  // cout << "START : " << start << " END : " << end << endl;
  int ret = infty;

  for(int i = 0; i < PM.size(); ++i){
    for(int j = 0; j < PM[i].size(); ++j){
      PM[i][j].second = infty;
    }
  }
  
  for(int i = 0; i < PM[start].size(); ++i){
    PM[start][i].second = MHdist( S, PM[start][i].first );
  }
  
  for(int k = 1; k < 5; ++k){
    int now = (start + k) % 5;
    int prev = (now + 4) % 5;
    //cout << " NOW : " << now << " PREV : " << prev << endl;
    for(int i = 0; i < PM[now].size(); ++i){
      
      int minimum = infty;
      for(int j = 0; j < PM[prev].size(); ++j){
	minimum = min( minimum,
		       PM[prev][j].second + MHdist( PM[prev][j].first, PM[now][i].first) );
      }
      
      //cout << minimum << endl;
      PM[now][i].second = min( PM[now][i].second, minimum );
      //cout << PM[now][i].second << endl;
    }
  }

  for(int i = 0; i < PM[end].size(); ++i){
    ret = min( ret, PM[end][i].second + MHdist( PM[end][i].first, G ) );
  }

  return ret;
}

int main()
{
  while(true){
    int ans_st;
    int ans = infty;
    int W,H;
    pos S,G;
    vector< vector< pair<pos,int> > > pachi(5);

    cin >> W >> H;
    if( W == 0 && H == 0 ) break;
    for(int i = 0; i < H; ++i){
      for(int j = 0; j < W; ++j){
	char c;
	cin >> c;
	if( c == 'S' ) S = pos(i,j);
	else if( c == 'G' ) G = pos(i,j);
	else if( c == '.' ) continue;
	else pachi[c-'0'-1].push_back( make_pair(pos(i,j),infty) );
      }
    }
    for(int i = 0; i < 5; ++i){
      int t = solve( i, pachi, S, G );
      if( ans > t ){
	ans_st = i+1;
	ans = t;
      }
    }

    if( ans >= infty )
      cout << "NA" << endl;
    else
      cout << ans_st << ' ' << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1000
N=int(input())
a = []
for line in range(N):
    input1,input2=input().split()
    a.append(input1+str(input2))

b = ['S','H','C','D']
cards = []
for i in b:
    for j in range(1,14):
        c =i + str(j)
        cards.append(c)

for i in a:
    cards.remove(i)

for i in cards:

    out = i[0:1] + " " + i[1::]
    print(out)




Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  string s;
  int w;
  cin>>s>>w;
  for(int i=0;i<s.size();i++){
    if(i%w==0){cout<<s[i];}
  }
  cout<<endl;
  return 0;
}

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

class Main {


    public static boolean contains(final int[] arr, final int key) {
        return Arrays.stream(arr).anyMatch(i -> i == key);
    }

    public static boolean check(int n,int [] arr){
        while (n>0){
            if(contains(arr,n%10)){
                return true;
            }
            n=n/10;
        }
        return false;
    }
    public static void main(String[] args) {

        Scanner inpunt = new Scanner(System.in);
        int x ,y ;

        x=inpunt.nextInt();
        y=inpunt.nextInt();
        inpunt.nextLine();
        int array[] = new int[y];

        for(int i=0;i<y;i++){
           array[i]=inpunt.nextInt();

        }

        while (check(x,array))
            x++;

        System.out.println(x);


    }
}

Measured memory_bytes: 38884
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
typedef long long ll;
typedef long double ld;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
  ll n,m,k,i,j,result=0;
  int a[200010];
  string s;
  cin >> s;
  m = 0;
  result=0;
  rep(i,3){
    if(s[i]=='R') m++;
    else m=0;
    result = max(result,m);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>

using namespace std;

int main(void){
	double d, min_height, max_height;
	
	scanf("%lf", &d);
	max_height = min_height = d;

	while( true ){
		if( 1 != scanf("%lf", &d) ) break;

		min_height = min( min_height, d );
		max_height = max( max_height, d );
	}
	printf("%.2f\n", max_height - min_height);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef pair<int, pair < int, int > > PP;
typedef long long ll;
typedef pair<ll, ll>P;
ll inf = -1;
ll mod = pow(10, 9) + 7;

const int MAX = 100000;
 ll C[51][51]; // C[n][k] -> nCk

void comb_table(int N){
	for(int i=0;i<=N;++i){
		for(int j=0;j<=i;++j){
			if(j==0 or j==i){
				C[i][j]=1LL;
			}
			else{
				C[i][j]=(C[i-1][j-1]+C[i-1][j]);
			}
		}
	}
}

int main() {
	int n, a,b;ll v[51];
	cin>>n>>a>>b;
	comb_table(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	sort(v,v+n,greater<ll>());
	long double sum=0;
	for(int i=0;i<a;i++){
		sum+=v[i];
	}
	cout<<setprecision(20)<<sum/a<<endl;
	int cnt=0;
	for(int i=0;i<n;i++){
		if(v[i]==v[a-1]){
			cnt++;
		}
	}
	ll ans=0;
	//全部同じ数の場合
	if(v[0]==v[a-1]){
		for(int i=a;i<=b;i++){
			ans+=C[cnt][i];
		}
	}
	//そうでない時
	else{
		int count=0;
		for(int i=0;i<a;i++){
			if(v[a-1]==v[i]){
				count++;
			}
		}
		ans=C[cnt][count];
	}

	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep1(i,n) for(i=1;i<=n;i++)
int main(){
  int x,y;
  int i,j;
  int numK,numT;
  bool exist = false;
  
  cin >> x >> y;
  
  for(numK=x;x>=0;x--){
    numT = x-numK;
    if(y==numK*4+numT*2){
      exist = true;
      break;
    }
  }
  
  if(exist)
    cout << "Yes";
  else
    cout << "No";
    
  
  
  
}

Measured memory_bytes: 3588
#include<iostream>

using namespace std;

int cnt = 0;
int m = 1;
int G[100];
void insertionsort(int A[],int n,int g){
	for (int i = g; i < n ; i++){
		int v = A[i];
		int j = i - g;
		while (j >= 0 and A[j] > v){
			A[j+g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j+g] = v;
	}
}


int h(int n){
	int h = 1;
	int count = 0;
	while (h < n){
		h  = 3 * h + 1;
		count++;
	}
	if (count == 0){
		return 1;
	}else{
		return count;
	}
}
void shellsort(int A[],int n){
	cnt = 0;
	m = h(n);
	for (int j = m; j > 0; j--){
		int mm = 1;
		for (int k = 0; k < j ; k++){
			mm *= 3;
		}
		G[j-1] = (mm-1)/2;
	}
	for (int i = m-1; i >= 0; i--){
		insertionsort(A,n,G[i]);
	}
}
int main(){
	int n; cin >> n;
	int A[1000001];

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

	shellsort(A,n);
	cout << m << endl;
	for (int i = m-1; i >= 0; i--){
		cout << G[i] ;
		if (i != m){
			cout << " ";
		}
	}
	cout << endl;
	cout << cnt << endl;
	for (int i = 0; i < n; i++){
		cout << A[i] << endl;;
	}
	

return 0;
}

Measured memory_bytes: 6996
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int64;
 
int main()
{
  int N, A[2] = {}, P;
 
  cin >> N >> P;
  for(int i = 0; i < N; i++) {
    int X;
    cin >> X;
    ++A[X % 2];
  }
 
  int64 mat[55][55] = {{}};
  for(int i = 0; i < 52; i++) {
    for(int j = 0; j <= i; j++) {
      if((j == 0) || (j == i)) {
        mat[i][j] = 1;
      } else {
        mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
      }
    }
  }
 
  int64 ret = 0;
  for(int i = 0; i <= A[0]; i++) {
    for(int j = 0; j <= A[1]; j++) {
      int mod = (i * 2 + j) % 2;
      if(mod == P) {
        ret += mat[A[0]][i] * mat[A[1]][j];
      }
    }
  }
  cout << ret << endl;
}

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

int main() {
    int n, m, l, r;
    cin >> n >> m;
    int lmax = 1, rmin = n;
    rep(i, m) {
        cin >> l;
        cin >> r;
        lmax = max(lmax, l);
        rmin = min(rmin, r);
    }
    cout << max(rmin - lmax + 1, 0) << endl;
    return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,c,k; cin>>n>>c>>k;
	vector<int> t(n);
	for (int i=0; i<n; i++)
		cin>>t[i];
	sort(t.begin(),t.end());
	int ret=0, idx=0;
	while(1) {
		if(idx>=n) break;
		ret++;
		int lim=t[idx]+k;
		for (int i=0; i<c; i++) {
			if(idx>=n) break;
			if(t[idx]<=lim) idx++;
			else break;
		}
	}
	cout << ret << endl;
	return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    ll N, K;
    cin >> N >> K;
    map<ll, ll> mp;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        mp[a] += b;
    }

    for (auto m: mp) {
        K -= m.second;
        if (K <= 0) {
            cout << m.first << endl;
            return 0;
        }
    }
}

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

int main(){
  int H, W;
  cin >> H >> W;
  char c[60][60];
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++){
      cin >> c[i][j];
    }
  }
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++){
      if(c[i][j] == '.'){
        int num = 0;
        if(c[i+1][j] == '#') num++;
        if(c[i-1][j] == '#') num++;
        if(c[i][j-1] == '#') num++;
        if(c[i][j+1] == '#') num++;
        if(c[i+1][j+1] == '#') num++;
        if(c[i+1][j-1] == '#') num++;
        if(c[i-1][j+1] == '#') num++;
        if(c[i-1][j-1] == '#') num++;
        c[i][j] = char(num + '0');
      }
    }
  }
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++){
      cout << c[i][j];
    }
    cout << endl;
  }
}
   


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
typedef long long ll;
using namespace std;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)){
		if (c=='-') 
			f=-1;
		c=getchar();
	}
	while (isdigit(c)) {
		x=x*10+c-'0';
		c=getchar();
	}
	x*=f;
}
const int N = 700000;
int n,ans=1e9,qzw[N],hze[N];
char s[N];
int main() {
	read(n);scanf("%s",s+1);
	rep(i,1,n) qzw[i]=qzw[i-1]+(s[i]=='W');
	per(i,n,1) hze[i]=hze[i+1]+(s[i]=='E');
	rep(i,1,n) ans=min(ans,qzw[i-1]+hze[i+1]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5760
while True:
	n = int(input())
	if n == 0:
		break
	m = 0
	c = 1000 - n
	while c != 0:
		if c >= 500:
			c = c - 500
			m = m + 1
		elif c >= 100:
			c = c - 100
			m = m + 1
		elif c >= 50:
			c = c - 50
			m = m + 1
		elif c >= 10:
			c = c - 10
			m = m + 1
		elif c >= 5:
			c = c - 5
			m = m + 1
		elif c >= 1:
			c = c - 1
			m = m + 1
	print(m)



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

int main(){
    int a,b;
    cin >> a >> b;
    
    if(a+b>=10) cout << "error";
    else cout << a+b;
}


Measured memory_bytes: 256
W, H, N = map(int, input().split())
A = [0, W, 0, H]
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        A[0] = max(A[0], x)
    elif a == 2:
        A[1] = min(A[1], x)
    elif a == 3:
        A[2] = max(A[2], y)
    else:
        A[3] = min(A[3], y)
a = A[1] - A[0]
b = A[3] - A[2]
if a >= 0 and b >= 0:
    ans = a * b
else:
    ans = 0
print(ans)

Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100005
int hill[MAXN];
int fir[MAXN];
int n,m,ecnt,ans;
struct edge
{
    int v,nxt;
}eds[MAXN<<1];
void adde(int a,int b)
{
    eds[++ecnt].v=b,eds[ecnt].nxt=fir[a],fir[a]=ecnt;
    eds[++ecnt].v=a,eds[ecnt].nxt=fir[b],fir[b]=ecnt;
}
int main()
{
    int a,b;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d",&hill[i]);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&a,&b);
        adde(a,b);
    }
    for(int i=1;i<=n;i++)
    {
        bool flg=0;
        for(int j=fir[i];j;j=eds[j].nxt)
        {
            int v=eds[j].v;
            if(hill[v]>=hill[i])
            flg=1;
        }
        if(flg==0)ans++;
    }
    printf("%d\n",ans);
    return 0;
}

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

string s, t, u, v;

bool func(string w){
	int x = 0;
	for(int i=0; i<t.size(); ++i){
		if(x < w.size() && t[i] == w[x]){
			++x;
		}
	}
	if(x == w.size()) return true;
	return false;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s >> t;
	for(int i=0; i<s.size(); i+=2) u += s[i];
	for(int i=1; i<s.size(); i+=2) v += s[i];
	if(func(u) || func(v)) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 3248