akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, C := sc.nextInt(), sc.nextInt()
	X := make([]int, N)
	V := make([]int, N)
	D := make([]int, N+1)
	now := 0
	for i := 0; i < N; i++ {
		X[i] = sc.nextInt()
		V[i] = sc.nextInt()
		D[i] = X[i] - now
		now += D[i]
	}
	D[N] = C - now
	Left := make([]int, N)
	Right := make([]int, N)
	best, d, v := 0, 0, 0
	for i := 0; i < N; i++ {
		d += D[i]
		v += V[i]
		best = max(best, v-d)
		Left[i] = best
	}
	best, d, v = 0, 0, 0
	for i := N; i > 0; i-- {
		d += D[i]
		v += V[i-1]
		best = max(best, v-d)
		Right[N-i] = best
	}
	//fmt.Fprintln(wtr, Left, Right)
	ans := 0
	d, v = 0, 0
	// Left -> Right
	for i := 0; i < N; i++ {
		v += V[i]
		d += D[i]
		sum := v - d
		if i < N-1 && 0 < Right[N-i-2]-d {
			sum += Right[N-i-2] - d
		}
		//fmt.Fprintln(wtr, Left[i], d, sum)
		ans = max(ans, sum)
	}
	// Right -> Left
	d, v = 0, 0
	for i := 0; i < N; i++ {
		v += V[N-1-i]
		d += D[N-i]
		sum := v - d
		if i < N-1 && 0 < Left[N-i-2]-d {
			sum += Left[N-i-2] - d
		}
		//fmt.Fprintln(wtr, v, d, sum)
		ans = max(ans, sum)
	}

	fmt.Fprintln(wtr, ans)
}


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

#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

#define Grt ch = getchar()
#define DeBug(x) std::cout << #x << '=' << x << std::endl

typedef long long ll;
const int MaxN = 45, MaxS = 1 << 18, mod = 1e9 + 7;

namespace IO
{
	char buf[1<<15], *fs, *ft;
	inline char getc() { return ft == fs && (ft = (fs = buf) + fread(buf, 1, 1<<15, stdin), ft == fs) ? 0 : *fs++; }
	template <typename T> inline void read(T &x)
	{
		x = 0;
		T f = 1, Grt;
		while (!isdigit(ch) && ch ^ '-') Grt;
		if (ch == '-') f = -1, Grt;
		while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), Grt;
		x *= f;
	}

	template <typename T, typename... Args>
	inline void read(T &x, Args &...args) { read(x); read(args...); }

	char Out[1<<24], *fe = Out;
	inline void flush() { fwrite(Out, 1, fe - Out, stdout); fe = Out; }
	template <typename T> inline void write(T x, char str)
	{
		if (!x) *fe++ = 48;
		if (x < 0) *fe++ = '-', x = -x;
		T num = 0, ch[20];
		while (x) ch[++ num] = x % 10 + 48, x /= 10;
		while (num) *fe++ = ch[num --];
		*fe++ = str;
	}
}

using IO::read;
using IO::write;

template <typename T> inline bool chkMin(T &a, const T &b) { return a > b ? (a = b, true) : false; }
template <typename T> inline bool chkMax(T &a, const T &b) { return a < b ? (a = b, true) : false; }
template <typename T> inline T min(T a, T b) { return a < b ? a : b; }
template <typename T> inline T max(T a, T b) { return a > b ? a : b; }

ll f[MaxN][MaxS], ans = 1;
int main()
{
	int n, x, y, z; read(n, x, y, z);
	int state = (1 << (x + y + z - 1)) |  (1 << (y + z - 1)) | (1 << (z - 1));
	int sum = (1 << (x + y + z)) - 1;
	f[0][0] = 1;
	for (int i = 1; i <= n; ++ i)
	{
		(ans *= 10) %= mod;
		for (int s = 0; s <= sum; ++ s) if (f[i - 1][s])
			for (int c = 1, now; c <= 10; ++ c)
			{
				now = (s << c) | (1 << (c - 1)), now &= sum;
				if ((now & state) != state) f[i][now] = (f[i][now] + f[i - 1][s]) % mod;
			}
	}
	for (int s = 0; s <= sum; ++ s) ans = (ans - f[n][s] + mod) % mod;
	write(ans, '\n');
	IO::flush();
	return 0;
}

Measured memory_bytes: 84224
//import java.io.File;
import java.util.Scanner;


