akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

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

  vi x(N), y(N);
  vector<char> d(N);
  for (ll i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> d[i];
  }

  vvi vx(3), vy(3);
  for (ll i = 0; i < N; i++) {
    if (d[i] == 'U') {
      vx[1].push_back(x[i]);
      vy[2].push_back(y[i]);
    } else if (d[i] == 'R') {
      vx[2].push_back(x[i]);
      vy[1].push_back(y[i]);
    } else if (d[i] == 'D') {
      vx[1].push_back(x[i]);
      vy[0].push_back(y[i]);
    } else {
      vx[0].push_back(x[i]);
      vy[1].push_back(y[i]);
    }
  }

  auto f = [](vi v) {
    sort(v.begin(), v.end());
    vi ret;
    if (v.size() == 0) return ret;
    ret.push_back(v.front());
    if (v.size() == 1) return ret;
    ret.push_back(v.back());
    return ret;
  };

  for (ll i = 0; i < 3; i++) {
    vx[i] = f(vx[i]);
    vy[i] = f(vy[i]);
  }

  vector<double> vt;
  vt.push_back(0);

  auto g = [&](vvi v) {
    for (ll i = 0; i < 3; i++) {
      for (ll j = i + 1; j < 3; j++) {
        for (auto k: v[i]) {
          for (auto l: v[j]) {
            pii left = {i - 1, k};
            pii right = {j - 1, l};
            double t = (double)(right.second - left.second) / (left.first - right.first);
            if (t >= 0) vt.push_back(t);
          }
        }
      }
    }
  };

  g(vx);
  g(vy);

  auto h = [&](double t) {
    vector<double> xs, ys;
    for (ll i = 0; i < 3; i++) {
      for (auto k: vx[i]) {
        xs.push_back(t * (i - 1) + k);
      }
      for (auto k: vy[i]) {
        ys.push_back(t * (i - 1) + k);
      }
    }
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    return (xs.back() - xs.front()) * (ys.back() - ys.front());
  };

  vector<double> ans;
  for (auto t: vt) {
    ans.push_back(h(t));
  }

  cout << setprecision(10) << fixed;
  cout << *min_element(ans.begin(), ans.end()) << endl;
}


Measured memory_bytes: 4136
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<cstdio>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = n-1; i >=0; i--)
#define lint long long
#define all(x) (x).begin(), (x).end()

int main(){
    long t1, t2, a1, a2, b1, b2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    long p1 = (b1-a1)*t1;
    long p2 = p1+(b2-a2)*t2;
    if((p1>0 && p2>0) || (p1<0 && p2<0)){
        cout << 0 << endl;
        return 0;
    }
    else if (p2 == 0){
        cout << "infinity" << endl;
        return 0;
    }
    else{ // ifugou
        long k = abs(p1) / abs(p2);
        if (abs(p1) % abs(p2) == 0) cout << 2*k << endl;
        else cout << 2*k+1 << endl;
        return 0;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# input
a = int(input())
num = [int(a) for a in input().split()]
# Odd or Even
counter = 0
while True:
    b = list(map(lambda x: x % 2, num))
    if b.count(0) == a:
        num = list(map(lambda x: x/2, num))
        counter += 1
    else:
        print(counter)
        break


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
// using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // int[] nx = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // long K = long.Parse(Console.ReadLine());
            // int[] ABC = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int s = int.Parse(Console.ReadLine());
            // int i = int.Parse(Console.ReadLine());
            int n = int.Parse(Console.ReadLine());
            // string A = Console.ReadLine();
            // string B = Console.ReadLine();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(int.Parse);
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // for(int i = 0; i<A_num.Length;i++){
            //     A_num[i] = 0;
            // }
            int sum = 0;
            for(int i =0; i<=n;i++){
                sum+=i;
            }
            Console.WriteLine(sum);
        }
        //最小公倍数
        static long Lcm(long a, long b)
        {
            return a/Gcd(a,b)*b;
        }

        //最大公約数
        static long Gcd(long m, long n)
        {
            if(n==0)return m;
            return Gcd(n,m%n);
        }
    }
}

Measured memory_bytes: 11092
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
b = gets.chomp.split(' ').map(&:to_i)

d = (0...n).map { |i| b[i] - a[i] }.sort
temp = d.select { |i| i > 0 }
m = temp.count
if m == 0
  puts(0)
else
  s = temp.inject(&:+)
  0.upto(n - 1) do |i|
    if d[i] >= 0
      break
    else
      s += d[i]
      m += 1
    end
    break if s <= 0
  end
  puts(s <= 0 ? m : -1)
end


