akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
using namespace std;

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

template<typename T>
T power(T x, long long k){
  T ret{1};
  while(k > 0){
    if(k&1) ret *= x;
    x *= x;
    k /= 2;
  }
  return ret;
}

int main(){
  using mint = modint<(int)1e9+7>;
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  map<int,int> M;
  for(auto a : A){
    for(int i = 2; i*i <= a; ++i){
      if(a%i) continue;
      int t = 0;
      while(a%i == 0){
        ++t;
        a /= i;
      }
      M[i] = max(M[i],t);
    }
    if(a > 1)
      M[a] = max(M[a],1);
  }
  mint lcm = 1;
  for(auto e : M){
    lcm *= power<mint>(e.first,e.second);
  }
  mint ans = 0;
  for(auto a : A)
    ans += lcm/a;
  cout << ans << endl;
}


Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int[] n = SpRead(' ').Select(_ => int.Parse(_)).ToArray();
        Console.WriteLine(((Math.Abs(n[2]-n[0] )<= n[3] || (Math.Abs(n[1] - n[0]) <= n[3] && Math.Abs(n[2] - n[1]) <= n[3]))?"Yes":"No"));
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }

}


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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> road_count(N);

    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        road_count.at(a - 1)++;
        road_count.at(b - 1)++;
    }

    for (int i = 0; i < N; i++)
    {
        cout << road_count.at(i) << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
	int A, B;
	cin >> A >> B;
	int AnsA = A + B;
	int AnsB = A - B;
	int AnsC = A * B;
	int largets = -200;
	if (largets < AnsA) {
		largets = AnsA;
	}
	if (largets < AnsB) {
		largets = AnsB;
	}
	if (largets < AnsC) {
		largets = AnsC;
	}
	cout << largets;
	cin >> largets;
}

Measured memory_bytes: 256
def resolve():
  s = input()
  l = (len(s) - 2) // 2
  while (l > 0):
    if s[0:l] == s[l:2*l]:
      print(2*l)
      return
    l -= 1

  print(2*l)

  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=1e9 + 7;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
#define all(x) x.begin(), x.end()

int__ main() {
	fast;

	int x,y,a,b,c; cin >> x >> y >> a >> b >> c;

	vi red(a), green(b);

	for(int i=0;i<a;i++) cin >> red[i];
	for(int i=0;i<b;i++) cin >> green[i];

	sort(all(red)); sort(all(green));
	reverse(all(red)); reverse(all(green));

	vi f;
	for(int i=0;i<min(x,a);i++) f.pb(red[i]);
	for(int i=0;i<min(y,b);i++) f.pb(green[i]);

	for(int i=0;i<c;i++) {
		int x; cin >> x; f.pb(x);
	}

	sort(all(f)); reverse(all(f));
	int ans=0;

	for(int i=0;i<x+y;i++) ans += f[i];
	cout << ans << endl;
}

Measured memory_bytes: 7792
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
using namespace std;
#define sd(n) scanf("%d", &n)
#define sdd(n, m) scanf("%d%d", &n, &m)
#define sddd(n, m, k) scanf("%d%d%d", &n, &m, &k)
#define pd(n) printf("%d\n", n)
#define pc(n) printf("%c", n)
#define pdd(n, m) printf("%d %d\n", n, m)
#define pddd(n, m, z) printf("%d %d %d\n", n, m, z)
#define pld(n) printf("%lld\n", n)
#define pldd(n, m) printf("%lld %lld\n", n, m)
#define plddd(n, m, z) printf("%lld %lld %lld\n", n, m, z)
#define sld(n) scanf("%lld", &n)
#define sldd(n, m) scanf("%lld%lld", &n, &m)
#define slddd(n, m, k) scanf("%lld%lld%lld", &n, &m, &k)
#define sf(n) scanf("%lf", &n)
#define sc(n) scanf("%c", &n)
#define sff(n, m) scanf("%lf%lf", &n, &m)
#define sfff(n, m, k) scanf("%lf%lf%lf", &n, &m, &k)
#define ss(str) scanf("%s", str)
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = a; i >= n; i--)
#define mem(a, n) memset(a, n, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ce i == n ? '\n' : ' '
#define mod(x) ((x) % MOD)
#define gcd(a, b) __gcd(a, b)
#define lowbit(x) (x & -x)
typedef pair<int, int> PII;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const int inf = 0x3f3f3f3f;
inline int read()
{
	int ret = 0, sgn = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9')
	{
		if (ch == '-')
			sgn = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		ret = ret * 10 + ch - '0';
		ch = getchar();
	}
	return ret * sgn;
}
inline void Out(int a) //ê?3?ía1ò
{
	if (a > 9)
		Out(a / 10);
	putchar(a % 10 + '0');
}

