akhauriyash/Code-Regression huggingface dataset:
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    auto s = readln().chomp();
    long ans;
    long ng;
    long np;
    foreach(si; s) {
        if(si == 'p') {
            if(np < ng) {
                ++np;
            } else {
                ++ng;
                --ans;
            }
        } else {
            if(np < ng) {
                ++np;
                ++ans;
            } else {
                ++ng;
            }
        }
    }
    writeln(ans);
}



Measured memory_bytes: 508
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            //3
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("100");
            //473
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1000000");
            //13969985
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int N = int.Parse(InputList[0]);

        DerivePatternCnt(N);

        long Answer = 0;
        for (int LoopC = 1; LoopC <= N; LoopC++) {
            int RestVal = N - LoopC;
            if (mProdCntDict.ContainsKey(RestVal)) {
                Answer += mProdCntDict[RestVal];
            }
        }
        Console.WriteLine(Answer);
    }

    static Dictionary<int, int> mProdCntDict = new Dictionary<int, int>();

    //掛けて、Nになる、ペアが何通りあるかを求めておく
    static void DerivePatternCnt(int pN)
    {
        //場合の数[積の値]
        for (int I = 1; I * I <= pN; I++) {
            for (int J = I; I * J <= pN; J++) {
                int Key = I * J;
                int AddCnt = (I == J ? 1 : 2);
                if (mProdCntDict.ContainsKey(Key)) {
                    mProdCntDict[Key] += AddCnt;
                }
                else {
                    mProdCntDict[Key] = AddCnt;
                }
            }
        }
        //foreach (var EachPair in mProdCntDict) {
        //    Console.WriteLine("mProdCntDict[{0}]={1}", EachPair.Key, EachPair.Value);
        //}
    }
}


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

int l, n=30, e, a[66], b[66], c[66];

int main() {
	cin >> l;
	while ((l>>n)%2==0) n--;
	for (int i=1; i<=n; i++) {
		a[e] = i; b[e] = i+1; c[e] = 1<<(i-1); e++;
		a[e] = i; b[e] = i+1; c[e] = 0; e++;
	}
	for (int i=n-1, k=(1<<n); ~i; i--) if ((l>>i)&1) {
		a[e] = i+1; b[e] = n+1; c[e] = k; e++; k += (1<<i);
	}

	cout << n+1 << ' ' << e << '\n';
	for (int i=0; i<e; i++) cout << a[i] << ' ' << b[i] << ' ' << c[i] << '\n';
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().abc100_b();
        }

        public void Solve()
        {

            string s = Console.ReadLine();
            bool Flag = true;
            bool Cflag = false;
            for (int i = 0; i < s.Length; i++)
            {
                if (i == 0)
                {
                    if (s[0] != 'A') Flag = false;
                }
                else if(2 <= i && i < s.Length - 1)
                {
                    if (('a' <= s[i] && s[i] <= 'z'))
                    {
                        continue;
                    }
                    else if(s[i] == 'C' && Cflag==false)
                    {
                        Cflag = true;
                        continue;
                    }

                    Flag = false;
                }
                else
                {
                    if (('a' <= s[i] && s[i] <= 'z')) continue;
                    Flag = false;
                }
            }

            if (Flag && Cflag) Console.WriteLine("AC");
            else Console.WriteLine("WA");
        }

        public void abc102_b()
        {
            int n = int.Parse(Console.ReadLine());

            List<int> a = Console.ReadLine().Split().Select(int.Parse).ToList();

            Int32 Amax = 0;
            Int32 Amin = Int32.MaxValue;

            for (int i = 0; i < n; i++)
            {
                Amax = Math.Max(Amax, a[i]);
                Amin = Math.Min(Amin, a[i]);
            }

            Console.WriteLine(Amax - Amin);
        }

        public void abc100_b()
        {

            var l = Console.ReadLine().Split(' ');
            int d = int.Parse(l[0]);
            int n = int.Parse(l[1]);
            int ans = 0;
            int num = 0;
            while (true)
            {
                int t = ++ans;
                int wn = 0;
                while(t % 100 == 0)
                {
                    t /= 100;
                    wn++;
                }
                if(wn == d)
                {
                    if(++num == n)
                    {
                        break;
                    }
                }
            }
            WriteLine(ans);
        }
    }

}


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