Measured memory_bytes: 19600
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>()> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const lint di[]{0, -1, 0, 1, -1, -1, 1, 1};
const lint dj[]{1, 0, -1, 0, 1, -1, -1, 1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for (int i=0; i<m; ++i){
        cin >> b[i];
    }
    vector<vector<int>> a(n);
    for (int i=0; i<n; ++i){
        a[i].resize(m);
        for (int j=0; j<m; ++j){
            cin >> a[i][j];
        }
    }
    int ans = 0;
    int num = 0;
    for (int i=0; i<n; ++i){
        num = c;
        for (int j=0; j<m; ++j){
            num += a[i][j] * b[j];
        }
        if(num > 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int digit(int,long long);
void ABC060(int,int,int);
void ABC058(string,string);
void line(int);
int main(){
	int n,k,ans=1;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		if(ans<k){
			ans*=2;
		}
		else ans+=k;
	}
	cout<<ans<<endl;
}
void ABC060(int a,int b,int c){
	
	for(int u=1;u<100;u++){
		if(a*u%b==c){
			cout<<"YES"<<endl;
			break;
			}
		else if(a*u%b==0){
			cout<<"NO"<<endl;
			break;
		}
	}
}
int digit(int n,long long dig){
	return n%(dig*10)/dig;
}
void ABC058(string o,string e){
	int z=o.size(),x=e.size();
	for(int i=0;i<z+x;i++){
		if(i%2==0){
			cout<<o[i/2];
		}
		else{
			cout<<e[(i+1)/2-1];
		}
	}
	cout<<endl;
}
void line(int w){
	for(int k=0;k<w+2;k++){
		cout<<"#";
	}
	cout<<endl;
}


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

const int MAXN = 100000;
int a[MAXN + 1], mx[MAXN + 1];
ll ans[MAXN + 1];

int main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    multiset<int> s1, s2;
    ll sum1 = 0, sum2 = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        if(a[mx[i - 1]] < a[i])
            mx[i] = i;
        else
            mx[i] = mx[i - 1];
    }
    int pos = mx[n];
    for(int j = pos; j <= n; j++)
        if(a[mx[pos - 1]] < a[j])
            s1.insert(a[j]), sum1 += a[j];
        else
            s2.insert(a[j]);
    while(pos > 1) {
        int npos = mx[pos - 1];
        int cur = a[npos];
        ans[pos] += sum1 - (ll)s1.size() * cur;
        sum1 = (ll)s1.size() * cur;
        for(int j = npos; j < pos; j++)
            if(a[mx[npos - 1]] < a[j])
                s1.insert(a[j]), sum1 += a[j];
            else
                s2.insert(a[j]);
        while(!s2.empty()) {
            auto it = s2.end();
            it--;
            if(a[mx[npos - 1]] < *it) {
                s1.insert(*it);
                sum1 += *it;
                s2.erase(it);
            } else
                break;
        }
        pos = npos;
    }
    while(!s2.empty()) {
        auto it = s2.end();
        it--;
        s1.insert(*it);
        sum1 += *it;
        s2.erase(it);
    }
    ans[pos] += sum1;
    for(int i = 1; i <= n; i++)
        cout << ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 7424
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (a > 0 && c > 0) {
		c -= b;
		if (c <= 0) break;
		a -= d;
		if (a <= 0) break;
	}
	if (a > 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3532
#include<bits/stdc++.h>
using namespace std;
int n, fa[100007], sz[100007], dep[100007], hvs[100007], id[100007], pos[100007], tp[100007], cnt;
int t1[400007], t2[400007], tag[400007], re[100007][2];
vector<int>e[100007];
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int dfs1(int w, int f)
{
	sz[w] = 1;
	for(int i=e[w].size()-1;i>=0;i--)
		if (e[w][i] != f)
		{
			fa[e[w][i]] = w;
			dep[e[w][i]] = dep[w] + 1;
			dfs1(e[w][i], w);
			sz[w] += sz[e[w][i]];
			if (sz[e[w][i]] > sz[hvs[w]])hvs[w] = e[w][i];
		}
	return 0;
}
int dfs2(int w, int top)
{
	id[w] = ++cnt;
	pos[cnt] = w;
	tp[w] = top;
	if (hvs[w])dfs2(hvs[w], top);
	for (int i = e[w].size() - 1; i >= 0; i--)
		if (e[w][i] != fa[w] && e[w][i] != hvs[w])
			dfs2(e[w][i], e[w][i]);
	return 0;
}
int down(int w)
{
	if ((!tag[w]) && (!t2[w]))return 0;
	t1[2 * w] += tag[w];
	t1[2 * w + 1] += tag[w];
	tag[2 * w] += tag[w];
	tag[2 * w + 1] += tag[w];
	t2[2 * w] ^= t2[w];
	t2[2 * w + 1] ^= t2[w];
	tag[w] = 0;
	t2[w] = 0;
	return 0;
}
int up(int w)
{
	t1[w] = min(t1[2 * w], t1[2 * w + 1]);
	return 0;
}
int change(int w, int l, int r, int x, int y, int v1, int v2)
{
	if (x <= l && r <= y)
	{
		t1[w] += v2;
		t2[w] ^= v1;
		tag[w] += v2;
		return 0;
	}
	down(w);
	int mid = (l + r) / 2;
	if (x <= mid)change(2 * w, l, mid, x, y, v1, v2);
	if (y > mid)change(2 * w + 1, mid + 1, r, x, y, v1, v2);
	up(w);
	return 0;
}
pair<int,int>find(int w, int l, int r)
{
	if (l == r)return make_pair(l, t2[w]);
	down(w);
	int mid = (l + r) / 2;
	if (t1[2 * w] == 1)return find(2 * w, l, mid);
	else return find(2 * w + 1, mid + 1, r);
}
int main()
{
	n = read();
	for (int i = 1; i < n; i++)
	{
		int a = read(), b = read();
		e[a].push_back(b);
		e[b].push_back(a);
	}
	for (int i = 1; i < n; i++)
	{
		re[i][0] = read();
		re[i][1] = read();
	}
	dep[1] = 1;
	dfs1(1, 0);
	dfs2(1, 1);
	for (int i = 1; i < n; i++)
	{
		int a = re[i][0], b = re[i][1];
		while (tp[a] != tp[b])
		{
			if (dep[tp[a]] < dep[tp[b]])swap(a, b);
			change(1, 1, n, id[tp[a]], id[a], i, 1);
			a = fa[tp[a]];
		}
		if (dep[a] < dep[b])swap(a, b);
		if (id[b] != id[a])change(1, 1, n, id[b] + 1, id[a], i, 1);
	}
	change(1, 1, n, 1, 1, 0, 1000000000);
	for (int i = 1; i < n; i++)
	{
		if (t1[1] != 1)
		{
			cout << "NO" << endl;
			return 0;
		}
		pair<int, int>res = find(1, 1, n);
		int a = re[res.second][0], b = re[res.second][1];
		while (tp[a] != tp[b])
		{
			if (dep[tp[a]] < dep[tp[b]])swap(a, b);
			change(1, 1, n, id[tp[a]], id[a], res.second, -1);
			a = fa[tp[a]];
		}
		if (dep[a] < dep[b])swap(a, b);
		if (id[b] != id[a])change(1, 1, n, id[b] + 1, id[a], res.second, -1);
		change(1, 1, n, res.first, res.first, 0, 1000000000);
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 19584
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static string ReadLine() { return Console.ReadLine().Trim(); }
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    static void Display(int[] xs) {
//        for (int i = 0; i < xs.Length; i++) {
//            if (i > 0) Console.Write(' ');
//            Console.Write(xs[i]);
//        }
//        Console.WriteLine();


//        string[] ss = new string[xs.Length];
//        for (int i = 0; i < xs.Length; i++) {
//            ss[i] = xs[i].ToString();
//        }

//        Console.WriteLine(string.Join(" ", ss));

        // string[] ss = xs.Select(e => e.ToString()).ToArray();
        Console.WriteLine(string.Join(" ", (string[])xs.Select(e => e.ToString()).ToArray()));
    }

    // OK
    static void Display1(int[] xs) {
        string[] ss = xs.Select(e => e.ToString()).ToArray();
        Console.WriteLine(string.Join(" ", ss));
    }

    // NG: ?????????????????¨??????
    // error CS1502: The best overloaded method match for `string.Join(string, string[])' has some invalid arguments
//    static void Display2(int[] xs) {
//        Console.WriteLine(string.Join(" ", xs));
//    }

    // OK: string[] ????????£??????????????¨?????????????????§??????
    static void Display3(int[] xs) {
        Console.WriteLine(string.Join(" ", (string[])xs.Select(e => e.ToString()).ToArray()));
    }

    static void Main() {
        int n = ReadInt();
        int[] xs = ReadInts();
        if (n != xs.Length) throw new Exception();

        Display(xs);
        for (int i = 1; i < xs.Length; i++) {
            int key = xs[i];
            // insert xs[i] into the sorted sequence xs[0..j-1]
            int j = i - 1;
            while (j >= 0 && xs[j] > key) {
                xs[j+1] = xs[j];
                j--;
            }
            xs[j+1] = key;

            // output
            Display(xs);
        }
    }
}

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

int main()
{
	ll N, A, B, ans;
	cin >> N >> A >> B;

	if (N % (A + B) > A) { ans=(N / (A + B) + 1)* A; }
	else { ans=N / (A + B) * A + N % (A + B); }

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll p[300][300];
const ll inf = ~0U >> 1;
ll e[300][300];
bool t[300][300];
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            e[i][j] = inf;
            t[i][j] = true;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> p[i][j];
            e[i][j] = p[i][j];
        }
    }
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (k != i && k!= j && p[i][j] == e[i][k] + e[k][j]) {
                         t[j][i] = false;
                        t[i][j] = false;
                }
                e[i][j] = min(e[i][j], e[i][k] + e[k][j]);
                if (e[i][j] < p[i][j]) {
                    puts("-1");
                    return 0;
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (t[i][j]) {
                ans += e[i][j];
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  string w;
  cin >> w;
  bool pred = true;
  for(char c = 'a'; pred && c <= 'z'; ++c) {
    pred = count(begin(w),end(w),c) % 2 == 0;
  }

  cout << (pred ? "Yes" : "No") << endl;
  return 0;
}


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

using namespace std;
int main()
{
    int ara[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    int x, y;
    cin >> x >> y;
    printf("%s\n",ara[x]==ara[y]?"Yes":"No");
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

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

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

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

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

  int N, F, ans = 0;
  cin >> N >> F;
  map< pair<string, string>, int > mp;
  rep(i, N) {
    int M;
    cin >> M;
    vector<string> vec;
    rep(j, M) {
      string item;
      cin >> item;
      vec.push_back(item);
    }
    rep(j, M) reps(k, j+1, M) {
      auto p = minmax(vec[j], vec[k]);
      if(mp.count(p)) mp[p]++;
      else mp[p] = 1;
      if(mp[p] == F) ans++;
    }
  }

  cout << ans << endl;
  for(auto p : mp) {
    if(p.second >= F) cout << p.first.first << " " << p.first.second << endl;
  }

  return 0;
}

Measured memory_bytes: 3508
package main

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

//•*¨*•.¸¸♪I/O•*¨*•.¸¸♪

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

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer(make([]byte, 10000), 100000000)

	n := scanInt()

	g := make([][]int, n)

	for i := 0; i < n-1; i++ {
		a,b := scanInt()-1, scanInt()-1
		g[a] = append(g[a],b)
		g[b] = append(g[b],a)
	}

	edge := make([]int64, n)
	done := make([]bool, n)
	q := make([]int, 0)
	q = append(q, 0)
	done[0] = true

	for len(q)!=0 {
		next := q[0]
		for _, e := range g[next] {
			if done[e] {
				continue
			}

			edge[e] = int64(1<<uint(e-1)) | edge[next]
			q = append(q, e)
			done[e] = true
		}
		q = q[1:]
	}

	m := scanInt()
	path := make([]int64, m)

	for i := 0; i < m; i++ {
		v,u := scanInt()-1, scanInt()-1
		path[i] = edge[u]^edge[v]
	}

	ans := int64(0)

	for i := 0; i < (1<<uint(m)); i++ {
		sign := 1
		p := int64(0)
		for j := 0; j < m; j++ {
			if i>>uint(j)&1 == 1 {
				p |= path[j]
				sign *= -1
			}
		}

		cnt := 0
		for j := 0; j < n-1; j++ {
			if p>>uint(j)&1==1 {
				cnt++
			}
		}

		ans += int64(sign)*int64(1<<uint(n-1-cnt))
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

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

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

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


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

int main(){
  string s;
  int n, sz;
  cin >> s;
  sz = s.size();
  
  for(int i=0; i<sz; i++){
    cout << "x";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
ll xorsum(ll bit)
{
    if (bit % 4 == 0) {
        return bit;
    } else if (bit % 4 == 1) {
        return 1;
    } else if (bit % 4 == 2) {
        return bit + 1;
    } else {
        return 0;
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    ll fa = xorsum(a - 1), fb = xorsum(b);
    ll res = fa ^ fb;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int expo(int x){
    int z=1;
    for(int i=0;i<x;i++){
        z*=10;
    }
    return z;
}

int main(void){
    int n;
    int k;
    scanf("%d%d", &n, &k);
    int d[k];
    for(int i=0;i<k;i++){
        scanf("%d", &d[i]);
    }
    int m=0;
    for(int i=0;i<6;i++){
        if((n/(expo(i)))!=0) m++;                         //nの桁数をmにする
    }
    int x=1, y[m];
    while(x!=0){
        if(n>=expo(m)) m++;
        for(int i=0;i<m;i++){
            for(int j=0;j<k;j++){
                if(((n%expo(i+1))/expo(i))==d[j]){
                    n++;
                    y[i]=1;
                    break;
                }
                else y[i]=0;
            }
        }
        int z=0;
        for(int l=0;l<m;l++){
            z+=y[l];
        }
        x = z;
    }
    printf("%d\n", n);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

signed main(){
	ll n;
	cin >> n;
	if(n % 2)cout << n/2 << endl;
	else cout << n/2 - 1 << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i, j, minj, n, p, count=0;
  int A[100];

  scanf("%d",&n);

  for(i=0 ; i<n ; i++) scanf("%d",&A[i]);

  for(i=0 ; i<n-1 ; i++){
    minj = i;
    for(j=i+1 ; j<n ; j++){
      if(A[j] < A[minj]) minj = j;
    }
    if(minj != i){
      p = A[i];
      A[i] = A[minj];
      A[minj] = p;
      count++;
    }
  }
  
  for(i=0 ; i<n-1 ; i++) printf("%d ",A[i]);
  printf("%d\n%d\n",A[i],count);
  
  return 0;
}

Measured memory_bytes: 600
#include <iostream>

int main(void){
  int N, x;
  std::cin >> N;
  if(N <= 111) x = 111;
  else if(111 < N && N <= 222) x = 222;
  else if(222 < N && N <= 333) x = 333;
  else if(333 < N && N <= 444) x = 444;
  else if(444 < N && N <= 555) x = 555;
  else if(555 < N && N <= 666) x = 666;
  else if(666 < N && N <= 777) x = 777;
  else if(777 < N && N <= 888) x = 888;
  else x = 999;
  std::cout << x << "\n";
  return 0;
}


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

ll L;
ll A[200010];
ll dp[200010][5];

ll rec(int pos, int stat){
    if(dp[pos][stat]>=0) return dp[pos][stat];
    ll res = 1LL << 60;
    if(pos == L){
        return 0;
    }
    else if(stat == 0 || stat == 4){
        if(stat == 0)
            res = min(res, rec(pos, stat + 1));
        res = min(res, rec(pos + 1, stat) + A[pos]);
    }
    else if(stat == 1 || stat == 3){
        res = min(res, rec(pos, stat + 1));
        ll cost = 0;
        if(A[pos] == 0) cost+=2;
        else if(A[pos] % 2 == 1) cost++;
        res = min(res, rec(pos + 1, stat) + cost);
    }
    else if(stat == 2){
        res = min(res, rec(pos, stat + 1));
        ll cost = 0;
        if(A[pos] % 2 == 0) cost++;
        res = min(res, rec(pos + 1, stat) + cost);
    }
    return dp[pos][stat] = res;
}

int main(){

    cin >> L;
    for(int i = 0; i < L; i++) cin >> A[i];
    memset(dp, -1, sizeof(dp));
    cout << rec(0, 0) << endl;
    
    return 0;
}


Measured memory_bytes: 18944
N,M=gets.split.map &:to_i
X=[p]*N
M.times{s,c=gets.split.map &:to_i;exit 0*p(-1)if c!=X[s-1]||=c}
puts N>1&&(1>X[0]||=1)? -1: X.map{|x|x||0}*''

Measured memory_bytes: 1788
#include <bits/stdc++.h>
   
using namespace std;
     
#define PB(x) push_back(x)
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x) make_pair(x);
    
#define debug(x) cerr << #x << '=' << x << endl;
#define debug2(x, y) cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(a) for (int x: a) cerr << x << ' '; cerr << endl;
     
#define int long long
     
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;

const int INF = 1e13;
const int mmod = 1000000007;

int32_t main()
{	
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	
	int ans = 0;
	for (int i = 1; i < n; i++) {
		if (s[i] == s[i-1]) ans++;
	}
	while (k > 0) {
		ans += 2;
		--k;
	}
	cout << min(n-1, ans) << endl;
	
}


Measured memory_bytes: 512
#ifndef _WIN32
#include<iostream>
#endif
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<string.h>
#include<map>
#include<utility>
using namespace std;

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
typedef vector<string> VS;
VS wrap(VS v,char c) {
	int R = v.size(), C = v[0].size();
	VS ret(R + 2, string(C + 2, c));
	REP(i, R)REP(j, C)ret[i + 1][j + 1] = v[i][j];
	return ret;
}
const int dr[] = { 0,0,1,-1 };
const int dc[] = { 1,-1,0,0 };
typedef long long LL;
typedef vector<LL> V;
typedef vector<V> VV;
const LL INF = 1e14;

int f(int x, int y, int a,int n, int z,int p,int q) {
	//cnt
	int res = 0;
	if (y*p == x*q)res++;
	
	if(n>0)
		for (int i = z; i*y <= a; i++) {
			res += f(i*x + y, i*y, a,n - 1, i, p, q);
		}
	return res;
}

int main() {
	int p, q, a, n;
	while (cin >> p >> q >> a >> n, p + q + a + n) {
		cout << f(0, 1, a, n,1, p, q) << endl;
	}
}

Measured memory_bytes: 3048
class Node
  # property parent : Int32
  # property s : Int32
  attr_accessor :parent, :s # Ruby
    
  def initialize(n)
    @parent = n
    @s = 0
  end
end

class UnionFindTree
  
  # property nodes : Array(Node) # Crystal
  attr_accessor :nodes        # Ruby

  def initialize(n)
    @nodes = (0..n).to_a.map{ |i| Node.new(i) }
  end

  def root(x)
    t = nodes[x].parent
    return x if x == t
    nodes[x].parent = root(t)
  end
  
  def unite(a, b)
    a = root(a)
    b = root(b)
    return false if a == b
    a, b = b, a if nodes[a].s < nodes[b].s
    nodes[b].parent = a
    nodes[a].s += 1 if nodes[a].s == nodes[b].s # by rank
    # nodes[a].s += nodes[b].s                    # by size
    true
  end
  
  def unite_by_size(a, b)
    a = root(a)
    b = root(b)
    return false if a == b
    a, b = b, a if nodes[a].s < nodes[b].s
    nodes[b].parent = a
    nodes[a].s += nodes[b].s
    true
  end
  
  def unite_by_rank(a, b)
    a = root(a)
    b = root(b)
    return false if a == b
    a, b = b, a if nodes[a].s < nodes[b].s
    nodes[b].parent = a
    nodes[a].s += 1 if nodes[a].s == nodes[b].s
  end

  def same?(a, b)
    root(a) == root(b)
  end

  def size(node)
    nodes[root(node)]
  end
end

n, m = gets.to_s.chomp.split.map{|i| i.to_i}
perm = gets.to_s.chomp.split.map{|i| i.to_i - 1 }
xys  = Array.new(m){ gets.to_s.chomp.split.map{|i| i.to_i - 1 } }

uf = UnionFindTree.new(n)
xys.each{|x,y| uf.unite(x,y) }
ans = (0...n).count{ |i| uf.same?(i, perm[i]) }

puts ans

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

int main()
{
    ll n, i, sum=0, j, k;

    scanf("%lld",&n);

    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            for(k=1; k<=n; k++)
            {
                sum+=__gcd(i,__gcd(j,k));
            }
        }
    }
    printf("%lld\n",sum);

}

Measured memory_bytes: 3824
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#define MOD 1000000007
#define INF 9000000009
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    int n;
    cin>>n;
    ll a[2*100000+1];
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    ll sunuke=0;
    ll arai=sum;
    ll ans=INF;
    for(int i=0;i<n-1;i++){
        sunuke+=a[i];
        arai-=a[i];
        ans=min(ans,abs(sunuke-arai));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
int main(void)
{
  int N, X, m, min, s;
  s = 0;
  min = 1001;
  cin >> N >> X;
  for(int i = 0; i < N; i++){
    s++;
  	cin >> m;
    X -= m;
    if( m < min){
    	min = m;
    }
  }
  while(X >= min){
  	s++;
    X -= min;
  }
  cout << s << endl;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9	
#define MOD 1000000007
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

void solve() {
	double d,t,s;
	cin >> d >> t >> s;
	double t1 = d/s;

	if(t >= t1) {
		cout<<"Yes";
		return;
	}
	cout<<"No";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();

	return 0;
}

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

using namespace std;

int n;
vector<int> cnt(4);
vector<vector<vector<double>>> dp;

int main(){
    cin>>n;
    dp.resize(n + 1, vector<vector<double>>(n + 1, vector<double>(n + 1)));
    for(int i = 0; i < n; i++){
        int tmp; cin>>tmp;
        cnt[tmp]++;
    }
    dp[0][0][0] = 0.0;
    for(int k = 0; k <= n; k++){
        for(int j = 0; j <= n; j++){
            for(int i = 0; i <= n; i++){
                double kk = i + j + k;
                if(kk == 0 || n < kk) continue;
                dp[i][j][k] = (n/kk) + (1/kk) * ((i ? i*dp[i-1][j][k] : 0) + (j ? j*dp[i+1][j-1][k] : 0) + (k ? k*dp[i][j+1][k-1] : 0));
            }
        }
    }
    auto res = dp[cnt[1]][cnt[2]][cnt[3]];
    cout<<setprecision(20)<<res<<endl;
    return 0;
}

Measured memory_bytes: 219984
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int dp[5005][5005];

int main(void) {
  int i,j;
  int n,k;
  cin>>n>>k;
  vi a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));

  int ok=-1;//不必要が確定している
  int ng=n;//必要が確定している
  int cnt=0;
  while(ok + 1 != ng){
    int mid=(ok+ng)/2;
    bool c=true;

    //    cout<<mid<<endl;

    rep(i,n+1)rep(j,k+1)dp[i][j]=0;
    dp[0][0]=1;

    rep(i,n)rep(j,k){
      dp[i+1][j]|=dp[i][j];
      if(i!=mid)dp[i+1][min(j+a[i],k)]|=dp[i][j];
    }
    /*
    rep(i,n+1)rep(j,k+1)if(dp[i][j]>0)
      cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
    */
    rep(j,k)if(dp[n][j]>0){
      //       cout<<j<<endl;
      if(j+a[mid] >= k){
        c=false;
        break;
      }
    }
    // cout<<mid<<" "<<c<<endl;

    if(c)ok=mid;
    else ng=mid;
  }

  cout<<ok+1<<endl;
}
/*
カードiを含むすべて集合の総和sum
sum >= k
sum-a[i] >= k
カードiは不必要

カードiを含まないある集合の総和sum
sum + a[i] >= k
sum < k
カードiは必要

a_1 < a_2 < … < a_n


a_iが不必要のときa_j (j<i)も不必要!!


a[i]を使わないとき和がk未満になるすべての集合のsum

dp[i][j]
a[i]までみたときに和がjとなるような集合の数

初期化
dp[0][0]=1
遷移
dp[i+1][j]=dp[i][j]
dp[i+1][min(j+a[i],k)]=dp[i][j]

O(NK * logN)


*/


Measured memory_bytes: 98048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

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

    vector<vector<bool>> g(N+5, vector<bool>(N+5, false));
    for(int i=2; i<=N; i++) g[1][i] = true;

    if((N-1)*(N-2)/2 < K){
        cout << -1 << endl;
        return 0;
    }

    bool flg = false;
    int cnt = (N-1)*(N-2)/2 - K;
    for(int i=2; i<=N; i++){
        for(int j=i+1; j<=N; j++){
            if(cnt == 0) {flg = true; break;}
            g[i][j] = true;
            cnt--;
        }
        if(flg) break;
    }

    vector<pair<int, int>> ans;
    for(int i=1; i<=N; i++) for(int j=i+1; j<=N; j++) if(g[i][j]) ans.push_back({i, j});

    cout << ans.size() << endl;
    for(auto e:ans) cout << e.first << " " << e.second << endl;
}

Measured memory_bytes: 384
//
// Created by yamunaku on 2020/06/13.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"YES"<<endl
#define CNO cout<<"NO"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    ll x, v, y, w, t;
    cin >> x >> v >> y >> w >> t;
    if(w > v){
        CNO;
    }else{
        if((v-w)*t >= abs(x-y)) CYES;
        else CNO;
    }
    return 0;
}

Measured memory_bytes: 3636
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, M, C = ni()
    val B = na(M)
    val A = nm(N, M)
    val ans = map(N) { i =>
      map(M) { j =>
        A(i)(j) * B(j)
      }.sum + C
    }.count(_ > 0)

    out.println(ans)
  }


  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  def debug(num: Long): Unit = {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}


Measured memory_bytes: 25420
S = gets.chomp
MOD = 2019

dp = Array.new(2019) { 0 }
dp[0] += 1
ans = 0
tens = 1
sum = 0
S.reverse.each_char do |s|
  n = s.to_i
  n *= tens
  sum += n
  sum %= MOD
  ans += dp[sum]
  dp[sum % MOD] += 1
  tens *= 10
  tens %= MOD
end

puts ans


Measured memory_bytes: 14820
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 k, n;
	std::cin >> n >> k;
	std::vector<std::pair<int32, int32>> p(n);
	rep(i, 0, n)
		std::cin >> p[i].first >> p[i].second;
	std::sort(ALL(p));
	uint64 ans = 0;
	--ans;
	rep(i, 0, n) {
		rep(j, 0, n) {
			int32 u = p[i].second, d = p[j].second;
			if (u < d) std::swap(u, d);
			uint32 l = 0, r = 0;
			int32 c = 0;
			if (d <= p[0].second&&p[0].second <= u) {
				++c;
			}
			while (l <= r) {
				if (c >= k) {
					if (d <= p[l].second&&p[l].second <= u) {
						--c;
					}
					++l;
				}
				else {
					++r;
					if (r >= n) break;
					if (d <= p[r].second&&p[r].second <= u) {
						++c;
					}
				}
				if (c >= k) {
					ans = std::min(ans, (uint64)(u - d)*(uint64)(p[r].first - p[l].first));
				}
			}
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int d,n;
int main()
{
    cin>>d>>n;
    if(n==100)
    {
        if(d==0)
         cout<<101<<endl;
        else if(d==1)
             cout<<10100<<endl;
        else if(d==2)
             cout<<1010000<<endl;

    }

    else
    {
    cout<<n;
    for(int i=0; i<d; i++)
    {
        cout<<"00";
    }
    cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        int st=i; 
        int x=a[i];
        for(;i<n;i++){
            if(a[i] > x) break;
            x=a[i];
        }
        i--;
        ans=max(ans,i-st);
    }
    cout<<ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6;
int n,L,T;
int pos[N];
int f[N][35];
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
	{
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
	{
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
int main() 
{
    n=read(); 
    for(int i=1;i<=n;i++) pos[i]=read();
    L=read(),T=read();
    for(int i=1;i<=n;i++)
        f[i][0]=upper_bound(pos+1,pos+n+1,pos[i]+L)-pos-1;
    for(int j=1;j<=30;j++)
    	for(int i=1;i<=n;i++) f[i][j]=f[f[i][j-1]][j-1];
    while(T--) 
	{
		int st=read(),en=read();
        if(st>en) swap(st,en);
        int ans=0;
        for(int i=30;i>=0;i--)
		 {
            if(f[st][i]<en)
			{
                ans+=1<<i;
                st=f[st][i];
            }
        }
        printf("%d\n",ans+1);
    }
    return 0;
}

Measured memory_bytes: 17152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793238462643383279;
int main(){
int N; cin >> N;
  vector<double> x(N); vector<double> y(N);
  for(int i = 0; i < N; i++){ cin >> x[i] >> y[i];}
double ans = 0.0;

for(int i = 0; i < 4000; i++){
  double s = cos(((double)i*pi)*0.0005); 
  double t = sin(((double)i*pi)*0.0005);
  double X = 0.0; double Y = 0.0;
  for(int i = 0; i < N; i++){
    if( s*x[i] + t*y[i] >= 0.0){ X += x[i]; Y += y[i];}}
  
  ans = max(ans, sqrt(X*X + Y*Y));}
  
  cout << fixed << setprecision(15) << ans << endl; return 0;}
    

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <ctime>
#include <complex>

#define enp 	printf("**Entry Point**\n")
#define A		first
#define B		second
#define MP		make_pair

using namespace std;

typedef long long ll;

const int INF = 0x6fffffff;
const int MINF = 0x80000000;
const ll mod = 100003;
const int cons = 100001;
const double pi = 3.141592653589793;

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

	int i1 = -1;

	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'C')
		{
			i1 = i;
			break;
		}
	}

	if (i1 == -1)
	{
		puts("No");
		return 0;
	}

	for (int i = i1 + 1; i < s.length(); i++)
	{
		if (s[i] == 'F')
		{
			puts("Yes");
			return 0;
		}
	}

	puts("No");

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    s=str(input())
    ls=len(s)
    cnt=1
    i=1
    temp=1
    while True:
        if i==ls:
            break
        if temp==2:
            cnt+=1
            temp=1
            i+=1
        else:
            if s[i-1]!=s[i]:
                i+=1
                cnt+=1
                temp=1
            else:
                if i==ls-1:
                    break
                else:
                    i+=2
                    cnt+=1
                    temp=2
    print(cnt)
resolve()

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {

    ll N, K;
    cin >> N >> K;
    vector<ll> h(N);
    REP(i, N){
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    // ll max = h[K-1];
    // ll min = h[0];
    ll diff = 1e18;
    REP(i, N-K+1){
        ll max_ = h[i+K-1];
        ll min_ = h[i];
        // cout << min_ << " " << max_ << endl;
        diff = min(diff, max_-min_);
    }

    cout << diff << endl;

}
/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> res(n);
  rep(i, n-1) {
    int a;
    cin >> a;
    --a;
    res[a]++;
  }
  rep(i, n) cout << res[i] << '\n';
  return 0;
}

Measured memory_bytes: 3984
def main(x):
    a = x[0]
    b = x[1]
    if a < b:
        print('a < b')
        return 
    elif a > b:
        print('a > b')
        return 
    else:
        print('a == b')
        return
    
    
if '__main__' == __name__:
    try:
        while True:
            main(list(map(int, input().strip().split(' '))))
    except EOFError:
        pass



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

int main() {
  int N;
  cin >> N;
  int a=0;
  int b=0;
  int c=0;
  int d=0;
  for(int i=0; i<N; i++){
    string S;
    cin>>S;
    if(S=="AC")
      a++;
    else if(S=="WA")
      b++;
    else if(S=="TLE")
      c++;
    else
      d++;
  }
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<b<<endl;
  cout<<"TLE x "<<c<<endl;
  cout<<"RE x "<<d<<endl;
}



Measured memory_bytes: 3628
using System;

namespace AizuOnline
{
    class Program
    {
        static void Main()
        {
            string[] ab = Console.ReadLine().Split();
            short a = Int16.Parse(ab[0]);
            short b = Int16.Parse(ab[1]);

            if (a > b)
               Console.WriteLine("a > b");
            else if (a < b)
                Console.WriteLine("a < b");
            else
                Console.WriteLine("a == b");
        }
    }
}


Measured memory_bytes: 8884