akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long double db;

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

template<typename T> void print(const T& a, ostream& out){	
	for(auto i: a) out << i << ' ';
	out << endl;
}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	LL a, b, c, d;
	cin >> a >> b >> c >> d;
	LL ans = -LINF;
	if (a <= 0 && b >= 0) ans = 0;
	if (c <= 0 && d >= 0) ans = 0;
	setmax(ans, a * c);
	setmax(ans, a * d);
	setmax(ans, b * c);
	setmax(ans, b * d);
	cout << ans << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;	
	return 0;
}


Measured memory_bytes: 3820
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	A := strings.Split(scanner.Text(), " ")
	var N, M int
	N, _ = strconv.Atoi(A[0])
	M, _ = strconv.Atoi(A[1])


	pos := make([]bool, N + 1)
	pos[1] = true

	count := make([]int, N + 1)
	fill(count, 1)

	for i := 0; i < M; i++ {
		scanner.Scan()
		A = strings.Split(scanner.Text(), " ")

		var x, y int
		x, _ = strconv.Atoi(A[0])
		y, _ = strconv.Atoi(A[1])

		if pos[x] {
			pos[y] = true
			if count[x] == 1 {
				pos[x] = false
			}
		}

		count[x]--
		count[y]++

	}

	ans := 0
	for i := 1; i <= N; i++ {
		if pos[i] {
			ans++
		}
	}
	fmt.Println(ans)
}

func fill(arr []int, v int) {
	for i := 0; i < len(arr); i++ {
		arr[i] = v
	}
}


Measured memory_bytes: 5376
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    	String x = sc.next();
     	
      if(x.charAt(0) == x.charAt(1) && x.charAt(1) == x.charAt(2)){
	    System.out.println("No");
      }else{
	    System.out.println("Yes");
      }
      }
}


Measured memory_bytes: 22740
"""
                            pppppppppppppppppppp
                         ppppp  ppppppppppppppppppp
                      ppppppp    ppppppppppppppppppppp
                      pppppppp  pppppppppppppppppppppp
                      pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
       ppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppp
      pppppppppppppppppppppppppppppppppppppppppppppppp  ppppppppppppppppppppp
     ppppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppppp
    ppppppppppppppppppppppppppppppppppppppppppppppp    pppppppppppppppppppppppp
   pppppppppppppppppppppppppppppppppppppppppppppp     pppppppppppppppppppppppppp
  ppppppppppppppppppppppppppppppppppppppppppppp      pppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppppppp               pppppppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppp     pppppppppppppppppppppppppppppppppppppppppppppp
  ppppppppppppppppppppppppppp    pppppppppppppppppppppppppppppppppppppppppppppppp
    pppppppppppppppppppppppp  pppppppppppppppppppppppppppppppppppppppppppppppppp
     ppppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppppp
      pppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppp
       ppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
                              pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppp  pppppppp
                              ppppppppppppppppppppp    ppppppp
                                 ppppppppppppppppppp  ppppp
                                    pppppppppppppppppppp
"""