ll gcd(ll a, ll b)
{
	return b == 0 ? a : gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
///快速幂m^k%mod
ll qpow(ll x, ll n, ll mod)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = x * x % mod, n >>= 1;
	}
	return res;
}

const int N = 2e5 + 10;

int main()
{
	int a, b, c, d;
	sdd(a, b);
	sdd(c, d);
	bool flag = 1;
	while (a && c)
	{
		c -= b;
		if (c < 1)
			break;
		a -= d;
		if (a < 1)
		{
			flag = 0;
			break;
		}
	}
	if (flag)
		puts("Yes");
	else
		puts("No");
	return 0;
}


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

vector<vector<long>> t(200005);
vector<long> c(200005);

void dfs(int v,int p){
  for(int i=0;i<t[v].size();i++){
    if (t[v][i]==p) continue;
    else {
      c[t[v][i]]+=c[v];
      dfs(t[v][i],v);
    }
  }
}

int main() {
int N,Q;
cin>>N>>Q;
for(int i=0;i<N-1;i++){
  int a,b;
  cin>>a>>b;
  a--;
  b--;
  t[a].push_back(b);
  t[b].push_back(a);
}
for(int i=0;i<Q;i++){
  int p,x;
  cin>>p>>x;
  p--;
  c[p]+=x;
}
dfs(0,-1);
for(int i=0;i<N;i++){
  cout<<c[i]<<" ";
}
cout<<endl;

}


Measured memory_bytes: 24320
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define NIL -1
#define MAX 100000

ll conv(string num) { stringstream ss; ss << num << flush; ll n; ss>>n; return n; }

string conv(ll n) { stringstream ss; ss << n << flush; return ss.str(); }

vector<string> split(string s, string delim) {
    vector<string> res;
    int pos = 0;
    while(true) {
        int found = s.find(delim, pos);
        if(found >= 0) {
            res.push_back(s.substr(pos, found - pos));
        }
        else {
            res.push_back(s.substr(pos));
            break;
        }
        pos = found + delim.size();
    }
    return res;
}
int ALPH_SIZE = 26;
char ALPH_L[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char ALPH_U[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

int m, n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
    stack<int> s;
    s.push(r);
    color[r] = c; // set color to the init point 

    while(!s.empty()) {
        int u = s.top();
        s.pop();

        for(int i=0; i<G[u].size(); i++) {
            int v = G[u][i];

            if (color[v] == NIL) {
                color[v] = c;  // set same color to connected points
                s.push(v);
            }

        }
    }
}


void assignColor() {
    int id = 1;

    for(int i=0; i<MAX; i++) {
        color[i] = NIL;
    }

    for(int i=0; i<MAX; i++) {
        if (color[i] == NIL) {
            dfs(i, id++);
        }
    }
}



int main() {
    int v, w, m, n, s, t;
    cin >> n >> m;
    for(int i=0; i<m; i++) {
        cin >> v >> w;
        G[v].push_back(w);
        G[w].push_back(v);
    }

    assignColor();

    int q; 

    cin >> q;
    for(int i=0; i<q; i++) {
        cin >> s >> t;

        if (color[s] == color[t]) cout << "yes" << endl;
        else cout << "no" << endl;
    }


    return 0;
}



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

using namespace std;

int main(void) {
	int temp,N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> temp;
		A[temp-1] = i+1;
	}
	for (int i = 0; i < N; ++i) {
		cout << A[i] << " ";
	}
	cout << endl;
	
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> dp(3, 0);
    for (int day = 0; day < n; day++)
    {
        vector<int> m(3, 0);
        int c[3];
        for (int i = 0; i < 3; i++)
        {
            cin >> c[i];
        }
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if(i != j)
                {
                    m[j] = max(m[j], dp[i] + c[j]);
                }
            }
        }
        dp = m;
    }
    cout << max({dp[0], dp[1], dp[2]});
    return 0;
}


Measured memory_bytes: 384
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    a = input()
    if 'a' <= a <= 'z':
        print('a')
    else:
        print('A')
resolve()

Measured memory_bytes: 61668
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

