akhauriyash/Code-Regression huggingface dataset:
package main

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

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

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`
	8
	ABABBABA
										`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	n := next()

	w := 0
	for i := 0; i < len(n); i++ {
		n, _ := strconv.Atoi(n[i : i+1])
		w = (w + n) % 9
	}

	ans := "No"
	if w == 0 {
		ans = "Yes"
	}

	//fmt.Fprintln(out, "[DEBUG]", a)
	fmt.Fprintln(out, ans)

}

// 挿入ソート配列
type slist struct {
	l []int
}

func makeSlist() slist {
	return slist{[]int{}}
}

func (s *slist) add(a int) {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	if pos < len(s.l) {
		s.l = append(s.l[:pos+1], s.l[pos:]...)
		s.l[pos] = a
	} else {
		s.l = append(s.l, a)
	}
}
func (s slist) contains(a int) bool {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	return pos < len(s.l) && s.l[pos] == a
}

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

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

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	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 chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func printArray(a []int) {
	for i := 0; i < len(a); i++ {
		if i >= 1 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, a[i])
	}
	fmt.Fprintln(out)
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func sign(x int) int {
	if x == 0 {
		return 0
	}
	if x > 0 {
		return 1
	}
	return -1
}
func log10(x int) float64 {
	return math.Log10(float64(x))
}
func divCeil(shi, bo int) int {
	ans := shi / bo
	if shi%bo != 0 {
		ans++
	}
	return ans
}


Measured memory_bytes: 2204
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){
	
	int n,k;
	cin >> n >> k;
	if(n >= k){
		n = n%k;
	}
	cout << min(k-n,n) << endl;

	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://abc161.contest.atcoder.jp/tasks/abc161_a

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
const int maxm = 1e6;
int a[maxn], sum[maxn];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum[a[i]]++;
	}
	for (int i = 1; i <= maxm; i++) {
		sum[i] += sum[i - 1];
	}
	int ans = 0;
	for (int i = 1; i <= maxm; i++) {
		int t = sum[i];
		if (n - t == t) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int MOD = 998244353;
const int N = 1e5 + 5;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}

int binpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int divv(int a, int b) {
	return mul(a, binpow(b, MOD - 2));
}

int f[N];

void init() {
	f[0] = 1; 
	for (int i = 1; i < N; i++) {
		f[i] = mul(i, f[i - 1]);
	}
}

int C(int n, int k) {
	return divv(f[n], mul(f[k], f[n - k]));
}

int cnt_array(int cnt, int n) {
	if (cnt == 0) return 0;
	return C(n + cnt - 1, n);
}


int solve(int db, int on, int n, int rk) {
	rk -= db;
	int ans = 0;
	for (int sel = 0; sel <= db && sel <= n; sel++) {
		int cnt = cnt_array(on + sel, n - sel);
		cnt = mul(cnt, C(db, sel));
		cnt = mul(cnt, binpow(2, sel));
		ans = add(ans, cnt);
	}
	return ans;
}

int n, k;

int solve_i(int i) {
	int db = 0;
	int on = 0;
	int mid = 0;
	for (int x = 1; x <= k; x++) {
		if (1 <= (i - x) && (i - x) <= k) {
			if (2 * x == i) {
				mid = 1;
			} else {
				db++;
			}
		} else {
			on++;
		}
	}
	db /= 2;
	if (mid) {
		int ff = solve(db, on, n, k - 1);
		int ss = solve(db, on, n - 1, k - 1);
		return add(ff, ss);
	} else {
		return solve(db, on, n, k);
	}
}

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

	init();

	cin >> k >> n;
	for (int i = 2; i <= 2 * k; i++) {
		cout << solve_i(i) << '\n';
	}
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

