akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    Int T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    A1 -= B1;
    A2 -= B2;
    if (A1 == 0 || A1 * T1 + A2 * T2 == 0) {
        cout << "infinity\n";
        return 0;
    }
    if (A1 * T1 + A2 * T2 < 0) {
        A1 *= -1, A2 *= -1;
    }
    if (A1 > 0) {
        cout << "0\n";
        return 0;
    }
    Int X = -A1 * T1;
    Int S = A1 * T1 + A2 * T2;
    if (X % S == 0) {
        cout << X / S * 2 << endl;
    } else {
        cout << X / S * 2 + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io;
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::mem::{replace, swap};

// [NOTE] つかうときには trim() 入れないと RE になるので注意
// abcde
fn read_as_line() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    line
}

// -3.2
fn read_as_primitive<T: FromStr>() -> T {
    let s = read_as_line();
    s.trim().parse().ok().expect("failed to parse input")
}

// 1 -3 0 999
fn read_as_collection<U: FromStr, T: FromIterator<U>>() -> T {
    let s = read_as_line();
    s.trim().split_whitespace().map(|s| s.parse().ok().expect("failed to parse")).collect()
}

// #.#.###..
fn read_as_chars<T: FromIterator<char>>() -> T {
    let s = read_as_line();
    s.trim().chars().collect()
}

// 1 abc
fn read_as_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let s = read_as_line();
    let mut it = s.trim().split_whitespace();
    (
        it.next().unwrap().parse().ok().expect("failed to parse"),
        it.next().unwrap().parse().ok().expect("failed to parse"),
    )
}

// 1.5 -2 abc
fn read_as_triple<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let s = read_as_line();
    let mut it = s.trim().split_whitespace();
    (
        it.next().unwrap().parse().ok().expect("failed to parse"),
        it.next().unwrap().parse().ok().expect("failed to parse"),
        it.next().unwrap().parse().ok().expect("failed to parse"),
    )
}

// Sorting ParitialOrd primitives like f64
// let mut v: Vec<f64> = vec![0.1, 1.0, 2.0];
// v.sort_by_key(|&x| Total(x));
// 
// src: https://qiita.com/hatoo@github/items/fa14ad36a1b568d14f3e
//      https://github.com/rust-lang/rust/pull/53938
//
#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}


fn main() {
    let n: usize = read_as_primitive();
    let (t, a): (f64, f64) = read_as_pair();
    let h: Vec<f64> = read_as_collection();
    assert_eq!(h.len(), n);

    let mut ans = (1000000.0, 0);
    for i in 0..n {
        let temperature_diff = (t - h[i] * 0.006 - a).abs();
        if temperature_diff < ans.0 {
            ans = (temperature_diff, i + 1);
        }
    }

    println!("{}", ans.1);

}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main()
{
	int i, n;
	double x[4], y[4];
	cin >> n;
	
	for (i=0; i<n; i++) {
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];
		if (x[0] == x[1]) {
			if (x[2] == x[3]) cout << "YES" << endl;
			else cout << "NO" << endl;
		} else {
			if ((y[0] - y[1]) / (x[0] - x[1]) == (y[2] - y[3]) / (x[2] - x[3])) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
int main(void)
{
	char a[11],b[11],c[11];
	int x,y;
	scanf("%s %s %s",a,b,c);
	x=strlen(a);
	y=strlen(b);
//	printf("%c %c\n",a[x-1],b[y-1]);
	if(a[x-1]==b[0]&&b[y-1]==c[0]) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Process {
	String name;
	int time;

	public Process(String name, int time) {
		super();
		this.name = name;
		this.time = time;
	}

	public void proceed(int q) {
		this.time -= q;
	}

}

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		sc.nextLine();

		Queue<Process> queue = new LinkedList<>();

		for (int i = 0; i < n; i++) {
			String[] input = sc.nextLine().split(" ");
			Process p = new Process(input[0], Integer.parseInt(input[1]));
			queue.add(p);
		}

		int passedTime = 0;
		while(true) {

			if(queue.isEmpty()) break;

			Process now = queue.poll();
			if(now.time > q) {
				now.proceed(q);
				passedTime += q;
				queue.add(now);
			} else {
				passedTime += now.time;
				System.out.printf("%s %d\n", now.name, passedTime);
			}
		}
	}
}

Measured memory_bytes: 130168
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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 ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  int ans = 0;
  rep(i,n){
    if((i+1)%2 && a[i]%2)ans++;
  }
  print(ans);
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<char> alpha;
  for(char i = 'A'; i <= 'Z'; i++) {
    alpha.push_back(i);
  }
  rep(i, s.size()) {
    int index = s.at(i) - 'A';
    index += n;
    index %= 26;
    s.at(i) = alpha.at(index);
  }
  cout << s << endl;
}