pair<int, int> to[200000];
int he[100001], jisuu[100001], A[100001], saidai[100001];
ll goukei[100001];

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


	int N = getint();
	rep1(i, N) A[i] = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();
		jisuu[a]++;
		jisuu[b]++;
		to[k] = mp(b, he[a]);
		he[a] = k++;
		to[k] = mp(a, he[b]);
		he[b] = k++;
	}

	if (N == 2) {
		if (A[1] == A[2]) printf("YES");
		else printf("NO");
		return 0;
	}

	int q[100000], x = 0;
	rep1(i, N) if (jisuu[i] == 1) jisuu[i] = 0;
	int n = N;
	rep1(i, N) if (jisuu[i] == 0) {
		int p = to[he[i]].first;
		goukei[p] += A[i];
		if (saidai[p] < A[i]) saidai[p] = A[i];
		jisuu[p]--;
		if (jisuu[p] == 1) q[x++] = p;
		n--;
	}

	bool OK = 1;
	for (int y = 0; y < n - 1; y++) {
		int i = q[y];
		for (int j = he[i]; j; j = to[j].second) {
			int p = to[j].first;
			if (jisuu[p]) {
				jisuu[p]--;
				if (jisuu[p] == 1) q[x++] = p;

				ll tmp = A[i] * 2 - goukei[i];
				if (saidai[i] < tmp) saidai[i] = tmp;
				goukei[p] += tmp;
				if (saidai[p] < tmp) saidai[p] = tmp;
				if (tmp < 0 || saidai[i] > A[i]) OK = 0;
			}
		}
		jisuu[i] = 0;
	}

	int i = q[n - 1];
	if (saidai[i] > A[i] || goukei[i] != A[i] * 2) OK = 0;

	if (OK) printf("YES");
	else printf("NO");

	Would you please return 0;
}

Measured memory_bytes: 4608
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
#define ul unsigned long long

#define rup(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rdn(i, a, b) for(int (i) = (a); (i) > (b); (i)--)

int main() {
	long n;
	cin >> n;
	vector<ul> a = vector<ul>(n, 0);
	rup(i, 0, n) cin >> a[i];
	sort(a.begin(), a.end());
	
	ul tyohen = 0, tanpen = 0;
	ul tyohenIndex = 0;
	for (ul i = a.size() - 2;; i--) {
		if (a[i] == a[i + 1]) {
			tyohen = a[i];
			tyohenIndex = i;
			break;
		}

		if (i == 0) break;
	}
	if (tyohenIndex >= 2) {
		for (ul i = tyohenIndex - 2;; i--) {
			if (a[i] == a[i + 1]) {
				tanpen = a[i];
				break;
			}
			if (i == 0) break;
		}
	}
	
	cout << tyohen*tanpen<<endl;

	return 0;
}





Measured memory_bytes: 1024
require 'set'

class Heap
	require 'forwardable'
	extend Forwardable

	def initialize
		@array = []
		@index = {}
	end

	def add(obj, key)
		@array << [obj, key]
		@index[obj] = @array.size - 1
		lift_up(@array.size - 1)
	end

	def swap(i, j)
		u = @array[i]
		v = @array[j]
		@index[u[0]], @index[v[0]] = j, i
		@array[i], @array[j] = v, u
	end

	def lift_up(i)
		return if i == 0
		j = (i - 1) / 2
		if (@array[i][1] <=> @array[j][1]) < 0
			swap(i, j)
			lift_up(j)
		end
	end

	def del_min
		raise "heap is empty!" if empty?
		min = @array[0]
		if size > 1
			swap(0, @array.size-1)
			@array.pop
			lift_down(0)
		else
			@array.pop
		end
		@index.delete(min[0])
		min
	end

	def inc_key(obj, diff)
		i = @index[obj]
		@array[i][1] += diff
		lift_down(i)
	end

	def dec_key(obj, diff)
		i = @index[obj]
		@array[i][1] -= diff
		lift_up(i)
	end

	def update_key(obj, new_key)
		i = @index[obj]
		return unless i
		return if (new_key <=> @array[i][1]) >= 0
		@array[i][1] = new_key
		lift_up(i)
	end

	def min_obj
		@array[0][0]
	end

	def min_key
		@array[0][1]
	end

	def lift_down(i)
		j = 2 * i + 1
		k = j + 1
		if k >= size
			return if j >= size
			if (@array[i][1] <=> @array[j][1]) > 0
				swap(i, j)
				lift_down(j)
			end
		else
			l = ((@array[j][1] <=> @array[k][1]) < 0 ? j : k)
			if (@array[i][1] <=> @array[l][1]) > 0
				swap(i, l)
				lift_down(l)
			end
		end
	end

	def_delegators :@array, :empty?, :size