signed main(){
	int N;
	string A, B, C;
	cin >> N >> A >> B >> C;
	int res = 0;
	for(int i = 0; i < N; ++i) {
		if (A[i] == B[i] && B[i] == C[i]) {
			res += 0;
		} else if(A[i] == B[i] || B[i] == C[i] || C[i] == A[i]) {
			res += 1;
		} else {
			res += 2;
		}
	}
	cout << res << 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 PI 3.141592653589793238

bool check(vector<string> s, int x, int y) {
	if (s[y][x] == '.') {
		return true;
	}
	else {
		bool judge = false;
		if (1 <= x && s[y][x - 1] == '#') {
			judge = true;
		}
		else if (x < s[0].size() - 1 && s[y][x + 1] == '#') {
			judge = true;
		}
		else if (1 <= y && s[y - 1][x] == '#') {
			judge = true;
		}
		else if (y < s.size() - 1 && s[y + 1][x] == '#'){
			judge = true;
		}
		return judge;
	}
}

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> s(H);
	rep(i, H) {
		cin >> s[i];
	}
	rep(i, H) {
		rep(j, W) {
			if (!check(s, j, i)) {
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int r;
int main () {
	cin >> r;
	if (0 <= r && r < 1200) {
		cout << "ABC";
	} else if (1200 <= r && r < 2800) {
		cout << "ARC";
	} else {
		cout << "AGC";
	}

}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

ll triple(ll a) {
    return a * a * a;
}

int main() {
    ll N, K;
    cin >> N >> K;
    ll ans = triple(N / K);
    if (K % 2 == 0) {
        ans += triple((N + K / 2) / K);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.*;

public class Main {

  public static void main(String[] args) {
    Main m = new Main();
    m.exec();
  }

  private void exec() {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    Map<String, Integer> nMap = new HashMap<String, Integer>();
    putMap(scan, n, nMap);
    int m = scan.nextInt();
    Map<String, Integer> mMap = new HashMap<String, Integer>();
    putMap(scan, m, mMap);
    
    int result = 0;
    for (Entry<String, Integer> entry : nMap.entrySet()) {
      String key = entry.getKey();
      int value = entry.getValue();      
      if (mMap.containsKey(key)) {
        value -= mMap.get(key);
      }
      if (value > result) {
        result = value;
      }
    }
    System.out.println(result);
  }

  private void putMap(Scanner scan, int count, Map<String, Integer> map) {
    for (int i = 0; i < count; i++) {
      String key = scan.next();
      if (map.containsKey(key)) {
        map.put(key, map.get(key) + 1);
      } else {
        map.put(key, 1);
      }
    }
  }
}

Measured memory_bytes: 21204
n = gets.to_i
l = gets.chomp.split.map(&:to_i).sort!
res = 0

0.step(n - 3) do |i|
  (i + 1).step(n - 2) do |j|
    r = l[(j + 1)...n]
    a, b = l[i], l[j]
    k = r.bsearch_index {|c| c >= a + b } || r.size
    res += (k + j) - j
  end
end
puts res


Measured memory_bytes: 14220
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  
  bool flag = true;
  
  ll tmp = 0;
  for (int i = 1; i < n; ++i) {
    tmp ^= a[i];
  }
  if (tmp == a[0]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double t = acos(-1) * 2;

    double z0 = t / 12 / 60 * (h * 60 + m);
    double x0 = a * cos(z0);
    double y0 = a * sin(z0);
    double x1 = b * cos(t / 60 * m);
    double y1 = b * sin(t / 60 * m);

    double x = x0 - x1;
    double y = y0 - y1;

    printf("%.12f\n", sqrt(x * x + y * y));

    return 0;
}

Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    char[] s = scanner.next().toCharArray();
    int[] si = new int[N];
    for (int i = 0; i < N; i++) {
      si[i] = s[i] == 'o' ? 0 : 1;
    }

    for (int[] t : new int[][] {{0, 0}, {0, 1}, {1, 0}, {1, 1}}) {
      int[] a = test(t, si, N);
      if (a != null) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < N; i++) sb.append(a[i] == 0 ? 'S' : 'W');
        System.out.println(sb.toString());
        return;
      }
    }
    System.out.println(-1);
  }

  private static int[] test(int[] t, int[] s, int N) {
    int[] a = new int[N];
    a[0] = t[0];
    a[1] = t[1];
    for (int i = 1; i < N - 1; i++) a[i + 1] = a[i - 1] ^ a[i] ^ s[i];
    if ((a[N - 2] ^ a[N - 1] ^ s[N - 1]) != a[0] || (a[N - 1] ^ a[0] ^ s[0]) != a[1]) {
      return null;
    }
    return a;
  }
}


Measured memory_bytes: 28280
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int compare_int(const void *a, const void *b)
{
  return *(int*)a - *(int*)b; 
}

int main()
{
  int n;
  int xs[3];

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &xs[0], &xs[1], &xs[2]);
    qsort(xs, 3, sizeof(int), compare_int);
    if (pow(xs[0], 2.0) + pow(xs[1], 2.0) == pow(xs[2], 2.0)) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }

  return 0;
}