Measured memory_bytes: 256
n = int(input())
s = sorted([sorted(list(input())) for i in range(n)])

res = 0
cnt = 0
tmp = ''
for word in s:
    if word != tmp:
        tmp = word
        res += (cnt * (cnt-1)) // 2
        cnt = 1
    else:
        cnt += 1
else:
    res += (cnt * (cnt-1)) // 2

print(res)

Measured memory_bytes: 25420
if __name__ == '__main__':
    N, M, X, Y = map(int, input().split())
    X_new = list(map(int, input().split()))
    Y_new = list(map(int, input().split()))
    X_new.append(X)
    Y_new.append(Y)
    X_new.sort()
    Y_new.sort()
    

    if X_new[N] < Y_new[0]:
        print('No War')
    else:
        print('War')

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

int main(){
    int n,d,x;
    cin >> n >> d >> x;
    vector<int> a(n),count(n+1);

    for(int i=0;i<n;i++){
        cin >>a.at(i);
    }

    int ans=0,j;
    for(int i=0;i<n;i++){
        count.at(i)=1;
        for(j=0;count.at(i)<=d;j++){
            count.at(i)+=a.at(i);
        }
        ans+=j;
        //cout << "ans:" << j << endl;
    }
    cout << ans+x << endl;
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 500005
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

int32_t main(){
	IOS;
	int n; cin >> n;
	int A[n];
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	sort(A, A + n, greater < int > ());
	int ans = 0;
	if(n == 1) {
		cout << ans;
		return 0;
	}

	ans += A[0];
	int j = 0;
	for(int i = 1; i < n - 1; i++){
		if(i % 2) j++;
		ans += A[j];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5224
<?php
    fscanf(STDIN,'%d %d',$n,$m);
    $h_array = explode(' ',trim(fgets(STDIN)));

    $is_good = array_fill(1,$n,true);

    for($i=0;$i<$m;++$i){
        fscanf(STDIN, '%d %d', $a, $b);
        if($h_array[$a-1] >= $h_array[$b-1]) $is_good[$b] = false;
        if($h_array[$a-1] <= $h_array[$b-1]) $is_good[$a] = false;
    }
    $count = 0;
    foreach($is_good as $v) if($v) ++$count;
    echo $count.PHP_EOL;
?>

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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    int a, b; cin >> a >> b;
    b += b;
    a -= b;
    cout << (a < 0 ? 0 : a) << '\n';
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>


using namespace std;
typedef long long ll;

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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }


constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

constexpr int N = 1000000;
int cnt[N + 1];
int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n; cin >> n;
	int g = 0;
	vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i], cnt[a[i]]++, g = gcd(g, a[i]);
	for (int i = 2; i <= N; i++) {
		for (int j = i + i; j <= N; j += i) {
			cnt[i] += cnt[j];
		}
	}
	bool f = true;
	for (int i = 2; i <= N; i++) {
		if (cnt[i] >= 2) f = false;
	}
	if (f) {
		cout << "pairwise coprime" << endl;
		return 0;
	}
	if (g == 1) {
		cout << "setwise coprime" << endl;
		return 0;
	}
	cout << "not coprime" << endl;
	return 0;
}