public class Main{
	static int END_YEAR = 999;
	static int END_MONTH = 10;
	static int MONTH_BIG = 20;
	static int MONTH_SMALL = 19;
	static int YEAR_ALLBIG_DAYS = MONTH_BIG*10;	//??\????????´?????\??°
	static int YEAR_ORDINAL_DAYS = MONTH_BIG*5+MONTH_SMALL*5;	//??????????????´?????\??°
	static int YEARS_LOOP = YEAR_ALLBIG_DAYS + YEAR_ORDINAL_DAYS*2;	//?????´??????

	public static void main(String[] args) {
try{

	//Scanner scan = new Scanner(new File("in.txt"));
	Scanner scan = new Scanner(System.in);

	int number = scan.nextInt();

	for(int i = 0; i < number; i++) {
		System.out.println(getAnswer(scan.nextInt(), scan.nextInt(), scan.nextInt()));
	}

	scan.close();

}catch(Exception e) {
	e.printStackTrace();
}

	}

	public static int getAnswer(int _y, int _m, int _d) {
		int sum = 0;

		//????????\????????§????????´??\????????\??°????¨?????????????(????????§?????????????????´????????¨??????????????§)
		sum += getYearDates(_y,_m,_d);
		_y++;
		for(int i = _y; !isSpecialYear(i) && _y<=END_YEAR; i++) {
			sum += isSpecialYear(i)? YEAR_ALLBIG_DAYS:YEAR_ORDINAL_DAYS;
			_y++;
		}

		//????????\??°????¨?????????????
		if(END_YEAR > _y) {
			sum += YEARS_LOOP * ((END_YEAR-_y)/3);
			_y = END_YEAR;
		}

		//?????????999/10/20?????§???????????\??°????¨?????????????
		if(_y==END_YEAR) sum += YEAR_ALLBIG_DAYS;

		//????¨??????????
		return sum;
	}

	public static int getYearDates(int _y, int _sm, int _sd) {
		int THIS_YEAR_MONTH_BIG = MONTH_BIG;
		int THIS_YEAR_MONTH_SMALL = (isSpecialYear(_y))? MONTH_BIG:MONTH_SMALL;

		int sum = 0;
		//????????????
		sum += ((isBigMonth(_sm))? THIS_YEAR_MONTH_BIG:THIS_YEAR_MONTH_SMALL) - _sd + 1;
		//????????\???
		for(int i = _sm+1; i <= END_MONTH; i++) {
			sum += ((isBigMonth(i))? THIS_YEAR_MONTH_BIG:THIS_YEAR_MONTH_SMALL);
		}

		return sum;
	}

	public static boolean isSpecialYear(int _y) {
		return (_y%3) == 0;
	}

	public static boolean isBigMonth(int _m) {
		return (_m%2) == 1;
	}
}

Measured memory_bytes: 26516
import sys

n,k = map(int,input().split())
s = input()

zero = []
string = s[0]
count = 0
left = 0
right = 0
num = 0
for i in range(n):
	if s[i] == string:
		count += 1
	else:
		if string == '0':
			num = count
			string = '1'
		else:
			if num != 0:
				zero.append([num,left,count])
			string = '0'
			left = count
			num = 1
		count = 1

if string == '0':
	zero.append([count,left,0])
else:
	zero.append([num,left,count])

if len(zero) <= k:
	print(len(s))
	sys.exit()
res = 0
for i in range(k):
	res += zero[i][0] + zero[i][1]
res += zero[i][2]

ans = res
for i in range(len(zero)-k):
	res -= zero[i][0] + zero[i][1]
	res += zero[i+k][0] + zero[i+k][2]
	ans = max(ans,res)

print(ans)


Measured memory_bytes: 8180
#include <iostream>
#include <cstdio>
#include <map>
#include <vector>
#include <cstring>
#include <algorithm>
//

using namespace std;
typedef long long ll;
int n;
ll a[3000+5];
int main()
{
    ll sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        sum+=(a[i]-1);
    }


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


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.TreeMap;
 
class Main{
 
    public static void main(String[] args){
 
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        List<Integer> list = new ArrayList<>();
        for(int i=1; i<n; i++){
            list.add(scanner.nextInt());
        }
        scanner.close();
        Map<Integer,Integer> map = new TreeMap<>();
        for(int i=1; i<=n; i++){
            map.put(i,0);
        }
        for(int val: list){
            map.put(val,map.get(val)+1);
        }
        for(int key: map.keySet()){
            System.out.println(map.get(key));
        }
    }
 
}

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