end

module Graphical
	require 'set'

	def dijkstra(start)
		raise "start must be Enumerable" if !start.kind_of?(Enumerable)
		h = Heap.new
		reached = Set[*start.to_a]
		start.each{|s| h.add(s, 0)}

		dist = {}
		until h.empty?
			u, key = h.del_min
			return key if block_given? && yield(u, key)
			dist[u] = key
			each_out_connection_of(u){|v, l|
				d = dist[u] + l
				if reached.include?(v)
					h.update_key(v, d)
				else
					h.add(v, d)
					reached << v
				end
			}
		end
		block_given? ? nil : dist
	end
end

include Math
class Line
	def self.through_two_points(x1, y1, x2, y2)
		a = y1 - y2
		b = x2 - x1
		c = a * x1 + b * y1
		new(a, b, c, x1, y1, x2, y2)
	end

	def cross?(l)
		return false if parallel?(l)
		(@a * l.x1 + @b * l.y1 - @c) * (@a * l.x2 + @b * l.y2 - @c) <= 0 &&
		(l.a * @x1 + l.b * @y1 - l.c) * (l.a * @x2 + l.b * @y2 - l.c) <= 0
	end

	def parallel?(l)
		@a * l.b == @b * l.a
	end

	def length
		hypot(@x1 - @x2, @y1 - @y2)
	end

	private_class_method :new

	def initialize(*args)
		@a, @b, @c, @x1, @y1, @x2, @y2 = args	
	end

	attr_reader :a, :b, :c, :x1, :y1, :x2, :y2
end

m, n = gets.split.map(&:to_i)
us = (1..m).map { gets.split.map(&:to_i) }
vs = (1..n).map { gets.split.map(&:to_i) }

class Array
	include Graphical
	def each_out_connection_of(u)
		each do |v|
			next if v == u
			l2 = Line.through_two_points(*u, *v)
			next if $l1.cross?(l2)
			yield [v, l2.length]
		end
	end
end

$l1 = Line.through_two_points(*us[0], *us[1])
d1 = $l1.length + (vs.dijkstra([vs[0]])[vs[1]] || Float::INFINITY)
$l1 = Line.through_two_points(*vs[0], *vs[1])
d2 = $l1.length + (us.dijkstra([us[0]])[us[1]] || Float::INFINITY)
d = [d1, d2].min
p d == Float::INFINITY ? -1 : d

Measured memory_bytes: 10132
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        distance_sum: [i64; n],
    }
    let mut d = distance_sum.iter().cloned().enumerate().collect::<Vec<_>>();
    d.sort_by_key(|d| d.1);
    let mut size = vec![1i64; n];
    let mut edge = vec![];
    for i in (1..n).rev() {
        let (a, x) = d[i];
        let y = x - n as i64 + 2 * size[a];
        if let Ok(k) = d.binary_search_by(|d| d.1.cmp(&y)) {
            let b = d[k].0;
            size[b] += size[a];
            edge.push((a, b));
        } else {
            println!("-1");
            return;
        }
        size[a] = 0;
    }
    if !size.iter().any(|s| *s == n as i64) {
        println!("-1");
        return;
    }
    let mut g = vec![vec![]; n];
    for &(a, b) in edge.iter() {
        g[a].push(b);
        g[b].push(a);
    }
    let mut q = vec![];
    let mut dfs = vec![(0, 0)];
    while let Some((v, p)) = dfs.pop() {
        q.push(v);
        if let Some(k) = g[v].iter().position(|u| *u == p) {
            g[v].remove(k);
        }
        for &u in g[v].iter() {
            dfs.push((u, v));
        }
    }
    let mut dp1 = vec![0; n];
    let mut size = vec![1i64; n];
    for &v in q.iter().rev() {
        for &u in g[v].iter() {
            dp1[v] += dp1[u] + size[u];
            size[v] += size[u];
        }
    }
    let mut dp2 = dp1.clone();
    for &v in q.iter() {
        for &u in g[v].iter() {
            dp2[u] = dp2[v] + n as i64 - size[u] * 2;
        }
    }
    if dp2.iter().zip(distance_sum.iter()).all(|p| *p.0 == *p.1) {
        let mut out = String::new();
        for (a, b) in edge {
            out.push_str(&format!("{} {}\n", a + 1, b + 1));
        }
        print!("{}", out);
    } else {
        println!("-1");
    }
}

fn main() {
    run();
}