Measured memory_bytes: 2496
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1) {
		int n, r, p, c;
		vector<int> cards;	//山札を意味するvector

		cin >> n >> r;		//山の枚数とシャッフル回数を取得する

		for(int i = n; i > 0; i --)
			cards.push_back(i);

		if( n == 0 && r == 0) break;

		for(int i = 0; i < r; i++) {
			cin >> p >> c;
			vector<int> tmp;	//抜き取った札を一時的に記憶するvector

			//c枚の札を抜き取る
			for(int j = 0; j < c; j++)  
				tmp.push_back(cards.at(p - 1 + j));

			//p-1枚の札を下に移す
			for(int j = p - 2; j >= 0; j--)	
				cards.at(j + c) = cards.at(j);

			//c枚の札を上に戻す
			for(int j = 0; j < c; j++) 
				cards.at(j) = tmp.at(j);
		}

		//答えの出力
		cout << cards.at(0) << endl;
	}

	//while(1){}
	return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  	int N, D;  	
    cin >> N >> D;
    cout << (N-1)/(2*D+1)+1 <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (auto i = 0; i < n; i++)
    {
        int hi;
        cin >> hi;
        h[i] = hi;
    }

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

    int ans = 1000000007;

    for (auto i = 0; i + k - 1 < n; i++)
    {
        int tmp = h[i + k - 1] - h[i];
        if(tmp < ans){
            ans = tmp;
        }
    }

    cout << ans << endl;
}

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

namespace AtTest.ABC_124
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] hs = ReadInts();
            int max = hs[0];
            int res = 1;
            for(int i = 1; i < n; i++)
            {
                if (hs[i] >= max)
                {
                    res++;
                    max = hs[i];
                }
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

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

ll h, w, ans = 0;

int main() {

    cin >> h >> w;
    
    if(h == 1 || w == 1) {
        ans = 1;
    }
    else ans = (h * w + 1) / 2;


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
s = input()

ans = []
for i in range(len(s)):
    if s[i] == '0':
        ans.append('0')
    elif s[i] == '1':
        ans.append('1')
    elif s[i] == 'B' and not len(ans) == 0:
        ans.pop()
print(''.join(ans))

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <sstream>
#include <iomanip>
using namespace std;


#define int int64_t
#define vi vector<int>
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define all(x) (x).begin(), (x).end()
#define vii vector< vector<int> >
#define rip(dp, n, m) vector< vector<int> > dp(n, vector<int>(m,0))
#define ff first
#define ss second
#define pii pair<int64_t, int64_t>
#define miv map<int, vector<int> >
#define mp make_pair
#define pb push_back
#define prr(x) cout << (#x) <<'	' << (x) << endl
#define pr(x) cout  << (x) << endl
#define f(i,n) for(i=0;i<n;i++)
#define pqb priority_queue<int>
#define pqs priority_queue<int,vi,greater<int> >
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x) int x; cin>>x; while(x--)
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int32_t main()
{
    FIO;
    int i, j, n, m, k, l, t;
   cin >> n;
   if(n>=30) cout << "Yes";
   else cout << "No";
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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 (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;
struct edge{ll from,to,cost;};


int  main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  ll n,m;
  cin>>n>>m;
  vector<edge>edges(m);
  rep(i,m)
  {
    ll a,b,c;
    cin>>a>>b>>c;
    edges[i]={a,b,c};
  }
  bool update=0;
  ll mm=-1e13;
  vector<ll>dist(n+1,mm);
  dist[1]=0;
  rep(i,n+1)
  {
    update=0;
    rep(j,m)
    {
      if(dist[edges[j].from]==mm)continue;
      bool tmp=chmax(dist[edges[j].to],dist[edges[j].from]+edges[j].cost);
      if(edges[j].to==n)update|=tmp;
    }
  }
  if(update)cout<<"inf"<<endl;
  else cout<<dist[n]<<endl;

  return 0;

}


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

typedef deque<int> DEQUE;
const int MAXN = 1e5+10;
struct Node{
	vector<int> Son;
	int col;
	bool B,W;
	int fa;
}node[MAXN];

DEQUE QB,QW;

void LCM(int x,int fa){
	int Size=node[x].Son.size();
	int k;
	for(int i=0;i<Size;i++){
		k=node[x].Son[i];
		if(k==fa)	continue;
		LCM(k,x);
		//node[x].B=(node[x].B||node[k].B);
		node[x].W=(node[x].W||node[k].W);
	}
	//if(node[x].B)	QB.push_back(x);
	if(node[x].W)	QW.push_back(x);
}

int dfs(int x,int fa,int This){
	if(x==This)	return 0;
	int sum=0;
	int Size=node[x].Son.size();
	int k;
	for(int i=0;i<Size;i++){
		k=node[x].Son[i];
		if(k==fa)	continue;
		sum+=dfs(k,x,This);
	}
	return sum+1;
}


int main(){
	int N,a,b;
	scanf("%d",&N);
	for(int i=1;i<N;i++){
		scanf("%d%d",&a,&b);
		node[a].Son.push_back(b);
		node[b].Son.push_back(a);
	}
	node[1].B=true;
	node[N].W=true;
	LCM(1,-1);
	int cB=1,cW=N;
	while(!QW.empty()){
		if(!QW.empty()){
			//if(!QW.empty()){
				cB=QW.back();
				QW.pop_back();
			
		}
		if(!QW.empty()){
			cW=QW.front();
			QW.pop_front();
		}
		
	}
	
	int p1=dfs(1,-1,cW);
	int p2=dfs(N,-1,cB);
	if(p1>p2){
		printf("Fennec");
	}else{
		printf("Snuke");
	}
	printf("\n");
	return 0;
	
}

Measured memory_bytes: 13952
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a < b)
			System.out.println("a < b");
		else if(a > b)
			System.out.println("a > b");
		else
			System.out.println("a == b");
	}
}