int main() {
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    cout<<s1[0]<<s2[0]<<s3[0]<<endl;
}


Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    string s;
    vector<int> cnt(26);
    while (getline(cin, s)) {
        int n = sz(s);
        rep(i, n) if (isalpha(s[i])) {
            if (isupper(s[i])) s[i] = tolower(s[i]);
            cnt[s[i] - 'a']++;
        }
    }
    rep(i, 26) {
        char c = 'a' + i;
        cout << c << " : " << cnt[i] << endl;
    }
}



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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll n,m;
  cin>>n>>m;
  vector<ll> a(m),b(m);
  vector<vector<ll>> c(m);
  rep(i,m){
    cin>>a[i]>>b[i];
    c[i].resize(b[i]);
    rep(j,b[i]){
      cin>>c[i][j];
      c[i][j]--;
    }
  }
  vector<ll> dp(1LL<<n,INF);
  dp[0]=0;
  rep(i,m){
    ll now=0;
    rep(j,b[i]){
      now |= (1LL<<c[i][j]);
    }
    rep(j,1LL<<n){
      chmin(dp[j|now],dp[j]+a[i]);
    }
  }
  cout<<(dp[(1<<n)-1]==INF?-1:dp[(1LL<<n)-1])<<endl;


}


Measured memory_bytes: 384
n, l = map(int, input().split())
taste_list = []
abs_list = []
for i in range(n):
    taste = l + i
    taste_list.append(taste)
    abs_taste = abs(taste)
    abs_list.append(abs_taste)
abs_min = min(abs_list)
min_index = abs_list.index(abs_min)
taste_list.remove(taste_list[min_index])
print(sum(taste_list))

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

int main() {
  int N, K, sum;
  cin >> N >> K;
  sum = 1;
  for (int i = 0; i < N; i++) {
    if (sum <= K) sum *= 2;
    else sum += K;
  }
  cout << sum << endl;
}
      
    

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int W, H;
	static boolean[][] f;
	static int[][] size;
	static int[][] count;
	static int ans;

	public static void main(String[] args) {
		while (true) {
			W = sc.nextInt();
			if (W == 0) break;
			H = sc.nextInt();
			f = new boolean[H + 1][W + 1];
			size = new int[H + 1][W + 1];
			count = new int[H + 1][W + 1];
			for (int i = 0; i < H; ++i) {
				for (int j = 0; j < W; ++j) {
					f[i][j] = sc.next().equals("1");
				}
			}
			System.out.println(solve());
		}
	}

	static int solve() {
		ans = 999;
		int rest = 0;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (f[i][j]) ++rest;
				OUT: for (int k = 1;; ++k) {
					for (int r = i; r < i + k; ++r) {
						for (int c = j; c < j + k; ++c) {
							if (!f[r][c]) {
								size[i][j] = k - 1;
								break OUT;
							}
						}
					}
				}
			}
		}
		if (rest == 0) return 0;
		rec(0, 0, 0, rest);
		return ans;
	}

	static void rec(int r, int c, int num, int rest) {
		if (rest == 0) {
			ans = num;
			return;
		}
		if (num + 1 >= ans) return;
		if (c == W) {
			rec(r + 1, 0, num, rest);
			return;
		}
		if (!f[r][c] || count[r][c] != 0) {
			rec(r, c + 1, num, rest);
		}

		// prune
		boolean filled = true;
		for (int i = 0; i < size[r][c]; ++i) {
			if (count[r + i][c] == 0) {
				filled = false;
				break;
			}
		}
		if (filled && size[r][c + 1] >= size[r][c]) return;
		filled = true;
		for (int i = 0; i < size[r][c]; ++i) {
			if (count[r][c + i] == 0) {
				filled = false;
				break;
			}
		}
		if (filled && size[r + 1][c] >= size[r][c]) return;

		boolean use = false;
		for (int i = 0; i < size[r][c]; ++i) {
			for (int j = 0; j < size[r][c]; ++j) {
				if (count[r + i][c + j] == 0) {
					use = true;
					--rest;
				}
				count[r + i][c + j]++;
			}
		}
		if (use) {
			rec(r, c + 1, num + 1, rest);
		}
		for (int i = 0; i < size[r][c]; ++i) {
			for (int j = 0; j < size[r][c]; ++j) {
				count[r + i][c + j]--;
			}
		}
	}
}

Measured memory_bytes: 26012
N=gets.to_i
g = Array.new(N){[]} 
(N-1).times do |i|
  u,v,w = gets.split.map(&:to_i)
  g[u-1] << [v-1, w]
  g[v-1] << [u-1, w]
  g[u-1] << [u-1, 0]
  g[v-1] << [v-1, 0]
end