Measured memory_bytes: 11060
using System;
public class Program
{
    public static void Main(string[] args)
    {
        // 整数の入力
        string[] inputs = Console.ReadLine().Split(' ');
        int n = int.Parse(inputs[0]);
        int k = int.Parse(inputs[1]);
        // スペース区切りの整数の入力
        inputs = Console.ReadLine().Split(' ');

        int temp = 0;
        for (int i=0;i<k;i++)
        {
            temp = temp + int.Parse(inputs[i]);
        }

        int max = temp;
        for (int i = k; i < n; i++)
        {
            temp = temp + int.Parse(inputs[i]) - int.Parse(inputs[i-k]);
            if (max < temp) max = temp;
        }


        //出力
        Console.WriteLine(((max+k)/2.0).ToString());
    }
}


Measured memory_bytes: 28636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define quickcin ios_base::sync_with_stdio(false);
const int mod=1e9+7;
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
template <typename T1,typename T2> inline void chadd(T1 &x,T2 b) {x+=b;if(x>=mod) x-=mod;}
template <typename T1,typename T2> inline void chmul(T1 &x,T2 b) {x=1LL*x*b%mod;}
template <typename T1,typename T2> inline void chmod(T1 &x,T2 b) {x%=b,x+=b;if(x>=b) x-=b;}
char c[1000005];
int k;

namespace combinatorics
{
	int *fac;
	int *ifac;
	int __Tmod;
	inline int add(int a,int b)
	{
		return (a+b)%__Tmod;
	}
	inline int sub(int a,int b)
	{
		return (a-b+__Tmod)%__Tmod;
	}
	inline int mult(int a,int b)
	{
		return (1LL*a*b)%__Tmod;
	}
	inline int fastpow(int basic,int x)
	{
		if(x==0) return 1;
		int res=1;
		while(x)
		{
			if(x&1)	res=mult(res,basic);
			basic=mult(basic,basic);
			x>>=1;
		}
		return res;
	}
	inline int inv(int x)
	{
		return fastpow(x,__Tmod-2);
	}
	void init(int n,int tmod)
	{
		__Tmod=tmod;
		fac=new int[n+5];
		ifac=new int[n+5];
		fac[0]=1;
		for(int i=1;i<=n;i++)
		{
			fac[i]=mult(fac[i-1],i);
		}
		ifac[n]=inv(fac[n]);
		for(int i=n-1;i>=0;i--)
		{
			ifac[i]=mult(ifac[i+1],i+1);
		}
	}
	inline int C(int n,int m)
	{
		return mult(mult(fac[n],ifac[m]),ifac[n-m]);
	}
	inline int Cat(int x)
	{
		return mult(C(x*2,x),inv(x+1));
	}
};
using namespace combinatorics;

int n;
int res;