Measured memory_bytes: 17156
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
while(1){
int i,j,l,a,b;
long long d[101][101][4]={0};
scanf("%d%d",&a,&b);
if(a==0&&b==0)
return 0;
d[1][0][0]=1;
d[0][1][2]=1;
for(i=0;i<a;i++){
for(j=0;j<b;j++){
for(l=0;l<4;l++){
if(l==0){
d[i+1][j][0]=(d[i+1][j][0]+d[i][j][0])%100000;
d[i][j+1][1]=(d[i][j+1][1]+d[i][j][0])%100000;
}
if(l==1)
d[i][j+1][2]=(d[i][j+1][2]+d[i][j][1])%100000;
if(l==2){
d[i][j+1][2]=(d[i][j+1][2]+d[i][j][2])%100000;
d[i+1][j][3]=(d[i+1][j][3]+d[i][j][2])%100000;
}
if(l==3)
d[i+1][j][0]=(d[i+1][j][0]+d[i][j][3])%100000;
}
}
}
printf("%d\n",(d[a-1][b-1][0]+d[a-1][b-1][1]+d[a-1][b-1][2]+d[a-1][b-1][3])%100000);
}
return 0;
}



Measured memory_bytes: 3524
#include <stdio.h>

int main(void)
{
	int m, d, d1, d10, count;
	scanf("%d %d", &m, &d);
	d1 = d % 10;
	d10 = d / 10;

	int i, j, tmp;
	count = 0;
	for (i = 2; i < d10; i++)
	{
		if ((tmp = m / i) > 9)
			count += 8;
		else if (tmp > 2)
			count += tmp - 1;
	}
	if (i == d10 && d1 >= 2 && (tmp = m / i) >= 2)
		count += tmp > d1 ? d1 - 1 : tmp - 1;
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 128
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for i in range(N):
    a = bisect.bisect_left(A, B[i])
    c = bisect.bisect_right(C, B[i])
    ans += a*(N-c)

print(ans)


Measured memory_bytes: 105572
#include <iostream>
using namespace std;
using ll = long long;

int main(){
        int n,i,cnt=0;
        ll a,m=1e9+7,ans=0;
        cin >> n;
        for(i=0;i<n;++i){
                cin >> a;
                if(a<0){
                        ++cnt;
                        a *= -1;
                }
                m = min(m,a);
                ans += a;
        }
        if(cnt%2==0) cout << ans << endl;
        else cout << ans-2*m << endl;
        return 0;
}

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

int main(){
  int N,M,i,count;
  double total;
  total=0;
  count=0;
  cin >> N >> M;
  vector<int> A(N);
  
  for(i=0;i<N;i++){
    cin >> A.at(i);
    total=total+A.at(i);
  }
  
  total=total/(4.0*M);
  
  for(i=0;i<N;i++){
    if(total<=A.at(i)){
      count++;
    }
  }
  
  if(count>=M){
    cout << "Yes" << endl;
    return 0;
  }
  
  cout << "No" << endl;
  return 0;
}

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

using namespace std;

const int INF = 1e9;

struct Edge {
    int from, to, cap, flow, cost;
    Edge(int from, int to, int cap, int flow, int cost):from(from), to(to), cap(cap), 
    flow(flow), cost(cost){}   
};

struct MaxflowMinCost {
    int n;
    vector<Edge> edges;
    vector<vector<int>> g;
    
    vector<int> p; //The id of the edge that connects to a vertex on the shortest path
    vector<int> a; //The possible flow change from the start to a vertex
    int flow = 0;
    int cost = 0;
    int f; //flow limit
    
    MaxflowMinCost(int n) : n(n) {
        g.assign(n + 1, vector<int>());
    }
    
    void addEdge(int from, int to, int cap, int cost) {
        edges.push_back(Edge(from , to, cap, 0, cost));
        edges.push_back(Edge(to, from, 0, 0, -cost));
        g[from].push_back(edges.size() - 2);
        g[to].push_back(edges.size() - 1);   
    }
    
    int solve(int s, int t, int f) {
        this->f = f;
        while (bellmanFord(s, t)) {
        }
        return flow;
    }
    
    bool bellmanFord(int s, int t) {
        vector<int> d(n + 1, INF); //distance from s
        vector<bool> inq(n + 1, false);
        p.assign(n + 1, -1);
        a.assign(n + 1, 0);
           
        queue<int> q;
        p[s] = -2;
        a[s] = INF;
        d[s] = 0;
        inq[s] = true;
        
        q.push(s);
        
        while (!q.empty()) {
            int u = q.front(); q.pop();
            inq[u] = false;
            for (int eid: g[u]) {
                Edge e = edges[eid];
                if (e.cap > e.flow && d[e.to] > d[u] + e.cost) {
                    d[e.to] = d[u] + e.cost;
                    p[e.to] = eid;
                    a[e.to] = min(a[u], e.cap - e.flow);
                    if (!inq[e.to]) { 
                        q.push(e.to);
                        inq[e.to] = true;
                    }
                }
            }
        }
        if (d[t] == INF) {
            return false;
        }
        int aug = min(f, a[t]);
        f -= aug;
        
        flow += aug;
        cost += d[t] * aug;
     
        for (int u = t; u != s; u = edges[p[u]].from) {
            edges[p[u]].flow += a[t];
            edges[p[u] ^ 1].flow -= a[t];
        }
        
         if (f == 0) {
            return false;
        }
        
        return true;
    }   
};

int main() {
    int v, e, s, t, f;
    cin >> v >> e >> f;
    s = 0;
    t = v - 1;
    MaxflowMinCost maxflow(v);
    for (int i = 0; i < e; i++) {
        int from, to, cap, cost;
        cin >> from >> to >> cap >> cost;
        maxflow.addEdge(from, to, cap, cost);
    }
    int ans = maxflow.solve(s, t, f);
    if (ans < f) {
        cout << -1 << endl;
    }
    else {
        cout << maxflow.cost << endl;
    }
    return 0;
    
}

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

long long int ans; 
long long a,b,c,k;
int main(){
	cin>>a>>b>>c>>k;
	if(k&1){
		cout<<b-a<<endl;
	}else{
		cout<<a-b<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib> 
using namespace std;

long long  dp[2][100005];
long long a[100005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(int i=0;i<100004;i++)
	{
		dp[0][i]=-1e18;
		dp[1][i]=-1e18;
	}
	dp[0][1]=a[1];
	for(int i=2;i<=n;i++)
	{
		dp[0][i]=max(dp[0][i-1],dp[1][i-1])+a[i];
		dp[1][i]=max(dp[0][i-1]-2*a[i-1]-a[i],dp[1][i-1]+2*a[i-1]-a[i]);
	}
	printf("%lld\n",max(dp[0][n],dp[1][n]));
	
	
	return 0;
} 

Measured memory_bytes: 2560
#include <queue>
#include <utility>
#include <vector>
#include <unordered_map>
#include <map>
// #include <fstream>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>

using namespace std;
const long long mod = 1000000007;
int n;
vector<long double> X(50);
vector<long double> Y(50);

const long double eps = 0.0000001;

long double calc2(long double x, long double y) {
    long double ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, sqrt((X[i]-x)*(X[i]-x) + (Y[i]-y)*(Y[i]-y)));
    }
    return ans;
}

long double calc(long double x) {
    long double l = 0;
    long double r = 1000;
    while (r-l > eps) {
        long double y1 = l + (r - l) / 3;
        long double y2 = r - (r - l) / 3;
        long double a = calc2(x, y1);
        long double b = calc2(x, y2);
        if (a < b) {
            r = y2;
        } else {
            l = y1;
        }
    }

    return calc2(x,l);
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> X[i] >> Y[i];
    }

    long double l = 0;
    long double r = 1000;
    while (r-l > eps) {
        long double x1 = l + (r - l) / 3;
        long double x2 = r - (r - l) / 3;
        long double a = calc(x1);
        long double b = calc(x2);
        if (a < b) {
            r = x2;
        } else {
            l = x1;
        }
    }

    long double ans = calc(l);

    cout << setprecision(10) << ans;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BCheckpoints {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, m;
	    in >> n >> m;
	    vector<pair<ll, ll>> ab;
	    int a, b;
	    for(int i=0; i<n; i++){
	        in >> a >> b;
	        ab.push_back(make_pair(a, b));
	    }
	    vector<pair<ll, ll>> cd;
	    int c, d;
	    for(int i=0; i<m; i++){
	        in >> c >> d;
	        cd.push_back(make_pair(c, d));
	    }

	    vector<int> res(n);
	    for(int i=0; i<n; i++){
	        ll mi = inf;
	        int ind = 0;
	        for(int j=0; j<m; j++){
                ll d = abs(ab[i].first - cd[j].first) + abs(ab[i].second - cd[j].second);
                if(d < mi){
                    ind = j;
                    mi = d;
                }
	        }
	        res[i] = ind;
	    }

	    for(auto const& e : res){
	        out << e+1 << endl;
	    }
	}
};