stack = []
stack << [0,0]
color = [false]*N
while !stack.empty?
  node, kyori = stack.pop
  color[node] = kyori % 2 == 0 ? 0 : 1
  g[node].each do |edge|
    if !color[edge[0]]
      stack << [edge[0], edge[1]+kyori]
    end
  end
end

puts color

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

#define ll long long
#define MAXN 200010
using namespace std;

int A[MAXN];
int cnt[MAXN];
int N;

int main()
{
	cin>>N;
	memset(cnt, 0, sizeof(cnt));
	for(int i = 1; i <= N; ++i)
	{
		cin>>A[i];
		cnt[A[i]]++;
	}
	ll total = 0;
	for(int i = 1; i <= N; ++i)
	{
		if(cnt[i] > 0)
			total += (ll)(cnt[i]) * (ll)(cnt[i]-1) / 2;
	}
	for(int i = 1; i <= N; ++i)
	{
			cout<<total - (cnt[A[i]]-1)<<endl;
	}
	
}


Measured memory_bytes: 4096
fun main(args: Array<String>) = shojin06c()

fun shojin06c() {
    val n = readLine()!!.toLong()

    var curr = 0L
    var i = 0

    while (curr < n) curr += ++i
    
    val answer = (1L..i).toList().let {
        if (n == curr) it else it - (curr - n)
    }.joinToString(System.lineSeparator())

    println(answer)
}


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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H-h)*(W-w) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>           
#include <string>             
using namespace std;          
                              
int main(void){               
  int n;                      
  cin >> n;                   
  int v[n],c[n],max = 0;      
  for(int i = 0; i < n;++i){  
    cin >> v[i];              
  }                           
  for(int i = 0; i < n;++i){  
    cin >> c[i];              
  }                           
  for(int i = 0; i < n;++i){  
    if(v[i]-c[i] > 0){        
      max += v[i]-c[i];       
    }                         
  }                           
                              
  cout << max <<endl;         
  return 0;                   
}                             
                              

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