import sys
from functools import lru_cache, cmp_to_key
from collections import defaultdict as dd, deque, Counter as C
from bisect import bisect_left as bl, bisect_right as br, bisect
from heapq import heapify, heappop, heappush
from math import ceil, log, floor, sqrt
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var, end="\n"): sys.stdout.write(str(var)+end)
def outa(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


cnt = 0
maxi = 0
for _ in range(int(data())):
    a, b = sp()
    if a == b:
        cnt += 1
        continue
    maxi = max(maxi, cnt)
    cnt = 0
maxi = max(cnt, maxi)
out(("Yes", "No")[maxi < 3])


Measured memory_bytes: 68200
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
const int mod = 1e9 +7;
int n;
int main() {
    cin >> n;
    vector<int> nums(n);
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
    }
    bool prev = false;
    int ans = 0;
    for (int i = 1; i < n; i++) {
        if (nums[i] == nums[i-1]) {
            ans++;
            nums[i] = 0;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double n,k1,k2;
int m;
int main()
{
	cin>>n;
	m=n;
	if(m%3==0) printf("%.7lf",(double)(m/3)*(m/3)*(m/3));
	else
	{
		k1=n/3-0.0000001;
		k2=n/3+0.0000001;
		printf("%.8lf",k1*k2*(n-k1-k2));
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    private static final int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int l = 0;
        int r = INF;
        for(int tmp = 0; tmp< m; tmp++){
            int x = sc.nextInt();
            l = Math.max(x,l);
            int y = sc.nextInt();
            r = Math.min(y,r);
        }

        System.out.println(l <= r ? r - l + 1 : 0);
    }
}


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

#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int;  // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    pair<ll, ll> a = make_pair(i, 0);
    while ((n % i) == 0) {
      n /= i;
      a.second += 1;
    }
    p.push_back(a);
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
  ll b = MOD, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) {
    u += MOD;
  }
  return u;
}
// 順列
ll permutation(const ll n, const ll m) {
  ll result = 1;
  for (ll i = n; i > n - m; i--) {
    result = (result * i) % MOD;
  }
  return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
  if (x == 0) return 1;
  ll res = repeat_square(n, x / 2);
  res = res * res % MOD;
  if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
  ll p = permutation(n, m);
  ll div = 1;
  for (ll i = 2; i <= m; i++) {
    div = (div * i) % MOD;
  }
  return (p * modinv(div)) % MOD;
}

// アルファベットの取得
string get_alphabet(ll n) {
  n--;
  return string(1, 'a' + (n % 26));
}

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

  vector<ll> x(N);
  bool is_front = (N %2 == 0) ? true : false;

  rep (i, N) {
    cin >> x[i];
  }

  list<ll> ans;
  ans.push_back(x[0]);
  rep (i, 1, N) {

    if (is_front) {
      ans.push_front(x[i]);
    } else {
      ans.push_back(x[i]);
    }
    is_front = !is_front;
  }

  for(auto itr: ans) {
    cout << itr << endl;
  }

  return 0;
}

Measured memory_bytes: 11112
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      String alpha = sc.next();
      char c = alpha.charAt(0);
      
      // 判定
      String result ="";
      if('a' <= c && c <= 'z'){
        result = "a";
      }else{
        result = "A";
      }
      
      // 出力
      System.out.println(result);
    }

}

Measured memory_bytes: 35692
N,M,X = map(int,input().split())
d=[]
ans = []
for i in range(N):
    l=list(map(int,input().split()))
    d.append(l)
for i in range(2**N):
    u=[0]*M
    price=0
    for j in range(N):
           if ((i>>j) & 1):
                price+=d[j][0]
                for k in range(M):
                    u[k]+=d[j][k+1]
    if all(x>=X for x in u):
        ans.append(price)
print(min(ans) if len(ans) > 0 else -1) 

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

int main() 
{
	int x[5];
	int i;
	int ans = 0;
	int diff_max = 0;
	rep(i, 5)
	{
		cin >> x[i];

		if (x[i] % 10 == 0)
		{
			ans += x[i];
		}
		else 
		{
			int diff = 10 - (x[i] % 10);
			//cout << diff << endl;
			diff_max = max(diff, diff_max);
			ans += diff + x[i];
		}
	}
	cout << ans - diff_max << endl;




}


Measured memory_bytes: 256
package main

import (
  "fmt"
  "math"
)

func main() {
  A := make([]int, 5)
  B := make([]int, 5)
  for i := 0; i < 5; i++ {
    fmt.Scan(&A[i])
    B[i] = A[i]
  }
  var (
    minModI, sumB int
    minMod        = math.MaxInt32
  )
  for i := 0; i < 5; i++ {
    if mod := A[i] % 10; mod != 0 {
      B[i] += 10 - mod
      if mod < minMod {
        minMod = mod
        minModI = i
      }
    }
    sumB += B[i]
  }
  fmt.Println(sumB - B[minModI] + A[minModI])
}


Measured memory_bytes: 512
import sys
input=lambda: sys.stdin.readline().rstrip()
mod=10**9+7
n=int(input())
edge=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
Ans=[]
inf=10**6

#親と入次数を求める
Par=[inf]*n
Par[0]=-1
Deg=[0]*n
Deg[0]=0
Chk=[0]
while Chk:
  c=Chk.pop()
  for next in edge[c]:
    if Par[next]==inf:
      Par[next]=c
      Deg[next]+=1
      Chk.append(next)
 
#トポソする
from collections import deque
TS=list(v for v in range(n) if Deg[v]==0)
D=deque(TS)
while D:
  v=D.popleft()
  for t in edge[v]:
    if t!=Par[v]:
      Deg[t]-=1
      if Deg[t]==0:
        D.append(t)
        TS.append(t)