int main() {
	BCheckpoints solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import sys

def main():
  S = input()
  T = input()
  lenS = len(S)
  lenT = len(T)
  for i in range(lenS-lenT,-1,-1):
    sub = S[i:i+lenT]
    for j in range(lenT):
      if sub[j]!=T[j] and sub[j]!="?":
        break
    else:
      S = S[:i]+T+S[i+lenT:]
      S=S.replace("?","a")
      print(S)
      sys.exit()
      break
    continue
  print("UNRESTORABLE")

main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll  = long long;
using v   = vector<int>;
using P   = pair<int,int>;
using vp  = vector<P>;
using vvp = vector<vp>;

int main(){
    char b;cin>>b;
    string s="ACGT";
    rep(i,4){
        if(b==s[i])cout << s[3-i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  cin >> n;
  ll i = 1;
  ll ans =1;
  while (1){
    if(i*i>n){
      break;
    }
    ans=i*i;
    i++;
  }
  pri(ans);







  return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  int left;
  for(int i=0;i<n;i++){
    if(a.at(i)==1){
      left=i;
      break;
    }
  }
  int right=n-left-1;
  int ans=right/(k-1)+left/(k-1)+1;
  if(right%(k-1)+left%(k-1)==0)
  ans--;
  cout << ans << endl;
}



Measured memory_bytes: 3796
import java.util.*;

class Main{
    public static void main(String[] args){
    Queue<String> queue = new ArrayDeque<String>();
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(); //処理する数
    int q = sc.nextInt(); //クオンタム
    int sum = 0;          //処理した数
    int sumTime = 0;      //合計処理時間
    for(int i = 0; i < 2*n; i++){
        String x = sc.next();
        queue.add(x);
    }
    /*処理部分*/
    while(sum != n){
        String name = queue.poll();
        int time = Integer.parseInt(queue.poll());
        if(time > q){
            sumTime += q;
            time -= q;
            queue.add(name);
            queue.add(String.valueOf(time));  //intをInteger経由でStringに変換している
        }
        else{
            sumTime += time;
            sum++;
            System.out.println(name +" "+sumTime);
        }
    }

    }
}


Measured memory_bytes: 80924
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
//#include <bits/stdc++.h>//atcoderでsqrtを使うときに必要
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;



void solve() {
	ll n;
	string s, t;
	cin >> s >> t;

	cout << t << s << endl;

	
}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 3124
import sys
#sys.setrecursionlimit(10**9)
input = sys.stdin.readline

import numpy as np

n, k = map(int, input().split())
A = np.array(input().split(), np.int64)
A = np.sort(A)

P = A[A>0]
Z = A[A==0]
N = A[A<0]

#t = n*(n-1)//2

def ok(x):
    # x以下になる組み合わせがk個以上
    cnt = 0
    #cnt += np.searchsorted(A, np.ceil(x/P), side='right').sum()
    cnt += np.searchsorted(A, x//P, side='right').sum()
    #cnt += n-np.searchsorted(A, np.floor(x/N), side='left').sum()
    cnt += (n-np.searchsorted(A, (-x-1)//(-N), side='right')).sum()
    if x >= 0:
        cnt += len(Z)*n
    cnt -= np.count_nonzero(A*A <= x)
    cnt = cnt//2
    if cnt >= k:
        return True
    else:
        return False

l = -10**18-1
r = 10**18+1
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)


Measured memory_bytes: 34628
#include <bits/stdc++.h>
using namespace std;
#define int long long
int N, M;
vector<vector<int> > tov;
vector<int> d;

signed main() {
	
	cin >> N >> M;
	tov.resize(N); 
	d.resize(N, 10000000);
	int a, b;
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		a--;
		b--;
		tov[a].push_back(b);
		tov[b].push_back(a);
	}
	d[0] = 0;
	for (int loop = 0; loop < 2; loop++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < tov[i].size(); j++) {
				d[tov[i][j]] = min(d[tov[i][j]], d[i] + 1);
			}
		}
	}
	
	if (d[N - 1] == 2) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	
	return 0;
	
}

Measured memory_bytes: 14312
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

int main(void){
    string s;
    int k;
    cin >> s >> k;

    vector<string> ans;
    int leng = s.length();

    for(int i=0;i<s.size();i++){
        for(int j=i;j<s.size() && j<i+7;j++){
            ans.push_back(s.substr(i, j-i+1));
        }
    }

    sort(ans.begin(), ans.end());
    unique(ans.begin(), ans.end());
    ans.erase( unique(ans.begin(), ans.end()), ans.end() );

    cout << ans[k-1] << endl;
    return 0;
}

Measured memory_bytes: 2300
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;

#define INF (1<<20)
typedef pair< int , int > P;
typedef pair< int , P > Pi;
struct Edge {
  int to,cost,des;
  Edge(){}
  Edge(int to,int cost,int des):to(to),cost(cost),des(des){};
};
vector< vector< Edge > > Graph;
int V,E,L;

int Dijkstra(int s,int g) {
  int min_cost[111][111];
  fill_n(*min_cost,111*111,INF);
  priority_queue < Pi ,vector< Pi >,greater< Pi > > que;
  que.push(Pi(0,P(L,s)));
  min_cost[s][L] = 0;
  while(!que.empty()){
    int cost = que.top().first;
    int des = que.top().second.first;
    int now = que.top().second.second;
    que.pop();
    if(now == g) return cost;
    if(cost > min_cost[now][des]) continue;
    for(int i=0;i<Graph[now].size();i++){
      Edge e = Graph[now][i];
      if(des >= e.des && min_cost[e.to][des-e.des] > cost){
	min_cost[e.to][des-e.des] = cost;
	que.push(Pi(cost,P(des-e.des,e.to)));
      }
      if(min_cost[e.to][des] > cost + e.cost){
	min_cost[e.to][des] = cost + e.cost;
	que.push(Pi(min_cost[e.to][des],P(des,e.to)));
      }
    }
  }
  return (-1);
}

int main(){
  while(cin >> V >> E >> L , (V||E||L)){
    Graph.resize(V+1);
    for(int i=0;i<E;i++){
      int a,b,c,d;
      cin >> a >> b >> c >> d;
      a--; b--;
      Graph[a].push_back(Edge(b,d,c));
      Graph[b].push_back(Edge(a,d,c));
    }
    cout << Dijkstra(0,V-1) << endl;
    Graph.clear();
  }
}

Measured memory_bytes: 1484
#include <cstdio>
#include <cctype>
#include <utility>
#include <set>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int n; (n = in());) {
		set<int> t, h;
		for (int i = 1; i <= n * 2; i++)
			h.insert(i);
		while (n--) {
			int c = in();
			t.insert(c);
			h.erase(c);
		}
		int c = 0;
		auto put = [&c](auto &p) {
			auto r = upper_bound(p.begin(), p.end(), c);
			if (r == p.end())
				c = 0;
			else {
				p.erase(*r);
				c = *r;
			}
			return !p.empty();
		};
		while (put(t) && put(h))
			;
		outl(h.size());
		outl(t.size());
	}
}