int main(){
  string S,T; cin >> S >> T;
  for(int i=0;i<S.size();i++){
    if(S == T){
      cout << "Yes" << endl;
      return 0;
    }
    S = S.back()+S.substr(0,S.size()-1);
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    ll N, A, B; cin >> N >> A >> B;
    ll C = N/(A+B);
    ll D = min(N%(A+B), A);
    ll ans = C * A + D;
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
//0oooo0
//000000
signed main() {
    int I,O,T,J,L,S,Z;
    cin >> I >> O >> T >> J >> L >> S >> Z;
    int ans = (I/2*4+O*2+J/2*4+L/2*4)/2;
    int cnt = I%2+J%2+L%2;
    if(cnt == 3) {
        ans+=3;
    }
    if(cnt == 2) {
        if(I != 0 && J != 0 && L != 0){
            ans+=1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    long long n; cin >> n;
    long long ans = 0;
    for (long long r = 1; r*r < n; r++) {
        if (n % r == 0) {
            long long m = n / r - 1;
            if (r < m) ans += m;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define ZERO 0
#define MIN 9
int main(void)
{
	int n,count,i,j,k,l;
	while(scanf("%d",&n)!=EOF)
	{
		count=0;
		for(i=ZERO;i<=MIN;i++)
		   for(j=ZERO;j<=MIN;j++)
		      for(k=ZERO;k<=MIN;k++)
		         for(l=ZERO;l<=MIN;l++)
		            if(i+j+k+l==n)
		               count++;
		printf("%d\n",count);
	}
	return 0;
}


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

const long MOD = 1'000'000'007;

int main() {
	string s; cin >> s;
	for (auto c: s) {
		if (c == '7') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


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

constexpr double eps = 1e-9;
 
struct segtree {
    vector<long long> dat;
    int n;
 
    segtree(int n_) {
        n = 1;
 
        while (n < n_) n *= 2;
 
        dat.resize(2*n, 0);
    }
 
    void update(int i, int x) {
        i += n - 1;
        int diff = x - dat[i];
        dat[i] = x;
 
        while (i > 0) {
            i = (i - 1) / 2;
            dat[i] += diff;
        }
    }
 
    long long query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r == -1) r = n;
 
        if (r <= a || l >= b) return 0;
 
        if (a <= l && r <= b) {
            return dat[k];
        }
 
        long long lv = query(a, b, k * 2 + 1, l, (l + r) / 2);
        long long rv = query(a, b, k * 2 + 2, (l + r) / 2, r);
 
        return lv + rv;
    }
};

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

    int N; cin >> N;
    vector<int> a(N), b(N);
 
    segtree P(N), Q(N);
    vector<pair<int, int>> A, B;
 
    for (int i = 0; i < N; ++i) {
        cin >> a[i] >> b[i];
        A.push_back(make_pair(a[i], b[i]));
    }
 
    sort(begin(A), end(A));
 
    for (int i = 0; i < N; ++i) {
        B.push_back(make_pair(A[i].second, i));
    }
 
    sort(begin(B), end(B));
     
    for (int i = 0; i < N; ++i) {
        P.update(i, A[i].first);
        Q.update(i, 1);
    }
 
    long long ma = 0;
 
    for (pair<int, int>& d : B) {
        int l = 0, r = N;

        long long PP, QQ;
 
        for (int j = 0; j < 20; ++j) {
            int mid = (l + r) / 2;

            PP = P.query(0, mid + 1);
            QQ = Q.query(0, mid + 1);
 
            if (PP <= d.first * QQ) {
                l = mid;
            } else {
                r = mid;
            }
        }

        if (double(PP) / QQ - eps < d.first) {
            ma = max(ma, QQ);
        }
 
        P.update(d.second, 0);
        Q.update(d.second, 0);
    }
 
    cout << ma << endl;
}

Measured memory_bytes: 29904
#include<iostream>

using namespace std;

typedef long long ll;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main(){
	ll A, B, C, D; cin >> A >> B >> C >> D;
	ll CD = C*D/GCD(C, D);

	ll abs = B - A + 1;
	ll cd = B/C - (A-1)/C;
	ll dd = B/D - (A-1)/D;
	ll cdd = B/CD - (A-1)/CD;

	cout << abs - (cd + dd - cdd) << endl;
	
	return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    if(a+b<=2*c){
        cout<<a*x+b*y<<endl;
    }else{
        int ans = inf;
        //cout<<2*max(x,y)<<endl;
        for(int i=0;i<=2*max(x,y);i++){
            if(i%2!=0) continue;
            //if(i==866) cout<<"check"<<i<<endl;
            int now=0;
            now+=i*c;
            int xx=x-i/2;
            int yy=y-i/2;
            now+=(a*max(xx,0)+b*max(yy,0));
            ans = min(ans,now);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
// きりみんちゃんねるからきました 2020/02/02 22:10

package main

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

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

func f(i, limit, k, ret int) int {
	if i == limit {
		return ret
	}
	r1 := ret * 2
	r2 := ret + k
	if r1 < r2 {
		return f(i+1, limit, k, r1)
	} else {
		return f(i+1, limit, k, r2)
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	n, k := nextInt(), nextInt()
	// だるいので全探索
	ans := f(0, n, k, 1)
	fmt.Println(ans)

}

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


Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int i = 0;i < N;i++){
            a[i] = sc.nextInt();
        }
        int x;
        int max = 0;
        int[] num = new int[100001];
        for(int i = 0;i < N ;i++){
            num[a[i]]++;
        }
        for(int j = 0;j < N;j++){
            x = a[j];
            int count = 0;
            if(x == 0){
                count = num[x] + num[x+1];
            }
            else{
                count = num[x] + num[x-1] + num[x+1];
            }
            max = Math.max(max,count);
        }
        System.out.println(max);
    }
}


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

int main() {
    ll n, m, k;
    cin >> n >> m >> k;

    vector<ll> a(n), b(m), sa(n, 0), sb(m, 0);
    ll prev = 0;
    for (int i = 0; i < n; i++)
        cin >> a[i], sum_a[i] = a[i] + prev, prev = sa[i];
    prev = 0;
    for (int i = 0; i < m; i++)
        cin >> b[i], sb[i] = prev + b[i], prev = sb[i];
*/

#include <bits/stdc++.h>

using namespace std;
#define int long long

int32_t main(){ 
//    int g;
//    cin >> g;    
    for(int a0 = 0; a0 < 1; a0++){
        int n;
        int m;
        int x;
        cin >> n >> m >> x;
        
        vector<int> a(n);
        for(int a_i = 0; a_i <n; a_i++){
           cin >> a[a_i];
        }
        
        vector<int> b(m);
        for(int b_i =0; b_i <m; b_i++){
           cin >> b[b_i];
        }
        
        int sum=0,count=0,temp=0,i=0,j=0;        
        
        while(i<n && sum+a[i]<=x){    //considering only first stack and calculating count
            sum+=a[i];
            i++;
        }
        count=i;        
       
        while(j<m && i>=0){          //now adding one element of second stack at a time and subtracting the top element of first stack and calculating the count   
            sum+=b[j];             
            j++;
            while(sum>x && i>0){
                i--;
                sum-=a[i];
            }
            if(sum<=x && i+j>count)
                count=i+j;
        }
        cout<<count<<endl;
    } 
    return 0;
}
    



Measured memory_bytes: 6428
A, B, M = [int(str) for str in input().strip().split()]
a = [int(str) for str in input().strip().split()]
b = [int(str) for str in input().strip().split()]
xyc = [[int(str) for str in input().strip().split()] for _ in range(M)]

min_price = min(a) + min(b)

for x, y, c in xyc:
    price = a[x - 1] + b[y - 1] - c
    min_price = min(min_price, price)

print(min_price)

Measured memory_bytes: 81888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n, k;
  cin >> n >> k;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  ll sum = 0;
  ll z = k * (k - 1) / 2%MOD;
  rep(i, n){
    ll p = 0;
    ll q = 0;
    for (ll j = i+1; j < n; j++){
      if(a[i]>a[j]){
        p++;
      }
    }
    for (ll l = 0; l < i+1;l++){
      if(a[i]>a[l]){
        q++;
      }
    }
    sum += p * k;
    sum %= MOD;
    sum += (p + q) * z;
    sum %= MOD;
  }
  sum %= MOD;
  print(sum);
}

Measured memory_bytes: 3648
#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;
    int ans = 0;
    if (n%2 == 1) ans = (n+1)/2;
    else ans = n/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

#include <atcoder/dsu>
using namespace std;
using ll = long long int;

int main(int, char **) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    auto dsu = atcoder::dsu(n);
    for (size_t i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        dsu.merge(a, b);
    }
    cout << dsu.groups().size() - 1 << endl;
    return 0;
}


Measured memory_bytes: 8988
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    int a[100002], b[100002];
    P p[200002];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        p[i] = P(a[i], 0);
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
        p[n + i] = P(b[i], 1);
    }
    sort(p, p + n * 2);
    ll r = 0;
    ll ans = 1;
    for(int i = 0; i < n * 2; i++){
        if(p[i].second == 0){
            if(r < 0) ans = ans * -r % MOD;
            r++;
        }
        else{
            if(r > 0) ans = ans * r % MOD;
            r--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
fn read<T: std::str::FromStr>() -> T {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).ok();
	s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().split_whitespace()
		.map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
	(0..n).map(|_| read_vec()).collect()
}

pub trait LexicalPermutation {
	/// Return `true` if the slice was permuted, `false` if it is already
	/// at the last ordered permutation.
	fn next_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T] where T: Ord {
	/// Original author in Rust: Thomas Backman <serenity@exscape.org>
	fn next_permutation(&mut self) -> bool {
		// These cases only have 1 permutation each, so we can't do anything.
		if self.len() < 2 { return false; }

		// Step 1: Identify the longest, rightmost weakly decreasing part of the vector
		let mut i = self.len() - 1;
		while i > 0 && self[i-1] >= self[i] {
			i -= 1;
		}

		// If that is the entire vector, this is the last-ordered permutation.
		if i == 0 {
			return false;
		}

		// Step 2: Find the rightmost element larger than the pivot (i-1)
		let mut j = self.len() - 1;
		while j >= i && self[j] <= self[i-1]  {
			j -= 1;
		}

		// Step 3: Swap that element with the pivot
		self.swap(j, i-1);

		// Step 4: Reverse the (previously) weakly decreasing part
		self[i..].reverse();

		true
	}
}

fn main() {
	let n: usize = read();

	let ans = {
		if n % 2 == 0 {
			n/2
		} else {
			n/2 + 1
		}
	};

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


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

using ll = long long int;

typedef pair<int, int> P;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;

ll l[MAX_N];
ll r[MAX_N];

pair<ll, ll> p[MAX_N];

ll min_r = INF;
ll max_l = -1L;

inline bool cmp(pair<ll, ll> a, pair<ll, ll> b) {
  return a.first < b.first || (a.first == b.first && a.second > b.second);
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%lld %lld", &(l[i]), &(r[i]));
    max_l = max(max_l, l[i]);
    min_r = min(min_r, r[i]);
  }

  ll ans = 0L;

  // for case that a part of group is singleton
  for (int i = 0; i < n; ++i) {
    if(l[i]<max_l&&min_r<r[i])
    ans = max(ans, max(min_r - max_l + 1, 0LL) + r[i] - l[i] + 1L);
  }

  for (int i = 0; i < n; ++i) {
    p[i].first = max(min_r - l[i] + 1L, 0LL);   // first: fixed right
    p[i].second = max(r[i] - max_l + 1L, 0LL);  // second: fixed left
  }

  sort(p, p + n, cmp);

  ll part = p[0].second;
  for (int i = 1; i < n; ++i) {
    ans = max(ans, part + p[i].first);
    part = min(part, p[i].second);
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main(){
    int n;
    while(cin >> n,n){
        vector<int>v(n+1,0);
        rep(i,n+1){
            if(i)v[i] = v[i-1]+i;
        }
        int cnt = 0;
        for(int i =0; i<=n;i++){
            for(int j = i+2; j<=n;j++){
                if(v[j]-v[i] == n)cnt++;
            }
        }
        cout << cnt << endl;
    }
}




Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,x,t;
  cin>>n>>x>>t;
  if(n%x==0){
   cout<<(n/x)*t<<"\n";
  }
  else
 {
  cout<<((n/x)+1)*t<<"\n";
 }
}


Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
typedef long long ll;


using namespace std;

int main() {
	int n;
	cin >> n;
	if (n < 1200) {
		cout << "ABC" << endl;
	}
	else {
		if (n < 2800) {
			cout << "ARC" << endl;
		}
		else {
			cout << "AGC" << endl;
		}
	}
}


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

int main() {
	int K, A, B;
	cin >> K >> A >> B;

	for(int i=A; i<= B; i++){
		if(i % K == 0){
			cout << "OK" << endl;
			break;
		}else if(i == B){
			cout << "NG" << endl;
		}
	}
}


Measured memory_bytes: 3632
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

vector<int> G[maxn];

int Can[maxn],l[maxn],r[maxn],Ans[maxn];

void dfs(int u,int f){
	Can[u]=2;l[u]=-100000;r[u]=20000;
	if(Ans[u]!=-1)Can[u]=Ans[u]&1,l[u]=r[u]=Ans[u];
	for(auto v:G[u])if(v!=f){
		dfs(v,u);
		if(Can[v]==2)continue;
		if(Can[u]==2)Can[u]=!Can[v],l[u]=l[v]-1,r[u]=r[v]+1;
		else{
			if(Can[u]==Can[v]){puts("No");exit(0);}
			l[u]=max(l[u],l[v]-1);r[u]=min(r[u],r[v]+1);
		}
	}
	if(l[u]>r[u]){puts("No");exit(0);}
}

void dfs2(int u,int f){
	for(auto v:G[u])if(v!=f){
		if(Ans[v]==-1)
			if(Ans[u]-1>=l[v])Ans[v]=Ans[u]-1;else Ans[v]=Ans[u]+1;
		dfs2(v,u);
	}
}

void Work(){
	dfs(1,0);
	if(Ans[1]==-1)Ans[1]=l[1];
	dfs2(1,0);
	puts("Yes");
	REP(i,1,n)printf("%d\n",Ans[i]);
}

void Init(){
	read(n);
	REP(i,2,n){
		int u,v;read(u,v);
		G[u].PB(v);G[v].PB(u);
	}
	REP(i,1,n)Ans[i]=-1;
	int K;
	read(K);
	while(K--){
		int x,y;
		read(x,y);
		Ans[x]=y;
	}
}

int main(){
	Init();
	Work();
	return 0;
}


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

int main() {
  string S , T ; 
  int N ; 
  int C = 0 ;
  cin >> S >> T ; 
  
  N = S.size() ; 
  
  for (int i = 0 ; i < N ; i++){
    if (S.at(i) != T.at(i)){
      C++ ; 
      
    }
    
  }
  
  cout << C << endl ; 
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 2e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
const ll INF = (1ll)<<60;
const int MOD = 1e9+7;

int n,m;
int a[maxN];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		a[l]+=1;
		a[r+1] -=1;
	}
	int cnt = 0;
	for(int i=1;i<=n;i++)
	{
		a[i] += a[i-1];
		if(a[i] == m)
			cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	ll h, w;
	cin >> h >> w;
	if (h == 1 || w == 1) cout << "1" << endl;
	else {
		ll num = h * w;
		num = num / 2 + num % 2;
		cout << num << endl;
	}return 0;
}

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

//no of ways to reach ith row and jth column
int dp[1001][1001];


int32_t main()
{
	int H, W;
	cin >> H >> W;
	char arr[H][W];
	for(int i=0; i<H;i++ ){
		for(int j=0;j<W;j++){
			cin >> arr[i][j];			 
		}
	}

	//trivial cases                   //since rows and column in dp[][] are items not indices
	for(int i=0;i<1001;i++)
	{
		dp[0][i]=0;
		dp[i][0]=0;
	}

	//base cases: 
	int flag=0;
	for(int i=0;i<H;i++)
	{
		if(arr[i][0]=='#')             //once you encounter a # on the first column then you cannot
			flag=1;                    //reach any cell below in that column.
		if(flag)
			dp[i+1][1]=0;
		else
			dp[i+1][1]=1;
	}

	flag=0;
	for(int i=0;i<W;i++)
	{
		if(arr[0][i]=='#')				//once you encounter a # on the first row then you cannot 
			flag=1;						//reach any cell to the right of it.
		if(flag)
			dp[1][i+1]=0;
		else
			dp[1][i+1]=1;
	}


	//NOTE due to the constrain by equation (1), i or j cannot be less than 2 hence
	//value dp[1][j] and dp[i][1] are handled by the base case above.
	for(int i=2;i<=H;i++)
	{
		for(int j=2;j<=W;j++)
		{
			if(arr[(i-1)-1][j-1]=='#' && arr[i-1][(j-1)-1]=='#')                 //-(1)
				dp[i][j] = 0;
			else if(arr[(i-1)-1][j-1]=='#' || arr[i-1][(j-1)-1]=='#')
			{
				if(arr[(i-1)-1][j-1]=='#')
					dp[i][j] = dp[i][j-1]; 
				if(arr[i-1][(j-1)-1]=='#')
					dp[i][j] = dp[i-1][j];
			}
			else
				dp[i][j] = (dp[i-1][j]%modul + dp[i][j-1]%modul)%modul;
		}
	}


	cout << dp[H][W];



	return 0;
}

Measured memory_bytes: 8440
(defun solve (n points)
  (let ((happiness (make-array (list n 3) :element-type 'fixnum))
        (first-day (pop points)))
    (setf (aref happiness 0 0) (nth 0 first-day))
    (setf (aref happiness 0 1) (nth 1 first-day))
    (setf (aref happiness 0 2) (nth 2 first-day))
    (loop for i from 1
          for (a b c) in points
          do
          (setf (aref happiness i 0)
                (+ (max (aref happiness (1- i) 1)
                        (aref happiness (1- i) 2))
                   a))
          (setf (aref happiness i 1)
                (+ (max (aref happiness (1- i) 0)
                        (aref happiness (1- i) 2))
                   b))
          (setf (aref happiness i 2)
                (+ (max (aref happiness (1- i) 0)
                        (aref happiness (1- i) 1))
                   c)))
    (max (aref happiness (1- n) 0)
         (aref happiness (1- n) 1)
         (aref happiness (1- n) 2))))

#-swank
(let* ((n (read))
       (points (loop repeat n collect (list (read) (read) (read)))))
  (format t "~A~%" (solve n points)))


Measured memory_bytes: 66024
#include <bits/stdc++.h>
using namespace std;
#define int long long
struct FenwickTreeMax {
    vector<int> bit;
    int n;
    const int INF = (int)1e9;

    FenwickTreeMax(int n) {
        this->n = n;
        bit.assign(n, 0);
    }

    FenwickTreeMax(vector<int> a) : FenwickTreeMax(a.size()) {
        for (size_t i = 0; i < a.size(); i++)
            update(i, a[i]);
    }

    int getmax(int r) {
        int ret = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            ret = max(ret, bit[r]);
        return ret;
    }

    void update(int idx, int val) {
        for (; idx < n; idx = idx | (idx + 1))
            bit[idx] = max(bit[idx], val);
    }
};
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  vector<array<int,3>> h(n);
  int idx=0;
  for(auto &e: h) {
    e[2] = idx++;
    cin >> e[0];
  }
  for(auto &e: h) cin >> e[1];
  sort(h.begin(),h.end());
  auto ft = FenwickTreeMax(n);
  for(int i=0;i<n;i++) {
    int val = ft.getmax(h[i][2]);
    // cerr << "Max for " << h[i][0] << " = " << val << '\n';
    ft.update(h[i][2],val+h[i][1]);
  }
  int ans = 0;
  for(int i=0;i<n;i++) {
    ans = max(ans,ft.getmax(i));
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 6528
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 21:39:55 2020

@author: liang
"""

# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 20:56:06 2020

@author: liang
"""

N = int(input())
L = [int(x) for x in input().split()]

from bisect import bisect_left

L.sort()
ans = 0
#print(L)
for i in range(N-2):
    #print("1:",i)
    #p = i+2
    #以下O(2N)　定数倍が遅い
    for j in range(i+1,N-1):
        #print("2",i,j)
        t = L[i] + L[j]
        #while p < N and L[p] < L[i] + L[j] :
        #    p += 1
        p = bisect_left(L,t)
            #print("up")
        #print(p)
        #ans += len(L[j+1:p])
        ans += max(0, p - j -1)
print(ans)

Measured memory_bytes: 9344
use std::io::*;
use std::str::FromStr;

fn main() {
	let n: usize = read();
	let mut temp: i64;
	let mut a = Vec::new();
	for _ in 0..n {
		temp = read();
		a.push(temp);
	}
	let mut v = vec![0_i64; n+1];
	for i in &a {
		v[*i as usize] += 1
	}
	let mut sum = 0_i64;
	for i in &v {
		sum += conbination(*i);
	}
	let mut ans: i64;
	for i in &a {
		temp = v[*i as usize];
		ans = sum - conbination(temp) + conbination(temp - 1);
		println!("{}", ans);
	}
}

fn conbination(n: i64) -> i64 {
	if n < 2 { 0 } else { n*(n-1)/2 }
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}



Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    int w, h, x, y; cin >> w >> h >> x >> y;
    double ans;
    int mlti=0;
    ans = (double)w*h/2;
    if(x==(double)w/2&&y==(double)h/2) mlti = 1;
    
    cout << fixed;
    cout << setprecision(12) << ans << " " << defaultfloat << mlti << endl;

}


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

using namespace std;

int
main()
{
    int n,k;
    cin >> n >> k;

    vector<int> a(n);
    for(int i=0;i<k;i++){
        int d;
        cin >> d;
        for(int j=0;j<d;j++){
            int x;
            cin >> x;
            a[x-1] = 1;
        }
    }

    int ans = 0;
    for(auto i : a) {
        if(i == 0){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    set<int> hoge;
    for(int i=0;i<3;i++){
        int a;
        cin>>a;
        hoge.insert(a);
    }
    
    if(hoge.size()==2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

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

/*int main() {
	string S, T;
	cin >> S >> T;
	int len = S.size();
	for (int i = 0; i < len; i++) {
		int cnt = 0, flag = 0;
		for (int j = i; ; j++) {
			if (cnt == len) break;
			if (S.at(j % len) != T.at(cnt)) {
				flag = 1;
			}
			cnt++;
		}
		if (flag == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}*/

int main() {
	string S, T;
	cin  >> S >> T;
	bool ans =false;
	for(int i = 0; i < (int)S.size(); i++) {
		if (S == T) { // これで比較できるのいいよね,c++.
			ans =true;
			break;
		}
		S = S.back() + S.substr(0, S.size ()-1); //メモリ食いそう...
	}
	if (ans) {
		cout  <<"Yes"<< endl;
	} else{
		cout  <<"No"<< endl;
	}
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a % 3 && b % 3 && (a + b) % 3) cout << "Impossible" << endl;
    else cout << "Possible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

#define eps (1e-10)
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x,y+p.y);}
    Point operator-(Point p) {return Point(x-p.x,y-p.y);}
    Point operator*(double k){return Point(x*k,y*k);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
    bool operator == (const Point &p) const{
    return fabs(x-p.x)<eps && fabs(y-p.y)<eps;
  }
  double dot(Point p){return x*p.x+y*p.y;}
  double det(Point p){return x*p.y-y*p.x;}
};
struct Line{
  Point p1,p2;
  Line(){}
  Line(Point p1, Point p2):p1(p1),p2(p2){}
};
int ccw(Point a,Point b,Point c){
  Point t1=b-a,t2=c-a;
  if(t1.det(t2)> eps) return 1;//counter clockwise
  if(t1.det(t2)< -eps) return -1;//clockwise
  if(t1.dot(t2)< -eps) return 2;//c-a-b online
  if(t1.norm()<t2.norm()) return -2;//a-b-c online
  return 0;//a-c-b online
}
bool intersectSS(Point a,Point b,Point c,Point d){
  return (ccw(a,b,c)*ccw(a,b,d)<=0&&ccw(c,d,a)*ccw(c,d,b)<=0);
}
bool intersectSS(Line l1,Line l2){
  return intersectSS(l1.p1,l1.p2,l2.p1,l2.p2);
}
bool isOrthogonal(Point a,Point b){
  return fabs(a.dot(b))<eps;
}
bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
  return isOrthogonal(a1-a2,b1-b2);
}
bool isParallel(Point a,Point b){
  return fabs(a.det(b))<eps;
}
bool isParallel(Point a1,Point a2,Point b1,Point b2){
  return isParallel(a1-a2,b1-b2);
}
Point CrossPoint(Line l1,Line l2){
    double a=(l1.p2-l1.p1).det(l2.p2-l2.p1);
    double b=(l1.p2-l1.p1).det(l1.p2-l2.p1);
    if(fabs(a)<eps&&fabs(b)<eps) return l2.p1;
    return l2.p1+(l2.p2-l2.p1)*(b/a);
}
Point project(Line l,Point p){
  Point base=l.p2-l.p1;
  double r=(p-l.p1).dot(base)/base.norm();
  return l.p1+base*r;
}
Point reflect(Line l,Point p){
  return p+(project(l,p)-p)*2.0;
}
int main(){
    int q;
    double xp0,yp0,xp1,yp1,xp2,yp2,xp3,yp3;
    cin>>q;
    while(q--){
        cin>>xp0>>yp0>>xp1>>yp1>>xp2>>yp2>>xp3>>yp3;
        Point p0(xp0,yp0),p1(xp1,yp1),p2(xp2,yp2),p3(xp3,yp3);
        if(intersectSS(p0,p1,p2,p3)) cout<<1<<endl;
        else cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 200003, M = N << 1;

int n, k;
int a[N], b[N];
int s[N]/*i+a_i*/, t[N]/*i-a_i*/;
int ton[M];
LL ans;

int main()
{
    n = gi();
    for (int i = 1; i <= n; i+=1) 
        a[i] = gi(), s[i] = i + a[i], t[i] = i - a[i];
    for (int i = 1; i <= n; i+=1)
        if (s[i] < 200000) ++ton[s[i]];
    for (int i = n; i >= 1; i-=1)
    {
        if (t[i] <= 0) continue;
        if (t[i] >= 200000) continue;
        ans += ton[t[i]];
        if (s[i] < 200000) --ton[s[i]];
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 6884
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

//約数列挙
template <class T>
vector<T> divisor(T x){
	vector<T> res;
	for(T i=1;i*i<=x;i++){
		if(x%i==0){
			res.push_back(i);
			if(i!=x/i){
				res.push_back(x/i);
			}
		}
	}
	return res;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll x;
	cin>>x;
	vector<ll> ret=divisor(x);
	for(ll d:ret){//a-b=d
		ll now=x/d;
		FOR(b,-ll(20000),ll(20000)){
			ll a=b+d;
			if(a*a*a*a+a*a*a*b+a*a*b*b+a*b*b*b+b*b*b*b==now){
				cout<<a<<' '<<b<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3620
import sys
from collections import deque, defaultdict


def bfs01(s, t, links):
    q = deque([(0, s, -1)])  # cost, station, last-company
    visited = set()
    while q:
        d, v, e = q.popleft()
        if v == t:
            return d
        if (v, e) in visited:
            continue
        visited.add((v, e))
        if e == 0:
            q.extend((d + 1, u, c) for c in links[v] for u in links[v][c] if (u, c) not in visited)
        else:
            q.extendleft((d, u, e) for u in links[v][e] if (u, e) not in visited)
            if (v, 0) not in visited:
                q.appendleft((d, v, 0))

    return -1


readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

n, m = map(int, readline().split())
links = [defaultdict(set) for _ in range(n)]
pqc = list(map(int, read().split()))
for p, q, c in zip(pqc[0::3], pqc[1::3], pqc[2::3]):
    p -= 1
    q -= 1
    links[p][c].add(q)
    links[q][c].add(p)

print(bfs01(0, n - 1, links))


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

int main(void){
	int x,y;

	while(cin){
		cin >> x >> y;
		if(x==0&&y==0) break;
		if(x<y) cout << x << " " << y << endl;
		else cout << y << " " << x << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		char[] c = w.toCharArray();
		char a = 'a';
		int acha = (int)a;
		a = 'z';
		int zcha = (int)a;
		int count = 0;
		for (int i = acha; i < zcha + 1; i++) {
			for (char x: c) {
				if (x == (char)i) {
					count++;
				}
			}
			if (count % 2 == 1) {
				System.out.println("No");
				return;
			}
			count = 0;
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4765
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(100005);
 
mint f(int n, int k) {
  if (n < 0) return 0;
  // nPk = nCk * k!
  mint res = comb(n,k);
  res *= comb.fact[k];
  return res;
}
 
int k;
mint ans;
vector<int> to[100005];
void dfs(int v, int p=-1) {
  for (int u : to[v]) {
    if (u == p) continue;
    dfs(u,v);
  }
  int nk = (p==-1) ? k : k-2;
  int c = (p==-1) ? to[v].size()+1 : to[v].size()-1;
  ans *= f(nk,c);
}
 
int main() {
  int n;
  cin >> n >> k;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans = 1;
  dfs(0);
  cout<<ans.x<<endl;
  return 0;
}

Measured memory_bytes: 10752
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
const int maxx=100010;

vector<int> A[maxx];
int pre[maxx],parent[maxx],low[maxx];
bool flag[maxx];
int v,e,now=1;

void dfs(int u){
	flag[u]=true;
	low[u]=now;
	pre[u]=now;
	now++;
	for(int i=0;i<A[u].size();i++){
		if(flag[A[u][i]]==false) {//if the next has not been visited
			parent[A[u][i]]=u;//update the parent array
			dfs(A[u][i]);//dfs the next point
			low[u]=min(low[u],low[A[u][i]]);//if the low value of son point is smaller
		}
		else if(parent[u]!=A[u][i]){//if a point has been visited and the edge between u and A[u][i] is not in dfs tree,
			low[u]=min(low[u],pre[A[u][i]]);//update the value of low array
		}
		
	}
	return ;
}


int main (){
	int x,y;
	parent[0]=0;
	for(int i=0;i<maxx;i++){
		flag[i]=false;
	}
	cin>>v>>e;
	while(e--){
		cin>>x>>y;
		A[x].push_back(y);
		A[y].push_back(x);
	}
	dfs(0);
	
	//for(int i=0;i<v;i++) cout<<i<<"  "<<low[i]<<endl;//debug
	
	set<int> ans;//save the answer data in set
	int cnt=0;
	for(int i=1;i<v;i++){
		int p=parent[i];
		if(p==0) cnt++;
		else if(pre[p]<=low[i]) ans.insert(p);
	}
	if(cnt>=2) ans.insert(0);
	for(set<int>::iterator it=ans.begin();it!=ans.end();it++) cout<<*it<<endl;
	return 0;
	
}


Measured memory_bytes: 6816