C1,C2=[0]*n,[0]*n
for i in reversed(range(n)):
  v=TS[i]
  if len(edge[v])==1 and Par[v]!=-1:
    C1[v]=1
    C2[v]=1
  else:
    c1,c2=1,1
    for g in edge[v]:
      if g==Par[v]:
        continue
      else:
        c1=((C1[g]+C2[g])*c1)%mod
        c2=(C1[g]*c2)%mod
    C1[v]=c1
    C2[v]=c2
print((C1[0]+C2[0])%mod)



Measured memory_bytes: 31824
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
	int na, nb, m;
	std::cin >> na >> nb >> m;
	std::vector<int> a(na), b(nb), x(m), y(m), c(m);
	for (auto &e : a) std::cin >> e;
	for (auto &e : b) std::cin >> e;
	for (int i = 0; i < m; i++) {
		std::cin >> x[i] >> y[i] >> c[i];
		x[i]--;
		y[i]--;
	}
	
	int min = *std::min_element(a.begin(), a.end())
		+ *std::min_element(b.begin(), b.end());
	for (int i = 0; i < m; i++) {
		min = std::min(min, a[x[i]] + b[y[i]] - c[i]);
	}
	
	std::cout << min << std::endl;
	
	return 0;
}


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

int main() {
    int  L,R,d;
    cin >> L >> R >> d;
    int countL = 0;
    int countR = 0;
    
    countL = (L-1)/d;
    countR = R/d;


    cout << countR-countL << endl;

    
    
    
    
}

Measured memory_bytes: 3628
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n, k, *a = map(int, read().split())
    if n <= k:
        print(1)
        sys.exit()
    else:
        r = ceil((n - 1) / (k - 1))
        print(r)
if __name__ == '__main__':
    main()

Measured memory_bytes: 88516
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public long N, S;
        public void Run()
        {
            N = Input.ReadLong();
            S = Input.ReadLong();

            if (N == S)
            {
                Console.WriteLine(N+1);
            }
            else if (N < S)
            {
                Console.WriteLine(-1);
            }
            else
            {
                for (int i = 2; i < 1000000; i++)
                {
                    if (Success(i))
                    {
                        Console.WriteLine(i);
                        return;
                    }
                }

                for (int m = 1000000; m >= 1; m--)
                {
                    if (SuccessMod(m) != -1)
                    {
                        Console.WriteLine(SuccessMod(m));
                        return;
                    }
                }

                Console.WriteLine(-1);
            }
        }

        public bool Success(int b)
        {
            long s = 0;
            long n = N;
            while (n > 0)
            {
                s += n % b;
                n /= b;
            }
            return s == S;
        }

        public long SuccessMod(int m)
        {
            if (S - m < 0) return -1;
            long x = N - (S - m);
            if (x < 0) return -1;
            if (x % m != 0) return -1;
            long b = x / m;
            if (b <= S - m) return -1;
            return b;
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 11220
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,t;
    cin>>n>>t;
    vp a(n);
    rep(i,n)cin>>a[i].fi>>a[i].se;
    sort(all(a));
    vi dp(6010);
    rep(i,n){
        rev(j,t){
            dp[j+a[i].fi]=max(dp[j+a[i].fi],dp[j]+a[i].se);
        }
    }
    cout<<*max_element(all(dp))<<endl;
}

Measured memory_bytes: 384
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

n = int(input())
s = input()

mod = 10**9+7

import collections
c = collections.Counter(s)
#print(c)
c_value_lst = list(c.values())
#print(c_value_lst)

ans = 1

for i in c_value_lst:
    ans = ans * (i+1)
    #print(ans)
    ans = ans%mod
print(ans-1)

Measured memory_bytes: 39408
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

	vector<int> spos;
	vector<int> tpos;

	rep(i, X.size())
	{
		if (X[i] == 'S')
		{
			spos.push_back(i);
		}
		else
		{
			tpos.push_back(i);
		}
	}

	vector<int> ss(X.size(), 0);
	vector<int> ts(X.size(), 0);

	rep(i, X.size())
	{
		ss[i] = (i == 0 ? 0 : ss[i - 1]);

		if (X[i] == 'S')
		{
			ss[i]++;
		}

		ts[i] = (i == 0 ? 0 : ts[i - 1]);

		if (X[i] == 'T')
		{
			ts[i]++;
		}
	}


	int scount = 0;

	reverse(all(spos));

	for (auto s : spos)
	{
		int tmp = ss[X.size() - 1] - (s == 0 ? 0 : ss[s - 1]);
		//Sの個数のほうが多ければ消せない
		if (tmp - scount > ts[X.size() - 1] - ts[s]) scount++;
	}

	int tcount = 0;

	for (auto t : tpos)
	{
		//Tの個数のほうが多ければ消せない
		if (ts[t] - tcount > ss[t]) tcount++;
	}

	cout << 2 * max(scount, tcount) << endl;

	return 0;
}