Measured memory_bytes: 2624
package main

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

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) 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 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 main() {
	sc := NewScanner()
	N := sc.nextInt()
	A := make([]float64, N)
	for i := 0; i < N; i++ {
		A[i] = float64(1 / float64(sc.nextInt()))
	}
	// fmt.Println(A)
	var sum float64
	for _, n := range A {
		sum += n
	}
	fmt.Println(1 / sum)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    string kind = "Three";
    cin >> N;
    vector<char> S(N);
    for(int i = 0; i <N; i++)
    {
        cin >> S.at(i);
    }
    for(int j = 0; j < N; j++)
    {
        if(S.at(j) == 'Y')
        kind = "Four";
    }
    cout << kind << endl;
}

Measured memory_bytes: 256
def main11():
    data = input().split()
    num = []
    for i in range(2):
        num.append(int(data[i]))
    result = int(num[0] / (num[1] * 2 + 1))
    if int(num[0] % (num[1] * 2 + 1)) != 0:
        result = result + 1
    print(result)

if __name__ == "__main__":
    main11()

Measured memory_bytes: 3060
from math import gcd

t = int(input())
queries = [tuple(int(x) for x in input().split()) for _ in range(t)]
for a, b, c, d in queries:
    if a < b:
        print("No")
        continue
    if b > d:
        print("No")
        continue
    if b - c <= 1:
        print("Yes")
        continue

    g = gcd(-b, d)
    if g == 1 or b - c > g:
        print("No")
    else:
        m = a - ((a - c) // g) * g
        if c < m < b:
            print("No")
        else:
            print("Yes")


Measured memory_bytes: 68224
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int mod = 1e9 + 7;
const int N = 2e5 + 11;
int n, m, nn, mm;
LL fac[N], inv[N], a[N];
inline LL A(LL x, LL y){
    return x + y - (x + y >= mod ? mod : 0);
}
LL C(int n, int m){
    if(n < m)return 0;
    return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main(){
    cin>>n>>m>>nn>>mm;
    fac[0] = inv[0] = fac[1] = inv[1] = 1;
    for(int i = 2;i <= 2e5; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = (mod - mod / i) * inv[mod%i] % mod;
    }
    for(int i = 2;i <= 2e5; i++){
        inv[i] = inv[i] * inv[i-1] % mod;
    }
    a[1] = 1;
    for(int i = 2;i <= n - nn; i++){
        a[i] = C(i + mm - 1, mm);
    }
    for(int i = n - nn + 1;i <= n; i++)a[i] = a[i-1];
    LL ans = 0;
    for(int i = 2;i <= n; i++){
        ans = A(ans, a[i] * C(n - i + m - mm - 2, n - i) % mod);
    }
    for(int i = mm + 2;i <= m; i++){
        ans = A(ans, C(n - 2 + m - i, n - 2));
    }
    if(mm == m - 1)ans = a[n];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4096
# coding: utf-8

N = int(input())
HL = list(map(int, input().split()))
HR = HL[:]

for i in range(N-1):
    HL[i] = HL[i] - (1 if HL[i] > HL[i+1] else 0)
    HR[N-i-2] = HR[N-i-2] - (1 if HR[N-i-1] < HR[N-i-2] else 0)

resL = "Yes"
for i in range(N-1):
    if HL[i] > HL[i+1]:
        resL= "No"
        break

resR = "Yes"
for i in range(N-1):
    if HR[i] > HR[i+1]:
        resR = "No"
        break

print("Yes" if resL == "Yes" or resR == "Yes" else "No")

Measured memory_bytes: 63984
//
// Created by moono on 2018/10/27.
//

#include <stdio.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

bool check(char *S, int A, int B){
    for (int i = 0; i < A+1+B; ++i) {
        if(i == A) continue;

//        cout << S[i] << endl;
//        cout << ('0' > S[i]) << endl;
//        cout << (S[i] > '9') << endl;
        if('0' > S[i] || S[i] > '9'){
            return false;
        }
    }



    if(S[A] != '-')
        return false;


    return true;
}


int main() {
    int A, B;
    char S[16];
    
    // 
    cin >> A >> B;
    scanf("%s", &S);

    if(check(S, A, B)) cout << "Yes";
    else cout << "No";


    return 0;
}

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

int main(){
    string S;
    cin >> S;
    if (S[2]==S[3] && S[4]==S[5]) cout << "Yes";
    else cout << "No";

    return 0;
}

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

int main() {
  int n, q;
  cin >> n >> q;
  std::vector<std::vector<int> > v(n);
  while (q--) {
    int op;
    cin >> op;
    if (op == 0) {
      int t, x;
      cin >> t >> x;
      v[t].push_back(x);
    } else if (op == 1) {
      int t;
      cin >> t;
      if (v[t].size() > 0) {
        for (size_t i = 0; i < v[t].size() - 1; i++) {
          cout << v[t][i] << " ";
        }
        cout << *v[t].rbegin();
      }
      cout << endl;
    } else {
      int t;
      cin >> t;
      v[t].clear();
    }
  }
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

#define MAX_N 100000

int N, M, Q;
vector<int> graph[MAX_N];
vector< tuple<int, int, int> > query;
int color[MAX_N];
int dist[MAX_N];

void dfs(int v, int d, int c) {
  if(d < 0) return;
  if(d <= dist[v]) return;
  dist[v] = d;
  if(!color[v]) color[v] = c;
  for(int u : graph[v]) dfs(u, d-1, c);
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> M;
  rep(i, M) {
    int a, b;
    cin >> a >> b; --a, --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  cin >> Q;
  rep(i, Q) {
    int v, d, c;
    cin >> v >> d >> c; --v;
    query.emplace_back(v, d, c);
  }
  reverse(all(query));
  memset(dist, -1, sizeof(dist));
  rep(i, Q) {
    int v, d, c;
    tie(v, d, c) = query[i];
    dfs(v, d, c);
  }
  rep(i, N) cout << color[i] << endl;

  return 0;
}


Measured memory_bytes: 11884