int main()
{
//	freopen("input.txt","r",stdin);
	scanf("%d%s",&k,c);
	n=strlen(c);
	init(26*(n+1)+k,mod);
	int e=1;
	for(int a=k;a>=0;a--)
	{
		chadd(res,mult(e,C(k+n,a+n)));
		chmul(e,25);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 215540
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


std::vector<string> out;

void seeker(std::vector<int> check, int n, std::vector<int> ind)
{
    if (ind.size() == n) {
        std::string ans;
        for (int i = 0; i < n; i++) {
            ans += (char)('a' + ind[i]);
        }
        out.pb(ans);
    } else {
        for (int i = 0; i < check.size(); i++) {
            std::vector<int> cp = ind;
            cp.pb(check[i]);
            seeker(check, n, cp);
        }
        check.pb(check.size());
        ind.pb(check.size() - 1);
        seeker(check, n, ind);
    }
}


signed main()
{
    int n;
    cin >> n;
    std::vector<int> check;
    std::vector<int> ind;
    seeker(check, n, ind);
    std::sort(out.begin(), out.end());
    for (int i = 0; i < out.size(); i++) {
        cout << out[i] << endl;
    }
    return 0;
}

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

int main(){

  string a,b,c;
  cin >> a >> b >> c;
  size_t len_a = a.length();
  size_t len_b = b.length();

  if(a[len_a-1]==b[0] && b[len_b-1]==c[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }


}

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

int main(){
  int n;cin >> n;
  ll a[n];ll ans = 1; 
  rep(i,n){
    cin >> a[i];
    if(a[i] == 0){cout << 0;return 0;}
  }

  rep(i,n){
      if(a[i] <= 1000000000000000000/ans){
        ans *= a[i];
      } else {
        cout << -1;return 0;
      }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),K = in();
    string S = in<string>();
    S[K-1] -= 'A' - 'a';
    cout << S << "\n";
}

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

public class Main {
  private static void solve() {
    int n = ni();
    int[] a = na(n);
    Map<Integer, Long> cnt = new HashMap<>();

    for (int v : a) {
      cnt.putIfAbsent(v, 0L);
      cnt.put(v, cnt.get(v) + 1L);
    }

    long ret = 0;
    for (Map.Entry<Integer, Long> entry : cnt.entrySet()) {
      long v = entry.getValue();
      ret += v * (v - 1) / 2;
    }

    for (int i = 0; i < n; i++) {
      long v = cnt.get(a[i]);
      long x = v * (v - 1) / 2;
      long y = (v - 1) * (v - 2) / 2;
      out.println(ret - x + y);
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 58012
#include <iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n, k, cnt = 0, t;
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> t;
		if (t >= k)
			++cnt;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 256
import sys
# input = sys.stdin.readline
inf = 10 ** 18
P = 10 ** 9 + 7

N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N - 1)]

graph = [[] for _ in range(N)]
for i, (ai, bi) in enumerate(ab):
    graph[ai - 1].append(bi)
    graph[bi - 1].append(ai)

for i_root in range(1, N + 1):
    if len(graph[i_root - 1]) > 1: break

from collections import deque

cnts = [None] * N
cnts[i_root - 1] = K

q = deque([i_root])
while len(q) > 0:
    src = q.popleft()
    idx = 0
    for dst in graph[src - 1]:
        if cnts[dst - 1] == None:
            parents = 1 if src == i_root else 2
            cnt_tmp = K - parents - idx
            cnts[dst - 1] = cnt_tmp if cnt_tmp > 0 else 0
            #    
            q.append(dst)
            idx += 1

# print("#", graph)
# print("#", cnts)

ans = 1
# for i in range(1, max(N, K) + 1):
#     ans = (ans * i) % P

for cnt in cnts:
    ans = (ans * cnt) % P
    if cnt == 0: break

print(ans)

Measured memory_bytes: 40396
#include <bits/stdc++.h> 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
  int n;
  cin>>n;
  int d[n];
  rep(i,n){cin>>d[i];}
  int k;
  rep(i,n){for(int j=i+1;j<n;j++){
    k+=d[i]*d[j];}}
  cout<<k<<endl;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

#define MOD 1000000007

int main() {
	int n = ri();
	int dp[n + 1];
	memset(dp, 0, sizeof(dp));
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = i + 3; j <= n; j++) {
			dp[j] += dp[i];
			if (dp[j] >= MOD) dp[j] -= MOD;
		}
	}
	std::cout << dp[n] << std::endl;
	return 0;
}


Measured memory_bytes: 3796
#include <iostream>
using namespace std;
int main()
{
  string str;
  cin >> str;
  
  int num = 0;
  for(int i=0; i<(str.size()/2); i++){
    if(str.at(i) != str.at(str.size()-1-i))
      num++;
  }
  cout << num << endl;
  
  return 0;
}

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

struct player { int to,fr,f; }; 
player p[1000];

int main() {
  int i,n,m,k,pn;
  char c[10001][9],a[256];
  for (i=1;i<10001;i++) {
	  if ((i % 3)==0 && (i % 5)==0) sprintf(c[i],"%s","FizzBuzz"); else
	  if ((i % 3)==0) sprintf(c[i],"%s","Fizz"); else
	  if ((i % 5)==0) sprintf(c[i],"%s","Buzz"); else
	  sprintf(c[i],"%d",i);
	  }
  while(cin >> m >> n && m>0) {
	  for (i=0;i<m;i++) { p[i].fr=(i+m-1) % m ; p[i].to=(i+1) % m; p[i].f=0;}
	  k=m;
	  for (pn=0,i=1;i<=n;i++) {
		  cin >> a;
		  if (k==1) continue;
		  if (strcmp(a,c[i])!=0) {p[pn].f=1; p[p[pn].fr].to=p[pn].to; p[p[pn].to].fr=p[pn].fr; k--;}
		  pn=p[pn].to;
		  }
	  k=0;	  
	  for (i=0;i<m;i++) if (p[i].f==0) { if (k==1) cout << ' '; 
		  cout << i+1; k=1; }
	  cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1300
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

x = int(input())
#print(factorization(8))

if x < 4:
    print(1)
else:
    for i in range(x,3,-1):
        if len(factorization(i)) == 1:
            if factorization(i)[0][1] != 1:
                print(i)
                #print(factorization(i))
                break
        else:
            for k in range(1,len(factorization(i))):
                if factorization(i)[k-1][1] != factorization(i)[k][1] or factorization(i)[k-1][1] == 1:
                    break
            else:
                print(i)
                break






Measured memory_bytes: 38768
#include <iostream>
using namespace std;
int a[100005];
inline int gcd(int x,int y)
{
	if(x>y) swap(x,y);
	while(x) y%=x,swap(x,y);
	return y;
}
int main(int argc, char** argv) {
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> a[i];
	int ans=0;
	for(int i=2;i<=n;i++)
		ans=gcd(ans,a[i]);
	for(int i=1;i*i<=a[1];i++)
	{
		if(a[1]%i==0)
		{
			int cnt=0;
			for(int j=2;j<=n;j++)
			{
				if(a[j]%i!=0) ++cnt;
				if(cnt>1) break;
			}
			if(cnt<=1) ans=max(ans,i);
			cnt=0;
			for(int j=2;j<=n;j++)
			{
				if(a[j]%(a[1]/i)!=0) ++cnt;
				if(cnt>1) break;
			}
			if(cnt<=1) ans=max(ans,a[1]/i);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

void solve(long long A, long long B, long long C, long long D){
  ll tmpc,tmpd,tmp;
  tmpc=B/C-(A-1)/C;
  tmpd=B/D-(A-1)/D;
  tmp=B/(D*C/gcd(D,C))-(A-1)/(D*C/gcd(D,C));
  op(B-A+1-(tmpc+tmpd-tmp))
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

ll pow_f(ll b, ll e) {
    ll ans = 1;
    b = b % M;
    while (e) {
        if (e&1) {
            ans = (ans * b) % M;
        }
        b = (b * b) % M;
        e >>= 1;
    }
    return ans;
}

ll nCr(ll n, ll r) {
    if (r > n || n < 0 || r < 0) { return 0; }
    if (n == r || r == 0) { return 1; }
    r = min(r, n-r);
    ll ans = 1;
    for (ll i = 1; i <= r; ++i) {
        ans = (ans * (n-i+1))/(i); 
    }
    return ans;
}

ll nCr(tuple<ll,ll> t) {
    auto n = get<0>(t);
    auto k = get<1>(t);
    return nCr(n+k-1, k);
}

struct quad {
    ll a, b, c, d;
};

template<typename T>
void print(vector<T> A) {
    for (auto &i : A) {
        cout << i << " ";
    }
    cout << endl;
}

ll ans = LLONG_MIN;

void calc_max_score(vector<ll> &A, ll m, vector<quad> &V) {
    ll ans = 0;
    for (auto &i : V) {
        if (A[i.b-1] - A[i.a-1] == i.c) {
            ans += i.d;
        }
    }
    ::ans = max(::ans, ans);
}
void fill_vec(vector<ll> &A, ll idx, ll prev_val, ll m, vector<quad> &V) {
    if (idx == A.size()) {
        calc_max_score(A, m, V);
        return;
    }
    for (int i = prev_val; i <= m; ++i) {
        A[idx] = i;
        fill_vec(A, idx+1, i, m, V);
    }
}
void solve() {
    /**
     * Generate ((10, 10)) array
     */ 
    ll n, m, q;
    cin >> n >> m >> q;
    vector<quad> V(q);
    for (auto &i : V) {
        cin >> i.a >> i.b >> i.c >> i.d;
    }

    vector<ll> A(n, 0);
    fill_vec(A, 0, 1, m, V);
    //cout << nCr({m,n}) << endl;

    cout << ::ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

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

int m, n, p[1001], pp[1001*1001];

int main(){
    while( true ){
        cin >> n >> m;
        if( m == 0 && n == 0 ) break;
        for(int i = 0; i < n; i++){
            cin >> p[i];
        }
        p[n] = 0;
        n++;
        for(int i = 0; i < n*n; i++){
            pp[i] = p[i/n] + p[i%n];
        }
        sort(pp, pp + n*n);
        int cand = 0;
        int j = n*n-1;
        for(int i = 0; i <= j; i++){
            while( j >= 0 && pp[i] + pp[j] > m ) j--;
            if(j >= 0){
                cand = max(cand, pp[i] + pp[j]);
            }
        }
        cout << cand << endl;
    }
    return 0;
}

Measured memory_bytes: 5092
// CODE by Kazhybay Askar

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

/*
find_by_order(k);
order_of_key(k);
ordered_set(int) s;
*/

/*
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
rng();
shuffle(permutation.begin(), permutation.end(), rng);
*/

/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define F      first
#define S      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define nl     '\n'
#define ordered_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>

typedef unsigned long long ull;
typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 5e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

ll n,a[MAXN];

void solve(){
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes";
    }
    else cout<<"No";
}



int main(){
    Speed;
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    r0;
}


Measured memory_bytes: 256
for r in range(input()):
	if r > 0: print
	n = input()
	if n < 3:
		for i in range(n): print "#"*(n-i) + " "*i
		continue
	S = [[" "]*n for i in range(n)]
	x,y,dx,dy = 0,n-1,0,-1
	while 1:
		S[y][x] = "#"
		y += dy; x += dx
		try:
			if S[y+dy][x+dx] == "#":
				if y+dy != -1:
					y -= dy; x -= dx
				raise
		except:
			S[y][x] = "#"
			dx,dy = -dy,dx
			y += dy; x += dx
		if S[y+dy][x+dx] == "#" or S[y+dx][x-dy] == "#": break
	for i in range(n):
		print "".join(S[i])

Measured memory_bytes: 4388
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,y,z;
    cin >> x >> y >> z;
    for(int i=0; i< x;i++){
        if((x - y*i - (i+1)*z) < 0){
            cout << (i-1)<< endl;
            return 0;
        }else if((x - y*i - (i+1)*z) < 0){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
    
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long tot = 0;
		for(int i=1;i<N;i++){
			if(A[i] >= A[i-1]) continue;
			long diff = A[i - 1] - A[i];
			A[i] += diff;
			tot += diff;
		}
		
		Console.WriteLine(tot);
		
	}
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 46708
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-05-19 17:18
# @url:https://atcoder.jp/contests/abc135/tasks/abc135_d
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    # python取模注意每次都需要取模，否则可能会导致tle
    # 大数取模的运算通常可以分解为每个位置的权重进行取模运算，然后求和再取模的，例如：
    # 1993%mod=(1000%mod+900%mod+90%mod+3%mod)%mod
    # 利用模运算的基本性质：
    # 加法：19%3=(10%3+9%3)%3 (a+b)%mod=(a%mod+b%mod)%mod
    # 乘法：27%4=(9%4*3%4)%4  (a*b)%mod=(a%mod*b%mod)%mod
    s=str(input())
    S=s[::-1]
    dp=[[0]*13 for i in range(len(S))]
    mod=10**9+7
    p=1 # 每位的权重10的幂次
    for i in range(len(S)):
        if i==0:
            if S[i]!='?':
                t=p*int(S[i])%13
                dp[i][t]+=1
            else:
                for j in range(10):
                    dp[i][j]+=1
        else:
            if S[i]!='?':
                t=p*int(S[i])%13
                for j in range(13):
                    dp[i][(t+j)%13]=dp[i-1][j]%mod
            else:
                for j in range(10):
                    for k in range(13):
                        temp=(p*j%13+k)%13
                        dp[i][temp]=(dp[i][temp]+dp[i-1][k])%mod
        # 权重取模
        p=(p%13*10%13)%13
    # print (dp)
    print (dp[len(S)-1][5])
if __name__ == "__main__":
    main()

Measured memory_bytes: 95788
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll a,b,n;
cin>>a>>b>>n;
ll x;
if(n<b)
{
    x=n;
}
else
{
    x=b-1;
}
ll c=floor((a*x)/b)-a*floor(x/b);
cout<<c<<endl;
    
    return 0;
    
}

Measured memory_bytes: 3572
s = input()

hor = ('W' in s and 'E' in s) or ('W' not in s and 'E' not in s)
ver = ('N' in s and 'S' in s) or ('N' not in s and 'S' not in s)

ans = hor and ver

if ans:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;

#define mod             1000000007
#define what_is(x)      cerr<<#x<<" is "<<x<<"\n";
#define read(x)         freopen("in.txt","r",stdin);
#define write(x)        freopen("out.txt","w",stdout);
#define Fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define sz              3000005

bool mark[sz];
vector<int > adj[sz];

void dfs(int u){

    mark[u]=1;
    for(int i=0; i<adj[u].size(); i++){
        int v=adj[u][i];
        if(mark[v]==0){
            dfs(v);
        }
    }
}

int main(){
    Fast;///using Fast I/O
    int a,b,c, i,j,k, t,n,m;

    cin>>n>>m;
    for(i=1; i<=m; i++){
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    int cnt=0;
    for(int i=1; i<=n; i++){
        if(mark[i]==0){
            cnt++;
            dfs(i);
        }
    }

    cout<<cnt-1<<endl;



    return 0;
}



Measured memory_bytes: 77668
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;

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

    ll n, d; cin >> n >> d;
    ll count = 0;
    rep(i, n){
        double x, y; cin >> x >> y;
        if(sqrt(x * x + y * y) <= d) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3752
#include<iostream>
#include<cstring>
using namespace std;
string a;
int main() {
	int left,right;
	cin>>a;
	for(int i=0; i<a.length(); i++)
		if(a[i]=='A') {
			left=i;
			break;
		}
	for(int i=a.length()-1; i>=0; i--)
		if(a[i]=='Z') {
			right=i;
			break;
		}
	cout<<right-left+1<<endl;
	return 0;
}

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

using ll = long long;
const int limit = 100010;
using edge = struct{int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d) {
	depth[v] = d;
	for (auto &e : tree[v]) {
		if (e.to == p) continue;
		dfs(e.to, v, d + e.cost);
	}
}

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

	for (int i = 0; i < n - 1; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		tree[a].push_back({b, c});
		tree[b].push_back({a, c});
	}

	int q, k;
	cin >> q >> k;
	k--;

	dfs(k, -1, 0);
	for (int i = 0; i < q; ++i) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		cout << depth[x] + depth[y] << endl;
	}
	return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int num[111],len,nw;
string to_ask,ans;
int ask(string s)
{
	cout<<"? "<<s<<endl;
	fflush(stdout);int res;
	cin>>res;
	return res;
}
char cal(int x)
{
	if (x>=0 && x<26) return 'a'+x;
	if (x>=26 && x<52) return 'A'+x-26;
	return '0'+x-52;
}
string solve(int l,int r)
{
	if (l==r)
	{
		string res="";
		for (int i=1;i<=num[l];i++) res.push_back(cal(l));
		return res;
	}
	int mid=(l+r)>>1,p1,p2,l1,l2;
	string s1=solve(l,mid),s2=solve(mid+1,r),res="";
	l1=s1.size();l2=s2.size();p1=p2=0;
	while(p1<l1 && p2<l2)
	{
		to_ask=res;
		to_ask.push_back(s1[p1]);
		to_ask=to_ask+s2.substr(p2);
		if (ask(to_ask)==len-(int)to_ask.size()) 
		{
			res.push_back(s1[p1]);
			p1++;
		}
		else
		{
			res.push_back(s2[p2]);
			p2++;
		}
	}
	while(p1<l1) res.push_back(s1[p1++]);
	while(p2<l2) res.push_back(s2[p2++]);
	return res;
}
int main()
{
	for (int i=0;i<=61;i++)
	{
		to_ask="";
		for (int j=0;j<128;j++) to_ask.push_back(cal(i));
		nw=ask(to_ask);
		num[i]=128-nw;
	}
	for (int i=0;i<=61;i++) len+=num[i];
	ans=solve(0,61);
	cout<<"! "<<ans<<endl;
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <bitset>
#include <cstdint>
#include <iomanip>
#include <queue>
#include <initializer_list>
#include <stdio.h>
typedef long long int ll;
using namespace std;
int main() {
	ll H; cin >> H;
	ll num = 0;
	ll ans = 0;
	while (H > 0) {
		H /= 2;
		num++;
	}
	ans = pow(2, num)-1;
	cout << ans << endl;
}

Measured memory_bytes: 3308
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	const ll mod = 1e9 + 7;
	ll s;
	cin >> s;

	vll t(s+1, 0);

	repeq(i, 3, s) {
		t[i]++;
		repeq(j, 3, i - 3) {
			t[i] += t[i - j];
			t[i] %= mod;
		}
	}

	cout << t[s] << endl;
	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
char s[100005];
int read() {
	char c=getchar(); int x=0,f=1;
	while (c<'0' || c>'9') {
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int main() {
	scanf("%s", s);
	int n=strlen(s);
	if (s[n-1]=='1') printf("-1\n");
	else if (s[0]=='0' || s[n-2]=='0') printf("-1\n");
	else {
		for (int i=1; i<=n-3; i++) {
			if (s[i]!=s[n-2-i]) {
				printf("-1\n");
				exit(0);
			}
		}
		int fa=1,now=2;
		for (int i=n-2; i>=0; i--) {
			if (s[i]=='1') {
				printf("%d %d\n", fa, now);
				fa=now;
			}
			else {
				printf("%d %d\n", fa, now);
			}
			++now;
		}
	}
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n,m;
	string s;
	static int a[200010],b[200010];
	static vector<int> G[200010];
	static int out[200010][2] = {};
	
	cin >> n >> m >> s;
	for(int i = 1 ; i <= m ; i ++){
		scanf("%d%d",&a[i],&b[i]);
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
		out[a[i]][s[b[i]-1]-'A'] ++;
		out[b[i]][s[a[i]-1]-'A'] ++;
	}
	
	queue<int> que;
	for(int i = 1 ; i <= n ; i ++){
		if(out[i][0] == 0 || out[i][1] == 0)que.push(i);
	}
	while(!que.empty()){
		int q = que.front(); que.pop(); n --;
		//cout << q << endl;
		for(int v: G[q]){
			out[v][s[q-1]-'A'] --;
			if(out[v][s[q-1]-'A'] == 0 && out[v][1-(s[q-1]-'A')] != 0)que.push(v);
		}
	}
	if(n > 0)puts("Yes");
	else puts("No");
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a + b) % 2 == 0) {
    cout << (a + b) / 2 << endl;
  }
  else {
    cout << (a + b + 1) / 2 << endl;
  }
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	s <- getLine
	w <- readInt
	putStrLn $ solve w s

solve _ [] = []
solve w s = head s : solve w ( drop w s )

Measured memory_bytes: 636
#include <stdio.h>
#define MN 300005
#define R register
int n,k,a[MN];
int main(){
	scanf("%d%d",&n,&k);
	if (~n&1){
		printf("%d ",n>>1);
		for (R int i=2; i<=k; ++i)
			printf("%d ",n);
		return 0;
	}else{
		for (R int i=1; i<=k; ++i)
			a[i]=n+1>>1;
		R int last=k;
		for (R int i=1; i<=k>>1; ++i)
			if (a[last]==1) --last;
			else{
				--a[last];
				for (R int j=last+1; j<=k; ++j) a[j]=n;
				last=k;
			}
		for (R int i=1; i<=last; ++i) printf("%d ",a[i]);
	}return 0;
}

Measured memory_bytes: 3328
from typing import List


def answer(n: int, a: List[int]) -> int:
    alice = 0
    bob = 0

    a.sort(reverse=True)
    for i in range(0, len(a), 2):
        alice += a[i]
    for j in range(1, len(a), 2):
        bob += a[j]

    return abs(alice - bob)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    print(answer(n,a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10200
#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() {
    int n;
    cin >> n;
    if(n == 1)cout << "Hello World" << endl;
    else{
        int a,b; cin >> a >> b;cout << a + b << endl;
    } 
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256