Measured memory_bytes: 24876
import java.util.Scanner;

public class Main{ 
        public static void main(String[] args){
            int i=0,j,k,count=0;
            int a[];
            int b[];
            a = new int[100000];
            b = new int[100000];
                Scanner n = new Scanner(System.in);
                while(true){
                     a[i] = n.nextInt();
                     b[i] = n.nextInt();
                     if(a[i]==0 && b[i]==0){
                         break;
                     }
                     count++;
                     i++;
                }
                i=0;
                while(count>i){
                     for(k=0;k<a[i];k++){
                         for(j=0;j<b[i];j++){
                             System.out.print("#");
                         }
                         System.out.printf("\n");
                     }
                     i++;
                     System.out.printf("\n");
                }
        }
    }


Measured memory_bytes: 39084
#include"bits/stdc++.h"
using namespace std;

int main(){
	int N;
	cin >> N;
	vector<pair<int, int>> juel(N);
	int ans = 0;
	for (int i = 0;i < N;++i) {
		cin >> juel[i].first;
	}
	for (int i = 0;i < N;++i) {
		cin >> juel[i].second;
		if (juel[i].first - juel[i].second > 0)ans += juel[i].first - juel[i].second;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1e9
#define N 100100
using namespace std;
int a[N];
int main()
{
	int n,ans=0,cnt;
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	int last=n;
	int mx=a[n];
	for (int i=n-1;i>=1;i--) 
	{
		if (a[i]<mx) 
		{
			mx=a[i];
			last=i;
		}
		else
		{
			mx=max(mx,a[i]);
			ans=max(ans,last-i);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
import sys
import bisect
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
ls = [i * 400 - 1 for i in range(1, 9)]
_set = set()
n_max = 0
for a in a_ls:
    ind = bisect.bisect_left(ls ,a)
    if ind == 8:
        n_max += 1
    else:
        _set.add(ind)
_min = max(len(_set), 1)
print(_min, len(_set) + n_max)

Measured memory_bytes: 3444
local S={}
S["a"]=io.read()
S["b"]=io.read()
S["c"]=io.read()

local discard="a"
while true do
    if #S[discard]==0 then
        print(discard:upper())
        break
    end
    discard,S[discard]=S[discard]:sub(1,1),S[discard]:sub(2)
end

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using Graph = vector<vector<int>>;
using ll = long long;
using p = pair<int, int>;

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = t.size();

    rep(i, s.size() - t.size() + 1)
    {
        int temp_ans = 0;
        rep(j, t.size())
        {
            if (s[i + j] != t[j])
            {
                temp_ans++;
            }
        }

        if (temp_ans < ans)
        {
            ans = temp_ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
try:
  x,n = list(map(int, input().split()))
  ps  = list(map(int, input().split()))
  #print(x)
  #print(n)
  #print(ps)
  
  if not (x in ps):
    print(x)
    exit(0)
  
  for item in range(1,101):
    if not x-item in ps:
      print(x-item)
      exit(0)
    elif not x+item in ps:
      print(x+item)
      exit(0)
except EOFError:
  print(x)

Measured memory_bytes: 9016
#include<stdio.h>
#include<algorithm>

using namespace std;

int main() {
	int m[10];

	for (int i = 0; i < 10; i++)scanf("%d", &m[i]);

	stable_sort(m, m + 10);
	
	for(int i=9;i>6;i--)printf("%d\n", m[i]);

	return 0;
}


Measured memory_bytes: 2748
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n, x;
int solve(int a,int b){
	int sum = 2 * floor(b*1.0 / a)*a;
	if (b%a == 0) return sum - a;
	return sum + solve(b%a, a);
}
signed main() {
	cin >> n >> x;
	cout << n + solve(x, n - x) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>
#include <set>

using namespace std;

class union_find
{
public:
    vector<int> parent;
    vector<int> size;
    vector<int> rank;

public:
    union_find(int vertex_count)
        : parent(), size(), rank()
    {
        parent.assign(vertex_count, 0);
        size.assign(vertex_count, 1);
        rank.assign(vertex_count, 1);

        for (int i = 0; i < vertex_count; i++)
        {
            parent[i] = i;
        }
    }

public:
    int find(int u)
    {
        if (parent[u] == u) return u;
        return parent[u] = find(parent[u]);
    }

    void merge(int u, int v)
    {
        u = find(u);
        v = find(v);

        if (u == v) return;
        if (rank[u] > rank[v]) swap(u, v);

        parent[u] = v;
        size[v] += size[u];
        if (rank[u] == rank[v]) rank[v]++;
    }

    int get_size(int u)
    {
        u = find(u);
        return size[u];
    }
};

//union_find uf(N);
//uf.merge(u, v);
//int u_parent = uf.find(u);

set<int> friendship[100000];
set<int> blockship[100000];

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

	int N, M, K;
	cin >> N >> M >> K;

    union_find uf(N);

    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;

        a--;
        b--;

        friendship[a].insert(b);
        friendship[b].insert(a);

        uf.merge(a, b);
    }

    for (int i = 0; i < K; i++)
    {
        int a, b;
        cin >> a >> b;

        a--;
        b--;

        int pa = uf.find(a);
        int pb = uf.find(b);

        if (pa == pb)
        {
            blockship[a].insert(b);
            blockship[b].insert(a);
        }
    }

    for (int i = 0; i < N; i++)
    {
        int total = uf.get_size(i) - 1;
        total -= friendship[i].size();
        total -= blockship[i].size();

        cout << total << " ";
    }

	return 0;
}

Measured memory_bytes: 30208
def solve():
    N = int(input())
    X = list(map(int, input().split()))

    sortedIdx = sorted(list(range(N)), key=lambda k: X[k])

    midrIdx = N // 2
    midrVal = X[sortedIdx[midrIdx]]
    midlIdx = N // 2 - 1
    midlVal = X[sortedIdx[midlIdx]]

    ans = [-1] * N
    for i in range(N):
        if i <= midlIdx:
            ans[sortedIdx[i]] = midrVal
        else:
            ans[sortedIdx[i]] = midlVal
    
    print(*ans, sep="\n")
if __name__ == '__main__':
    solve()

Measured memory_bytes: 112824
pts = []

while (line = gets)
  pts.push line.chomp.split(",").map{|s| s.to_f}
end

s = 0.0

pt0 = pts.shift
pt1 = pts.shift

e01 = Math.sqrt((pt1[0] - pt0[0]) ** 2 + (pt1[1] - pt0[1]) ** 2)

while pts.length > 0
  pt2 = pts.shift

  e02 = Math.sqrt((pt2[0] - pt0[0]) ** 2 + (pt2[1] - pt0[1]) ** 2)
  e12 = Math.sqrt((pt2[0] - pt1[0]) ** 2 + (pt2[1] - pt1[1]) ** 2)

  z = (e01 + e02 + e12) / 2
  s += Math.sqrt(z * (z - e01) * (z - e02) * (z - e12))

  pt1 = pt2
  e01 = e02
end

printf("%.6f\n", s)

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

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

std::vector<ll> divisor(ll n){
  std::vector<ll> div;
  for(ll p=1;p*p<=n;++p){
    if(n%p==0){
     div.push_back(p);
     if(p*p!=n)div.push_back(n/p);
    }
  }
  std::sort(div.begin(),div.end());
  return div;
}

main(){

  ll n;
  cin>>n;
  
  ll ans=INF;
  for(ll p=1;p*p<=n;++p){
    if(n%p!=0)continue;
    chmin(ans,p+n/p);
  }
  cout<<(ans-2)<<endl;

}

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

using namespace std;

const int MAXN = 1e6 + 7;

#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> a(n);
    for (int i = 0; i < n; ++i)
    {
        int k;
        cin >> k;
        a[i].resize(k);
        for (int j = 0; j < k; ++j)
        {
            cin >> a[i][j].first >> a[i][j].second;
            --a[i][j].first;
        }
    }
    int ans = 0;
    for (int m = 0; m < (1 << n); ++m)
    {
        int cur = 0;
        int fl = true;
        for (int i = 0; i < n; ++i)
        {
            if (m & (1 << i))
            {
                ++cur;
                for (auto el : a[i])
                {
                    if ((bool)(m & (1 << el.first)) != el.second)
                    {
                        fl = false;
                        break;
                    }
                }
            }
        }
        if (fl)
        {
            ans = max(ans, cur);
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

  set<char> s;
  for (int i = 0; i < N; i++) {
    char d;
    cin >> d;
    s.insert(d);
  }

  if (s.size() == 3) cout << "Three" << endl;
  else cout << "Four" << endl;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var [w,h,c] = input.trim().split(" ");
w=w-0;
h=h-0;
var ans=[];
ans.push("+" + "-".repeat(w-2) + "+");
for(var i=0;i<h - 2;i++)ans.push("|" + ".".repeat(w-2) + "|");
ans.push("+" + "-".repeat(w-2) + "+");
ans[Math.floor(h/2)]="|" + ".".repeat((w-3)/2)  + c + ".".repeat((w-3)/2)+ "|"
console.log(ans.join("\n").trim());


Measured memory_bytes: 15360
// たなこふ先生の input マクロ (´･_･`)
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        xs: [i32; m],
    }

    let xs = {
        let mut xs = xs;
        xs.sort();
        xs
    };

    let dists = {
        let mut dists = Vec::with_capacity(m-1);
        for i in 1..m {
            dists.push(xs[i]-xs[i-1]);
        }
        dists.sort();
        dists.truncate(if m >= n {m - n} else {0});
        dists
    };

    println!("{}", dists.iter().sum::<i32>());
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define fr first
#define sc second
#define eps 1e-9
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define sni(x) scanf("%d",&x)
#define snl(x) scanf("%lld", &x)
#define snc(x) scanf("%c", &c);
#define rep(n) for(int i = 0 ; i < n ;i ++)
#define repc(i, n) for(int i = 0 ; i < n ; i ++)
#define FOR(i, x, y) for(int i = x ; i < y ; i ++)
#define DEC(i, x, y) for(int i = x ; i >= y ; i --)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b,c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a+n
using namespace std;
#define ll long long
double pi=3.141592653589793238462643383279;

ll a[100005];
ll n,k;
ll check(ll d)
{
    ll res=0;
    for(ll i=0;i<n-1;i++)
    res+=(a[i+1]-a[i]-1)/d;
    if(res<=k)
    return 1;
    else
    return 0;
}
int main() {
   ll n;
   cin>>n;
  map<ll,ll>f;
   FOR(i,0,n-1)
   {
       ll y;
       cin>>y;
       f[y-1]++;
   }
   FOR(i,0,n)
   cout<<f[i]<<endl;
}


Measured memory_bytes: 16128
#if defined(LOCAL)
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#endif
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<int, int>;
using lu = unsigned long long;
using l = long long;
using vs = vector<string>;
using vii = vector<ii>;
using vl = vector<l>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using ll = pair<l, l>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using mll = unordered_map<l, l>;
using sl = unordered_set<l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10;
const double PI = 3.14159265358979323846;
const l e0 = 1, e3 = 1000, e5 = 100000, e6 = 10 * e5, e7 = 10 * e6,
        e8 = 10 * e7, e9 = 10 * e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a, b, c) for (l a = l(b); a < l(c); a++)
#define B(a, b, c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

void solve(istream &in, ostream &out);
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  tst::test_init(argc, argv);
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  tst::maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}
const l MOD = e9 + 7; // end of template

void solve(istream &in, ostream &out) {
  l n; in >> n;
  vl v(n); F(i, 0, n) in >> v[i];
  l sum = accumulate(all(v), l(0));
  l z = 0;
  l best = INF;
  F(i, 0, n) {
    l d = abs(v[i] * n - sum);
    if (d < best) {
      best = d;
      z = i;
    }
  }
  out << z << lf;
}


Measured memory_bytes: 256
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const long long MOD = 1000000007;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;

auto mpow = [](auto x, i64 y){
 auto z = x;
 decltype(x) val = y & 1 ? x : decltype(x)(1);
 while(z *= z, y >>= 1)
  if(y & 1)
   val *= z;
 return val;
};



void solve(long long n, long long k){

    mint ans = 0;
    i64 mi = 0;
    i64 ma = 0;
    int cnt = 0;
    for(int i = 0; i < n + 1; ++i, ++cnt){
        mi += cnt;
        ma += (n - cnt);
        if(i >= k - 1){
            ans += (ma - mi + 1);
        }
    }
    cout << ans << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 3764
from collections import Counter

N = int(input())
S = input()

left, right = S[:N], S[N:][::-1]
a, b = Counter(), Counter()

for i in range(2 ** N):
    t = "".join(left[j] if (i >> j) & 1 else "" for j in range(N))
    u = "".join(right[j] if (i >> j) & 1 else "" for j in range(N))
    v = "".join("" if (i >> j) & 1 else left[j] for j in range(N))
    w = "".join("" if (i >> j) & 1 else right[j] for j in range(N))
    a[t, v] += 1
    b[u, w] += 1

print((sum(a[t] * b[t] for t in a.keys())))

Measured memory_bytes: 168180
#include<stdio.h>

int main()
  {
     int n,d;
     scanf("%d %d",&n,&d);
     int x=n/(2*d+1);
  if(x*(2*d+1)==n)
    x=x;
  else
    x=x+1;
  printf("%d\n",x);
  return 0;
  }
      

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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


ll n, m, k, t, sum[200000], s, ans;
vector<ll> A, B;

int main() {
	fastio;
	cin >> n >> m >> k;
	FOR(i, n) {
		cin >> t;
		A.pb(t);
	}
	FOR(i, m) {
		cin >> t;
		B.pb(t);
	}
	sum[0] = B[0];
	for (int i = 1; i < m; i++) {
		sum[i] = B[i] + sum[i - 1];
	}
	for (ll i = -1; i < n; i++) {
		if(i != -1) s += A[i];
		t = k - s;
		if (t < 0) break;
		ll idx = upper_bound(sum, sum + m, t) - sum;
		ans = max(ans, i + 1 + idx);
	}
	cout << ans;
}

Measured memory_bytes: 7944
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N>>M>>K;
    vec a(N);
    rep(i,N) cin>>a[i];
    ll ans = K;
    rep(i,N){
        ans += (M + a[i] - 1)/a[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[m];
		long[] a_sum = new long[n+1];
		long[] b_sum = new long[m+1];
		a_sum[0] = a[0];
		b_sum[0] = b[0];
		for(int i = 1; i < n+1; i++) {
			a[i-1] = sc.nextInt();
			a_sum[i] = a[i-1] + a_sum[i-1];
		}
		for(int i = 1; i < m+1; i++) {
			b[i-1] = sc.nextInt();
			b_sum[i] = b[i-1] + b_sum[i-1];
			//System.out.println(b_sum[i]);
		}
		
		int j = m;
		int ans = 0;
		for(int i = 0; i < n+1 ; i++) {
			if(a_sum[i] > k) {
				break;
			}
			while(b_sum[j] > k - a_sum[i]) {
				j--;
			}
			//System.out.println(i +" "+j);
			ans = Math.max(ans, i+j);
		}
		System.out.println(ans);
	}
}

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

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    while(cin>>n && n){
        typedef pair<double,string> data;
        vector<data> v(n);
        rep(i,n){
            string l;
            int p,a,b,c,d,e,f,s,m;
            cin>>l>>p>>a>>b>>c>>d>>e>>f>>s>>m;
            double lifetime = a+b+c+(d+e)*m;
            double benefit = f*m*s-p;
            // cout << lifetime << " " << benefit << endl;
            v[i] = make_pair(benefit/lifetime,l);
        }
        sort(v.begin(), v.end(), [](const data& a, const data& b){
                if(abs(a.first-b.first)>1e-8) return a.first > b.first;
                return a.second < b.second;
            });
        rep(i,n){
            cout << v[i].second << endl;
        }
        cout << "#" << endl;
    }
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int gcd_(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}


int main() {
  int n, x, a;
  cin >> n >> x;
  int y[n];
  for (size_t i = 0; i < n; i++) {
    cin >> a;
    y[i] = a - x;
  }
  a = y[0];
  for (size_t i = 1; i < n; i++) {
    a = gcd_(a,y[i]);
  }
  if (a < 0) a = -a;
  cout << a << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    vector<int> a(N);
    vector<ll> S(N + 1);
    S[0] = 0;
    for(int i = 0; i < N; ++i){
        cin >> a[i];
        S[i + 1] = S[i] + a[i];
    }

    constexpr ll inf = 1e+15;
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, -1));
    auto MemoRec = [&](auto&& self, int l, int r) -> ll {
        if(dp[l][r] != -1)  return dp[l][r];
        if(r - l <= 1)  return dp[l][r] = 0;

        ll res = inf;
        for(int m = l + 1; m < r; ++m){
            chmin(res, self(self, l, m) + self(self, m, r));
        }
        res += S[r] - S[l];

        return dp[l][r] = res;
    };

    cout << MemoRec(MemoRec, 0, N) << endl;
}

Measured memory_bytes: 4528
#include<stdio.h>

int main()
{
  int n,i;
  int a[101];
  int ans=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    if(i%2==0 && a[i]%2==1){
      ans++;
    }
  }
  printf("%d",ans);
  return 0;
}


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

using namespace std;

int main(){
  char X, Y;
  cin >> X >> Y;
  
  if((int)X < (int)Y){
    cout << "<" << endl;
  }else if((int)Y < (int)X){
    cout << ">" << endl;
  }else{
    cout << "=" << endl;
  }
}


Measured memory_bytes: 3624