int main() {
    int n;
    cin >> n;
    int w[n];
    for (int i = 1; i <= n; i++) {
        cin >> w[i];
    }
    
    int sum[n];
    sum[0] = 0;
    for (int i = 1; i <= n; i++) {
       sum[i] = w[i] + sum[i-1]; 
    }
    int ret = sum[n];
    for (int i = 1; i <= n; i++) {
       int tmp;
       tmp = abs(sum[n] - 2 * sum[i]);
       if (ret > tmp) {
           ret = tmp;
       }
    }

    cout << ret << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#define ll long long
#define FOR(i,t,x) for(int i=t;i<=x;i++)

using namespace std;

int ans,a,b,c;

int main(int argc, char const *argv[])
{
	cin>>a>>b>>c;
	int maks=max(a,max(b,c));
	while(a<(maks-1)){
		a+=2;ans++;
	}
	while(c<(maks-1)){
		c+=2;ans++;
	}
	while(b<(maks-1)){
		b+=2;ans++;
	}
	if(a==b&&b==c){
		cout<<ans<<endl;
		return 0;
	}
	if((a==maks&&b==maks)||(a==maks&&c==maks)||(b==maks&&c==maks)){
		ans+=2;
	}else{
		ans++;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> d1(n);
  vector<int> d2(n);
  rep(i, n){
    cin >> d1[i] >> d2[i];
  }
  bool flag=false;
  rep(i, n-2){
    if(d1[i]==d2[i] && d1[i+1]==d2[i+1] &&d1[i+2]==d2[i+2] ){
      flag=true;
      break;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
object Main extends App {
  val seq1 = for(i<-1 to 9) yield Vector(i,i,i)
  val seq2 = for(i<-1 to 7) yield Vector(i,i+1,i+2)

  def check(m:Vector[Int], count:Int,u:Int,v:Int):Boolean =
    if(m.length != count) false
    else if(count==2) m(0)==m(1)
    else
      (u to 8).exists( i=> check(m diff seq1(i),count-3,i+1,v)) || (v to 6).exists(i=> check(m diff seq2(i),count-3,u,i))

  Iterator.continually(readLine).takeWhile ( _!=null ).foreach { line =>
    val l = line.map(_.asDigit).toVector
    val m = (1 to 9).filter { i=> l.count( _==i ) < 4 && check(i+:l,14,0,0) }
    if(m.length>0) println(m.mkString(" ")) else println(0)
  }
}

Measured memory_bytes: 74372
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){	
  int x,y; cin>>x>>y;
  for(int i=0;i<x+1;i++){
      int b = x-i;
      if((2*i + 4*b) == y){
        cout<<"Yes\n";return;
      }
  }
  cout<<"No\n";
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //int t; cin >> t;
  //while(t--) solve();
  //
  solve();
  return 0;
}


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

int diceC (int [],int []);
void diceS(int []);
void diceE(int []);
void diceW(int []);
void diceN(int []);
void diceR(int []);

int main(){
	int d[6],da[6];
	string str;
	for(int i=0;i<6;i++) cin >> d[i];
	for(int i=0;i<6;i++) cin >> da[i];
		for(int k=0;k<4;k++){
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(diceC(d,da)){
					cout << "Yes" << endl;
					goto LOOP;
				}
				diceS(d);
			}
			diceE(d);
		}
		diceR(d);
		}
		cout << "No" <<endl;
		LOOP:;

	return 0;
}

void diceS(int a[6]){
	int w;
	w=a[0];
	a[0]=a[4];
	a[4]=a[5];
	a[5]=a[1];
	a[1]=w;
}


void diceE(int a[6]){
	int w;
	w=a[0];
	a[0]=a[3];
	a[3]=a[5];
	a[5]=a[2];
	a[2]=w;
}

void diceW(int a[6]){
	int w;
	w=a[0];
	a[0]=a[2];
	a[2]=a[5];
	a[5]=a[3];
	a[3]=w;
}

void diceN(int a[6]){
	int w;
	w=a[0];
	a[0]=a[1];
	a[1]=a[5];
	a[5]=a[4];
	a[4]=w;
}

void diceR(int a[6]){
	int w;
	w=a[1];
	a[1]=a[2];
	a[2]=a[4];
	a[4]=a[3];
	a[3]=w;
}

int diceC(int a[6],int b[6]){
	for(int i=0;i<6;i++){
		if(a[i]!=b[i]) return 0;
	}
	return 1;
}

Measured memory_bytes: 1160
//
// Created on 2018-12-22.
//
#include "bits/stdc++.h"

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<(n);++i)
#define RFOR(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define PB push_back
#define EB emplace_back
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    string n;
    cin >> n;

    int ans = 0;
    REP(i,4){
        if (n[i] == '2') ans++;
    }

    cout << ans<< endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  int k,t;  cin >> k >> t;
  vector<int> v(t);
  rep(i,0,t){
    cin >> v[i];
  }
  priority_queue<pii> que;
  rep(i,0,t){
    que.push(mp(v[i],i));
  }
  int cnt=0;
  int pre = -1;
  while(que.size()){
    pii x=que.top();  que.pop();
    if(!que.size()){
      if(x.se==pre) cnt++;
      else pre=x.se;
      if(x.fi-1!=0) que.push(mp(x.fi-1, x.se));
    }else{
      if(x.se==pre){
        pii y=que.top();  que.pop();
        pre=y.se;
        if(y.fi-1!=0) que.push(mp(y.fi-1, y.se));
        que.push(mp(x.fi, x.se));
      }else{
        pre=x.se;
        if(x.fi-1!=0) que.push(mp(x.fi-1, x.se));
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


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

bool is_prime(int N){
	for(int i = 2; i * i <= N; i++){
		if(N % i == 0){
			return false;
		}
	}
	return true;
}

int main(){
	int X;
	scanf("%d", &X);
	while(is_prime(X) == false){
		X++;
	}
	printf("%d\n", X);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int inp,i;
    scanf("%d",&inp);
    for(i=1;i<=9;i++)
        if((inp/i)>=1&&(inp/i)<=9)
            if(((float)inp/(float)i)-(inp/i)==0)
                break;
    if(i==10)
        printf("No");
    else
        printf("Yes");
    return 0;
}


Measured memory_bytes: 128
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int x[10], y[10];

double dist(int i, int j) {
	double dx = x[i] - x[j];
	double dy = y[i] - y[j];
	return pow(dx * dx + dy * dy, 0.5);
}
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> y[i];
	}
	double sum = 0.0;
	vector<int>v(n);
	for (int i = 0; i < n; i++) {
		v[i] = i + 1;
	}
	do {
		for (int i = 0; i < n - 1; i++)sum += dist(v[i], v[i + 1]);
	} while (next_permutation(v.begin(), v.end()));
	int count = 1;
	for (int i = 1; i <= n; i++) {
		count *= i;
	}
	cout << fixed << setprecision(10) << sum / count << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int k; cin >> k;
    ll now = 7;
    int ans = 1;
    while (now % k != 0) {
        ans++;
        now *= 10;
        now += 7;
        now %= k;
        if (ans > 1e7) {cout << -1 << endl; return 0;}
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

const ll MN = -1e18 - 99999999;

int main() {
    ll N, K;
    cin >> N >> K;

    vec<ll> P(N);
    rep(i, N) cin >> P[i], --P[i];

    vec<ll> C(N);
    rep(i, N) cin >> C[i];

    ll ans = MN;
    rep(i, N) {
        ll now = i;
        vector<int> loop;
        ll nowS = 0;

        while (1) {
            now = P[now];
            nowS += C[now];
            loop.emplace_back(C[now]);
            if (now == i) break;
        }

        ll tmp = 0;
        ll sz  = loop.size();
        rep(j, sz) {
            tmp += loop[j];
            if (j == K) break;
            if (nowS > 0) {
                ll cnt = (K - (j + 1)) / sz;
                ans = max(ans, nowS * cnt + tmp);
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3728
n,m = map(int, input().split())
t = [[n] for i in range(n)]
for i in range(m):
  a,b = map(int, input().split())
  t[a-1].append(b-1)
g = []
for i in t:
  g.append(min(i))
k = 0
ans=0
while k <=n-1:
  e = min(g[k:])
  if e==n:
    break
  ans+=1
  k = e
print(ans)

Measured memory_bytes: 27108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int a, b, t;
	cin >> a >> b >> t;
  	
	cout << (t/a) * b << endl;
    
  	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>
#include <functional>

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
vector<int> l;

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll ans = 0;
	int n;
	cin >> n;

	REPS(i, 9) {
		REPS(j, 9) {
			if (n == i*j) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
'''input
10
2184 2126 1721 1800 1024 2528 3360 1945 1280 1776
'''
n = input()
arr = map(int,raw_input().split())
ans = 0
for i in range(n):
	while arr[i]%2 == 0:
		ans +=1
		arr[i] /= 2
print ans 

Measured memory_bytes: 32748
def read():
    A, B, C = map(int, input().split())
    K = int(input().strip())
    return A, B, C, K

def solve(A, B, C, K):
    k = 0
    while A >= B:
        B *= 2
        k += 1
    while B >= C:
        C *= 2
        k += 1
    return "Yes" if k <= K else "No"


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


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

using namespace std;
int a[101];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n, m, c; cin >> n >> m >> c;
	int ans = 0;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int k = 0; k < m; k++) {
			int x; cin >> x;
			sum += x * a[k];
		}
		if (sum +c > 0)ans += 1;
	}

	cout << ans << '\n';




}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
const ll N=2e5+3;
map<ll,ll>mp;
ll a[N];
int main()
{
    ft
    ll t,i,j,n,m,l,r=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        mp[i-a[i]]++;
    }
    for(i=1;i<=n;i++)
    {
        r+=(mp[i+a[i]]);
    }
    cout<<r<<"\n";
    return 0;
}



Measured memory_bytes: 27848
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll l, r, d;
  cin >> l >> r >> d;
  ll cnt = 0;
  for (ll i = l; i <= r; ++i) {
    if (i%d == 0) ++cnt;
  }
  cout << cnt << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(void)
{
	int D,L,a,s;
	scanf("%d %d",&D,&L);
	a=D/L;
	s=D%L;
	if(0==D%L){
		printf("%d\n",a);
	}
	else{
		printf("%d\n",a+s);
	}
	return 0;
}


Measured memory_bytes: 2756
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// mint N;

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

// combination c(N);
// mint ans = c(N,n);
// cout << ans.x << endl;

// -------------------------------------------------------------


int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  ll sum=0;
  vector<ll> Sum(N);
  for(int i=0; i<N; i++){
    cin >> a[i];
    sum += a[i];
  }
  ll sum_f=a[0];
  ll sum_b=sum-a[0];
  ll ans=abs(sum_f-sum_b);
  for(int i=1; i<N-1; i++){
    sum_f += a[i];
    sum_b -= a[i];
    ans = min(ans, abs(sum_f-sum_b));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=100005;

int n,A[MAXN];

bool solve()
{
	if(n==1)
		return false;
	int cnt[2]={0,0};
	for(int i=1;i<=n;i++)
		cnt[A[i]&1]++;
	if(cnt[0]&1)
		return true;
	if((cnt[0]&1)==0&&cnt[1]>=2)
		return false;
	int pos=-1;
	for(int i=1;i<=n&&pos==-1;i++)
		if(A[i]&1)
			pos=i;
	if(A[pos]==1)
	{
		int sum=0;
		for(int i=1;i<=n;i++)
			sum^=(A[i]-1)&1;
		return sum;
	}
	A[pos]--;
	int g=A[1];
	for(int i=2;i<=n;i++)
		g=__gcd(g,A[i]);
	for(int i=1;i<=n;i++)
		A[i]/=g;
	return solve()^1;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&A[i]);
	if(solve())
		puts("First");
	else
		puts("Second");
	
	return 0;
}


Measured memory_bytes: 512
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var S = cin.Read;
            var T = cin.Read;
            WriteLine(S.Equals(T.Substring(0,T.Length-1)) ? "Yes" : "No");
        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }


        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 26268
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
map<string, int> id;
int A[100], memo[100];
vector<int> G[100];

int dfs(int x) {
  if (memo[x] != -1) return memo[x];
  int m = A[x];
  if (G[x].size()) {
    int s = 0;
    for (int t : G[x]) s += dfs(t);
    m = min(m, s);
  }
  return memo[x] = m;
}

int read() {
  string s;
  cin >> s;
  assert(id.find(s) != id.end());
  return id[s];
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  while (cin >> N) {
    if (N == 0) break;
    id.clear();
    rep(i, N) G[i].clear();
    rep(i, N) {
      string s;
      cin >> s >> A[i];
      id[s] = i;
    }
    cin >> M;
    rep(_, M) {
      int s = read();
      int k;
      cin >> k;
      rep(i, k) G[s].pb(read());
    }
    rep(i, N) memo[i] = -1;
    int o = read();
    cout << dfs(o) << "\n";
  }
  return 0;
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<ll> v, w;
  rep(i,N){
    ll a, b;
    cin >> a >> b;
    if(N%2==0){
      a*=2;
      b*=2;
    }
    v.push_back(a);
    w.push_back(b);
  }
  
  sort(ALLOF(v));
  sort(ALLOF(w));

  if(N%2==0){
    ll x1 = v[N/2-1];
    ll x2 = v[N/2];
    ll y1 = w[N/2-1];
    ll y2 = w[N/2];
    ll x = (x1+x2)/2;
    ll y = (y1+y2)/2;
    cout << y - x + 1 << endl;
  }else{
    ll x = v[N/2];
    ll y = w[N/2];
    
    cout << y - x + 1 << endl;
  }
  
  return 0;
}




Measured memory_bytes: 6660
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	while(getline(cin, s)){
		for(int i = 0; i < 26; i++){
			for(int i = 0; s[i] != '\0'; i++){
				if(s[i] >= 97 && s[i] <= 122) s[i] = (s[i] - 97 + 1) % 26 + 97;
			}
			if(s.find("the", 0) != string::npos || s.find("this", 0) != string::npos || s.find("that", 0) != string::npos){
				cout << s << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  string S;
  rep(i, N) cin >> S;
  
  vector<int> east(N);
  vector<int> west(N);
  rep(i, N){
  	if(i==0){
      east[0]=0;
      west[0]=0;
      if(S[i] == 'E') east[0] = 1;
      else west[0] = 1;
    }else{
      if(S[i] == 'E'){
        east[i] = east[i-1]+1;
        west[i] = west[i-1];
      }
      else{
        west[i] = west[i-1]+1;
        east[i] = east[i-1];
      }
    }
  }
  
  int min = N;
  rep(i, N){
    int sum = 0;
    
    if(i==0){
      if(S[i] == 'E') sum = east[N-1] - 1;
      else sum = east[N-1];
      if(sum < min) min = sum;
    }else{
      if(S[i] == 'W') sum = west[i-1] + east[N-1] - east[i-1];
      else sum = west[i-1] + east[N-1] - east[i];
      if(sum < min) min = sum;
    }
  }
  
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int N, M, V, P;
vector<ll> A;

bool check(int idx) {
    // cout << "# idx : " << idx << " , A[idx] : " << A[idx] << endl;
    ll big = 0, les = 0;
    REP(i, 0, N) {
        if (A[idx] + M < A[i]) big++;
        if (A[idx] >= A[i]) les++;
    }

    if (big >= P) return false;
    ll rem = V - (P - 1) - les;
    // cout << "--> big : " << big << " les : " << les << " rem : " << rem << endl;
    rem *= M;
    for (int i = idx + 1; i < N - P + 1; i++) {
        rem -= A[idx] + M - A[i];
    }    

    if (rem < 1) return true;
    else return false;
}

int main() {
    cin >> N >> M >> V >> P;
    A.resize(N); 
    REP(i, 0, N) cin >> A[i];
    sort(ALL(A));

    int ng = -1, ok = N;
    while (ok - ng > 1) {
        int mid = ng + (ok - ng) / 2;
        if (check(mid)) ok = mid;
        else ng = mid;
    }

    cout << N - ok << endl;
    return 0;
}

Measured memory_bytes: 1024
S = input()
s = int(S[0:2])
t = int(S[2:4])

if s >= 1 and s <= 12 and t >= 1 and t <= 12:
  print('AMBIGUOUS')
elif s >= 1 and s <= 12:
  print('MMYY')
elif t >= 1 and t <= 12:
  print('YYMM')
else:
  print('NA')

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/27  Problem: ABC 113 B / Link: http://abc113.contest.atcoder.jp/tasks/abc113_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */


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

	LL N, T, A; cin >> N >> T >> A;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	double ans = LINF;
	int id = 0;
	FOR(i, 0, N) {
		double ret = T - a[i] * 0.006;
		ret = abs(A - ret);
		if (ans > ret) {
			ans = ret;
			id = i + 1;
		}
	}
	cout << id << endl;

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
#define watch(x) cout << (#x)<<" = "<<x<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 2e5 + 10;
int depth[N];
ll n, x, m;
ll getNextNode(int node) {
	return (1LL * node * node) % m;
}
ll forward(ll node, ll k) {
	if (k == 0)
		return node;
	return node + forward(getNextNode(node), k - 1);
}
ll go(ll node, ll k, int dis = 1) {
	if (k == 0)
		return node;
	if (depth[node]) {
		int cycle = dis - depth[node];
		depth[node] = 0;
		return forward(node, k % cycle) + forward(node, cycle - 1LL) * (k / cycle);
	}
	depth[node] = dis;
	return node + go(getNextNode(node), k - 1, dis + 1);
}
int main() {
	file();
	fast();
	cin >> n >> x >> m;
	cout << go(x, n - 1) << endl;
	return 0;
}

Measured memory_bytes: 4020
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


class RangeAddSum():
    def __init__(self, n):
        i = 1
        while 2**i <= n:
            i += 1
        self.N = 2**i
        self.A = [0] * (self.N*2)
        self.B = [0] * (self.N*2)

    def add(self, a, b, x, k, l, r):
        def ina(k, l, r):
            if a <= l and r <= b:
                self.A[k] += x
            elif l < b and a < r:
                self.B[k] += (min(b, r) - max(a, l)) * x
                m = (l+r) // 2
                ina(k*2+1, l, m)
                ina(k*2+2, m, r)

        ina(k, l, r)

    def query(self, a, b, k, l, r):
        def inq(k, l, r):
            if b <= l or r <= a:
                return 0

            if a <= l and r <= b:
                return self.A[k] * (r - l) + self.B[k]

            res = (min(b, r) - max(a, l)) * self.A[k]
            m = (l+r) // 2
            res += inq(k*2+1, l, m)
            res += inq(k*2+2, m, r)
            return res

        return inq(k, l, r)

def main():
    n,q = LI()
    qa = [LI() for _ in range(q)]

    ras = RangeAddSum(n)
    rr = []
    for qi in qa:
        s = qi[1] - 1
        t = qi[2]
        if qi[0] == 0:
            x = qi[3]
            ras.add(s, t, x, 0, 0, n)
        else:
            rr.append(ras.query(s, t, 0, 0, n))

    return JA(rr, "\n")

# start = time.time()
print(main())
# pe(time.time() - start)






Measured memory_bytes: 45100
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    int n;
    ll w;
    cin >> n >> w;
    vector<pair<long long, int>> things(n);
    rep(i, n){
        ll w, v;
        cin >> w >> v;
        things[i] = make_pair(w, v);
    }

    int maxValue = 1e3 * n;

    int ans = 0;
    vvll dp(n + 1, vll(maxValue + 5, 1e9 + 5));
    dp[0][0] = 0;
    // i個までの荷物を考えたとき価値jを実現できる最小の重量を考える
    for(int i = 1; i <= n; i++){
        ll weight, value;
        weight = things[i-1].first;
        value = things[i-1].second;
        for(int j = 0; j < maxValue + 5; j++){
            if(j < value){
                dp[i][j] = dp[i - 1][j];
            }
            else{
                ll t1, t2;
                t1 = dp[i - 1][j - value] + weight;
                t2 = dp[i - 1][j];
                dp[i][j] = min(t1, t2);
            }
            if(dp[i][j] <= w and dp[i][j] != 0) ans = max(ans, j);
        }
    }

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


Measured memory_bytes: 80256
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

	int a,b,c,d;

int main()
{
	cin>>a>>b>>c>>d;
	if(a+b>c+d)cout<<"Left";
	else if(a+b<c+d)cout<<"Right";
	else cout<<"Balanced";
}

Measured memory_bytes: 256