Measured memory_bytes: 2976
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
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);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int C[27];

int main(){
  ll N;
  cin >> N;
  ll M=N;
  ll T=0,K=0;
  rRep(i,20,2){
    if(i==20){
      C[i]=M%4;
      K+=M%4;
      M/=4;
    }
    else{
      C[i]=M%2;
      K+=M%2;
      M/=2;
    }
  }
  cout << 20 << " " << 38+K << endl;
  cout << 19 << " " << 20 << " " << 0 << endl;
  cout << 19 << " " << 20 << " " << 1 << endl;
  cout << 19 << " " << 20 << " " << 2 << endl;
  cout << 19 << " " << 20 << " " << 3 << endl;
  T=4;
  rRep(i,18,2){
    cout << i << " " << i+1 << " " << 0 << endl;
    cout << i << " " << i+1 << " " << T << endl;
    T*=2;
  }
  T=0;
  Rep(i,2,20){
    if(C[i]){
      cout << 1 << " " << i << " " << T << endl;
      T+=pow(2,21-i);
    }
  }
  rep(i,C[20]){
    cout << 1 << " " << 20 << " " << T << endl;
    T++;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3


import collections
import functools
from math import gcd


L = 10 ** 6 + 1


def sieve_of_eratosthenes(end):
    """Enumerates prime numbers below the given integer `end`.

    Returns (as a tuple):

    - `is_prime`: a list of bool values.
      If an integer `i` is a prime number, then `is_prime[i]` is True.
      Otherwise `is_prime[i]` is False.
    - `primes`: a list of prime numbers below `end`.
    """

    if end <= 1:
        raise ValueError("The integer `end` must be greater than one")
    is_prime = [True for _ in range(end)]
    is_prime[0] = False
    is_prime[1] = False
    primes = []
    for i in range(2, end):
        if is_prime[i]:
            primes.append(i)
            for j in range(2 * i, end, i):
                is_prime[j] = False
    return primes


PRIMES = sieve_of_eratosthenes(L)


def factorize(n):
    factors = []
    if n < 2:
        return factors
    for p in PRIMES:
        if p * p > n:
            break
        while n % p == 0:
            factors.append(p)
            n //= p
    if n > 1:
        factors.append(n)
    return factors


def is_pairwise_coprime(bs):
    lcm_fs = set()
    for b in bs:
        ps = set(factorize(b))
        for p in ps:
            if p in lcm_fs:
                return False
            else:
                lcm_fs.add(p)
    return True


def is_setwise_coprime(bs):
    return functools.reduce(gcd, bs) == 1


def main():
    n = int(input())
    bs = [int(b) for b in input().split()]
    if is_pairwise_coprime(bs):
        print("pairwise coprime")
    elif is_setwise_coprime(bs):
        print("setwise coprime")
    else:
        print("not coprime")


if __name__ == '__main__':
    main()

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

using namespace std;

int main()
{
   
   int k,s;
   scanf("%d%d",&k,&s);
   int i,j,ans,cnt=0;
   
   for(i=0;i<=k;++i) 
    {
        for(j=0;j<=k;++j)
          {
            ans=s-(i+j);
            if(ans<=k && (i+j+ans)==s && ans>=0)
               {    
                    cnt++;
               }
          }
    }
    
    printf("%d",cnt);
  
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	ll N, M;
	priority_queue<ll> A;
	ll tmp, sum;

	sum = 0;

	cin >> N >> M;

	rep(i, N)
	{
		cin >> tmp;
		A.push(tmp);
	}

	rep(i, M)
	{
		tmp = A.top();
		A.pop();
		A.push((int)(tmp / 2));
	}

	tmp = A.size();
	rep(i, tmp)
	{
		sum += A.top();
		A.pop();
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1400
n = int(input())
l = list(map(int,input().split()))
sorted_l = sorted(l)
left_med,right_med = sorted_l[int(n/2)-1], sorted_l[int(n/2)]

for i in l:
    if i <= left_med:
        print(right_med)
    
    else:
        print(left_med)

Measured memory_bytes: 25472
import java.util.Scanner;

public class Main {

public static void main(String[] args) {

		//??\??????????????????????????????Scanner???????????§???????????????
		Scanner scan = new Scanner(System.in);
		//s??¨p?????????????????????
		String s = scan.next();
		String p = scan.next();

		//s???2??????????????????
		s += s;

		if(s.contains(p)){
			System.out.println("Yes");
		} else  {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 26276
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> pll;
const lli inf = 1e18;

int main(){
    lli a;
    double b;
    cin >> a >> b;
    lli c = b*100 +1e-6;
    lli ans = a*c;
    ans /= 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int f(int i,int x){
	return i*(100+x)/100;
}

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		vi a(n);
		int t=m,id=0;
		while(1){
			if(t>0){
				a[id]++,t--;
				if(a[id]==m){
					cout<<id<<endl;
					break;
				}
			}
			else{
				t+=a[id];
				a[id]=0;
			}
			id=(id+1)%n;
		}
	}
}


Measured memory_bytes: 2988
n = int(input())
b = list(map(int, input().split()))

a = [0]*n

#print(*a)
#print(*b)

a[0] = b[0]

for i in range(n-1):
    a[i+1] = b[i]
    if (a[i] > b[i]):
        a[i] = b[i]

print(sum(a))


Measured memory_bytes: 38384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        int MAX_INF = 10000000;
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        int[][] cost = new int[N][N];
        for (int i = 0; i < N; i++) {
            Arrays.fill(cost[i], MAX_INF);
        }
        int[] a = new int[M];
        int[] b = new int[M];
        int[] c = new int[M];
        for (int i = 0 ; i < M; i++) {
            a[i] = scan.nextInt()-1;
            b[i] = scan.nextInt()-1;
            c[i] = scan.nextInt();
            cost[a[i]][b[i]] = c[i];
            cost[b[i]][a[i]] = c[i];
        }
        int[][] dp = new int[N][N];
        for(int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                dp[i][j] = MAX_INF;
            }
        }
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                if (i == j) {
                    dp[i][j] = 0;
                    continue;
                }
                dp[i][j] = cost[i][j];
            }
        }
        for (int k = 0; k < N; k++) {
            for(int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    dp[i][j] = Math.min(dp[i][j],dp[i][k]+dp[k][j]);
                }
            }
        }
        int answer = M;
        for(int i = 0; i < M; i++) {
            for (int j = 0; j < N; j++) {
                if (dp[j][a[i]]+c[i] == dp[j][b[i]]) {
                    answer -= 1;
                    break;
                }
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 26836
n = int(input())
h = list(map(int, input().split()))

ans = 0
watering = False
while sum(h) > 0:
    for i in range(n):
        if h[i] > 0:
            if not watering:
                ans += 1
            watering = True
            h[i] -= 1
        else:
            watering = False
    watering = False
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
	#include <set>
	#define ll long long 
	#include <string>
	#define pb push_back
	#define mp make_pair
	# define pi 3.14159265358979323846
	#define mod 1000000007
	#define rep(i,n) for(i=0;i<n;i++)
	#define repk(i,k,n) for(i=k;i<n;i++)
	using namespace std;
	void fastio()
	{
		#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	    #endif
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    cout.tie(NULL);

	}
	ll int multiply(ll int a,ll int b)
	{
		ll int ans=(a%mod*b%mod)%mod;
		return ans;
	}
	ll int add(ll int a, ll int b)
	{
		ll int ans=(a%mod+b%mod)% mod;
		return ans;
	}
	ll int vis[100001]={0};
vector< vector<ll int> >adj(100001);
	void dfs(ll int n)
	{
		vis[n]=1;
		for(auto child: adj[n])
		{
			if (vis[child]==0)
				dfs(child);
		}
	}


	void solve()
	{
		ll int n,m;
		cin>>n>>m;
		while(m--)
		{
			ll int x,y;
			cin>>x>>y;	
			adj[x].pb(y);
			adj[y].pb(x);
		}
		ll int i;
		ll int ans=0;
		for(i=1;i<=n;i++)
		{
			if(vis[i]==0 && adj[i].size()>0)
				{dfs(i);
					ans++;}
		}
		ans--;
		
		repk(i,1,n+1)
		{if(vis[i]==0)
			ans++;}
			cout<<ans<<endl;

		

	}
		
	int main()
	{ 
		fastio();
	    ll int t;
	    // cin>>t;
	    t=1;
	    while(t--)
	    {
	    	solve();
	    }
	}

		
			
		
		
		
		





Measured memory_bytes: 10568
#  AtCoder Beginners Contest 66 - B
# -*- encoding: UTF-8 -*-
slist = list(input())

slist.pop()

if len(slist) % 2 == 1:
  slist.pop()

result = 0
while len(slist) > 0 :
   l = int(len(slist) / 2)
#   print(slist)
#   print(l)
   flist = slist[0:l]
   rlist = slist[l:]
#   print(flist)
#   print(rlist)
   if "".join(flist) == "".join(rlist) :
      result = len(slist)
      break
   slist.pop()
   slist.pop()

print(result)


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>

using namespace std;

template
<   
	typename TYPE,
	std::size_t SIZE
>
std::size_t array_length(const TYPE (&)[SIZE])
{   
	return SIZE;
}

int main(int argc, char *argv[]) {
	int antenna[5];
	int k;
	for (int i = 0; i < array_length(antenna); i++) {
		cin >> antenna[i];
	}
	cin >> k;
	
	bool flag = false;
	for (int i = 0; i < array_length(antenna); i++) {
		for (int j = i + 1; j < array_length(antenna); j++) {
			if (abs(antenna[j] - antenna[i]) > k) {
				flag = true;
				break;
			}
		}
	}
	
	if (flag) {
		cout << ":(" << endl;
	} else {
		cout << "Yay!" << endl;
	}
}

Measured memory_bytes: 256
#include "iostream"
using namespace std;
int main(){
  int h;int w;int h1; int w1;
  cin>>h>>w;
  cin>>h1>>w1;
  if(h1==h||w1==w){
    cout<<0<<endl;

  }
  else{
    cout<<(w-w1)*(h-h1)<<endl;
  }
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <vector>

using namespace std;

typedef long long LL;

LL gcd(LL x, LL y)
{
    if (x < y) swap(x,y);
    LL r;
    while(y) {
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

LL n, m;
char s[114514], t[114514];

int main()
{
    cin >> n >> m;
    scanf("%s%s", s+1, t+1);
    LL z = gcd(n,m);
    LL nn = n / z, mm = m / z;
    bool succ = (s[1] == t[1]);
    for (LL i = 1, j = 1, i0 = 1, j0 = 1; succ && i0 <= n; i += mm, j += nn, i0 += 1, j0 += 1) {
        if ((i - 1) % nn == 0 && s[i0] != t[(i - 1)/nn + 1]) succ = 0;
    }
    for (LL i = 1, j = 1, i0 = 1, j0 = 1; succ && j0 <= m; i += mm, j += nn, i0 += 1, j0 += 1) {
        if ((j - 1) % mm == 0 && t[j0] != s[(j - 1)/mm + 1]) succ = 0;
    }
    //cout << succ << endl;
    if (z == min(n,m)) {
        if (n < m) {
            for (LL i = 1; i <= m&&succ; ++i) {
                if (s[i%n]!=t[i]) succ = 0;
            }
        }
        else {
            for (LL i = 1; i <= n&&succ; ++i) {
                if (t[i%m]!=s[i]) succ = 0;
            }
        }
    }
    if (succ) cout << nn * mm * z;
    else cout << -1;

}

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

int H,W;
char R[501][501],B[501][501],P[501][501];

int main(){
	cin >> H >> W;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if((j==1 || i%2==1) && j!=W) R[i][j] = '#';
			else R[i][j] = '.';
			if((j==W || i%2==0) && j!=1) B[i][j] = '#';
			else B[i][j] = '.';
			cin >> P[i][j];
			if(P[i][j]=='#'){
				R[i][j] = '#';
				B[i][j] = '#';
			}
		}
	}
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(j!=W) cout << R[i][j];
			else cout << R[i][j] << endl;
		}
	}
	cout << endl;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(j!=W) cout << B[i][j];
			else cout << B[i][j] << endl;
		}
	}
}

Measured memory_bytes: 1408
class DisjointSet
  class Node
    include Comparable

    attr_reader :id
    attr_accessor :parent, :rank

    def initialize(id)
      @id = id
      @parent = self
      @rank = 0
    end

    def root?
      @parent == self
    end

    def <=>(other)
      @id <=> other.id
    end
  end

  def initialize(n)
    @nodes = n.times.map {|id| Node.new(id) }
  end

  def unite(x, y)
    node1 = @nodes[x]
    node2 = @nodes[y]

    link(find_set(node1), find_set(node2))
  end

  def same?(x, y)
    find_set(@nodes[x]) == find_set(@nodes[y])
  end

  private

  def find_set(node)
    unless node.root?
      node.parent = find_set(node.parent)
    end

    node.parent
  end

  def link(node1, node2)
    if node1.rank > node2.rank
      node2.parent = node1
    else
      node1.parent = node2

      if node1.rank == node2.rank
        node2.rank += 1
      end
    end
  end
end

if $PROGRAM_NAME == __FILE__
  n, q = gets.chomp.split.map(&:to_i)

  ds = DisjointSet.new(n)

  q.times do
    command, x, y = gets.chomp.split.map(&:to_i)

    case command
    when 0
      ds.unite(x, y)
    when 1
      puts ds.same?(x, y) ? 1 : 0
    else
      raise "unknown command: #{command}"
    end
  end
end

Measured memory_bytes: 8940
rInt :: String -> Int
rInt str = read str :: Int

divisors :: Int -> Int -> Int
divisors a b
  |a `mod` b  == 0 = 1
  |otherwise      = 0
  
main :: IO ()
main = do
  input <- getLine
  let tripleInt = map rInt $ words input
  let a = head tripleInt
      b = tripleInt !! 1
      c = last tripleInt  
  --print $ sum (map (divisors c) [a..b])
  print $ sum [1 | x <- [a..b], c `mod` x == 0]   	 

Measured memory_bytes: 4116
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

int main(){
	int n;
	scanf("%d", &n);
	int count[6];
	char judge[4] = {'A', 'W', 'T', 'R'};
	char tmp[8];
	for(int i=0; i<6; i++) count[i] = 0;
	
	for(int i=0; i<n; i++){
		scanf("%s", tmp);
		for(int i=0; i<4; i++){
			if(tmp[0] == judge[i]) count[i]++;
		}
	}
	
	printf("AC x %d\n", count[0]);
	printf("WA x %d\n", count[1]);
	printf("TLE x %d\n", count[2]);
	printf("RE x %d\n", count[3]);

	//printf("%d\n", ans);
	
	
	return 0;
}


Measured memory_bytes: 1704
#include<stdio.h>

int main(void)
{
   int a[5], i, x[5], s, z=0;

   for(i=0;i<5;i++){
      scanf("%d",&a[i]);
      x[i]=a[i]%10;
      if(x[i]!=0)
         x[i]=10-x[i];
      s+=a[i]+x[i];
      if(z<x[i])
         z=x[i];
   }

   printf("%d\n",s-z);
   return 0;
}

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

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

    int n;
    cin >> n;
    int cnt4 = 0;
    int cntO = 0;
    int cnt2 = 0;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        if (tmp % 4 == 0) cnt4++;
        else if (tmp % 2 == 0) cnt2++;
        else cntO++;
    }

    if (cnt2 == 0 && cnt4 + 1 >= cntO) cout << "Yes" << '\n';
    else if (cnt2 > 0 && cnt4 >= cntO) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    for (int k = 0; k <= N; k++) {
        for (int l = 0; l <= M; l++) {
            if ( (k*(M-l)+(N-k)*l) == K ) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

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

using namespace std;

int main(void) {
    string S;
    cin >> S;

    int N = S.size();
    int P = 2019;
    vector<int> v(P);

    int t = 0;
    int ten = 1;
    int ans = 0;
    for(int i=0; i<N; i++) {
        t += (S[N-1-i]-'0') * ten;
        ten *= 10;
        t %= P;
        ten %= P;
        ans += v[t];
        v[t]++;
    }

    cout << ans + v[0] << endl;
    return 0;
}


Measured memory_bytes: 3652
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).expect("");
    let trimmed = s.trim();
    let v: Vec<&str> = trimmed.split(' ').collect();
    let n: i32 = v[0].parse().unwrap();
    let l: i32 = v[1].parse().unwrap();

    let mut vec: Vec<(i32, i32)> = Vec::new();
    for i in l..l+n {
        vec.push((i.abs(), i));
    }
    vec.sort();
    let mut ans = 0;
    for it in &vec[1..] {
        ans += it.1;
        // println!("{} {}", it.0, it.1);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
Q = 10**9+7
#import sys
#input = sys.stdin.readline
from collections import deque
def main():
    N, K = map( int, input().split())
    E = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map( lambda x: x-1, map( int, input().split()))
        E[a].append(b)
        E[b].append(a)
    V = [0]*N
    V[0] = K
    d = deque()
    for i in range( len(E[0])):
        t = E[0][i]
        V[t] = K - 1 - i
        if K == i+1:
            print(0)
            return
        cnt = 0
        for v in E[t]:
            if V[v] == 0:
                d.append(v)
                if K == cnt+2:
                    print(0)
                    return
                V[v] = K-2-cnt
                cnt += 1
    while d:
        t = d.popleft()
        cnt = 0
        for v in E[t]:
            if V[v] == 0:
                d.append(v)
                if K == cnt+2:
                    print(0)
                    return
                V[v] = K-2-cnt
                cnt += 1
    ans = 1
    for v in V:
        ans *= v
        ans %= Q
    print(ans)
    
if __name__ == '__main__':
    main()



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

long long ans = 0;

int par[100000];  // 親
int Rank[100000]; // 木の深さ
int size[100000]; // 木の要素数

void init(int n){
	for(int i=0; i<n; i++){
		par[i] = i;
		Rank[i] = 0;
		size[i] = 1;
	}
}

int find(int x){
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(Rank[x] < Rank[y]){
		ans += (long long)size[x]*size[y];
		par[x] = y;
		size[y] += size[x];
	}else{
		ans += (long long)size[x]*size[y];
		par[y] = x;
		size[x] += size[y];
		if(Rank[x] == Rank[y]) Rank[x]++;
	}
}

bool same(int x, int y){
	return (find(x) == find(y))?true:false;
}

int main(){
	int N, M;
	cin >> N >> M;
	init(N);
	int A[M], B[M];
	long long ANS[M];
	ANS[M-1] = (long)N*(N-1)/2;
	for(int i=0; i<M; i++) cin >> A[i] >> B[i];
	for(int i=0; i<M-1; i++){
		A[M-i-1]--; B[M-i-1]--;
		unite(A[M-i-1], B[M-i-1]);
		ANS[M-2-i] = (long long)N*(N-1)/2 - ans;
	}
	for(int i=0; i<M; i++) cout << ANS[i] << endl;
	return 0;
}

Measured memory_bytes: 4096
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from 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:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

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

const INF: i64 = 1 << 60;

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    m: usize,
    key: [(i64, [usize1]); m],
  }
  let key: Vec<_> = key.into_iter().map(|(a, c)| (a, c.into_iter().map(|x| 1 << x).sum::<usize>())).collect();
  let mut cost = vec![INF; 1 << n];
  cost[0] = 0;
  for i in 0 .. 1 << n {
    for &(a, c) in &key {
      cost[i | c] = cmp::min(cost[i | c], cost[i] + a);
    }
  }
  let ans = if cost[(1 << n) - 1] == INF {
    -1
  } else {
    cost[(1 << n) - 1]
  };

  puts!("{}\n", ans);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
using namespace std;
#define M 55555
vector<bool> a(M+1,true);
void make(void){
	a[0]=a[1]=false;
	for(int i=2;i<=M;i++){
		int j=2;
	if(a[i]){
		while(j*i<=M){
			a[j*i]=false;
			j++;
			}
		}else{
			a[i]=false;
		}
	}
	return;
}

void solve(int n){
	cout<<2;
	for(int i=2;i<M+1;i++){
	if(a[i]&&i%5==1){
		cout<<' '<<i;
		n--;
		if(n==1)return;
	}
	}
	cout<<endl;
	return ;
}
int main(){
int n;
cin>>n;
make();
solve(n);
return 0;
}


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

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

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve(parseProblem())
}

func parseProblem() (int, []int) {
	n := scanInt(sc)
	xs := nextIntSlice(sc, n)
	return n, xs
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

func resolve(n int, xs []int) {
	sorted := make([]int, len(xs))
	copy(sorted, xs)
	sort.Sort(sort.IntSlice(sorted))
	mid := n >> 1
	for i := 0; i < len(xs); i++ {
		if xs[i] >= sorted[mid] {
			fmt.Println(sorted[mid-1])
		} else {
			fmt.Println(sorted[mid])
		}
	}
	return
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 8664
import os
import sys

import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N, M = list(map(int, sys.stdin.readline().split()))
ABC = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

D = np.zeros((N, N))
for a, b, c in ABC:
    D[a - 1][b - 1] = c

min_dist = dijkstra(csgraph_from_dense(D), directed=False)
print((min_dist < D).sum())


Measured memory_bytes: 19904
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	ll a, b, c;
	cin >> a >> b >> c;
	if(c - a - b < 0) {
		cout << "No" << endl;
		return 0;
	}
	else {
		if(a*a+b*b+c*c > 2*(a*b+b*c+c*a)) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
inline void solve()
{
	int d,t,s;
	cin>>d>>t>>s;
	if(t*s>=d) cout<<"Yes\n";
	else cout<<"No\n";

}
int main()
{
	IOS();
	solve();
	return 0;
}




Measured memory_bytes: 3644