akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define hi cout<<"hi"
#define ll long long
#define all(c) c.begin(),c.end()
#define mod 1000000007
#define pb push_back
#define pb2 pop_back
#define ff first
#define ss second
#define debug(x) cout<<#x<<" : "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define IO ios_base::sync_with_stdio(0);cin.tie(NULL);
const char nl = '\n';
int main(){
    ll n;cin>>n;
    cout<<(n+n*n+n*n*n)<<nl;
}


Measured memory_bytes: 3608
import java.util.BitSet;
import java.util.Scanner;
import java.util.stream.Collectors;

class Solver {
    void solve(Scanner sc) {
        int N = sc.nextInt();
        BitSet a = new BitSet(N);
        for (int i = 0; i < N; i++) {
            a.set(i, sc.nextInt() == 1);
        }

        BitSet box = new BitSet(N);
        for (int n = N; n > 0; n--) {
            int sum = 0;
            for (int i = n; i <= N; i += n) {
                if (box.get(i - 1)) {
                    sum++;
                }
            }
            if ((sum % 2 == 1) != a.get(n - 1)) {
                box.set(n - 1);
            }
        }
        System.out.println(box.cardinality());
        System.out.println(box.stream().map(i -> i + 1).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
    }
}

class Main {
    public static void main(String... args) {
        Scanner in = new Scanner(System.in);

        new Solver().solve(in);

        in.close();
    }
}

Measured memory_bytes: 67084
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<string>
#include<stack>
#include<algorithm>

using namespace std;

void slove(){
    int n;
    int ans = 0;
    string s;
    cin>>n;
    cin>>s;
    int l = 0;
    int r = n-1;

    while(l < r){
        while(l < r && s[l] == 'R') l++;
        while(l < r && s[r] == 'W') r--;
        if(l < r){
            swap(s[l],s[r]);
            ans++;
        }
    }

    cout<<ans<<endl;
}

int main(){
    slove();
}

Measured memory_bytes: 3688
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

long long x[100050];
long long nxt[100050][31];
int main()
{
    long long n, q, l;
    scanf("%lld", &n);
    for(long long i = 0; i < n; ++i)
        scanf("%lld", &x[i]);
    scanf("%lld", &l);
    for(long long j = 0; j < 20; ++j)
    {
        for(long long i = 0; i < n; ++i)
        {
            if(j == 0)
                nxt[i][j] = upper_bound(x + i, x + n, x[i] + l) - x - 1;
            else
                nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
        }
    }
    scanf("%lld", &q);
    while(q--)
    {
        long long a, b;
        scanf("%lld%lld", &a, &b);
        --a;
        --b;
        if(a > b)
            swap(a, b);
        long long ans = 0;
        for(long long i = 19; i >= 0; --i)
        {
            if(a == b)
                break;
            if(nxt[a][i] < b)
            {
                ans += 1 << i;
                a = nxt[a][i];
            }
        }
        printf("%lld\n", ans + 1);
    }
    return 0;
}


Measured memory_bytes: 25728
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

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

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

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

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

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;

fn main() {
    let a:u32 = read();
    let b:u32 = read();

    println!("{}", if a%2!=0 && b%2!=0 {"Yes"} else {"No"});

}


Measured memory_bytes: 4476
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> 
// using namespace __gnu_pbds;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MaX 300005
using namespace std;

 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
   	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
// typedef tree<int, null_type, less<int>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//     new_data_set; 
bool isprime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}
const int N=2e5+5;
ll a[N];
int main()
{
	fast();
	ll ans=0,i,n;
	cin>>n;
	rep(i,n)
	{
		cin>>a[i];
		ans=ans^a[i];
	}
	for(i=0;i<n;i++)
		cout<<(ans^a[i])<<' ';
}






/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀
⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀
⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀
⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀
⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸⠀
⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁⠀⠀⠀⠀⠀
*/

Measured memory_bytes: 5044
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		boolean[] isprime = new boolean[100001];
		int[] likenum = new int[100001];
		int[] sum = new int[100001];
		sum[0] = 0;
		int q = sc.nextInt();

		for(int i = 0; i <= 100000; i++) {
			isprime[i] = true;
			likenum[i] = 0;
		}

		isprime[0] = false;
		isprime[1] = false;


		for(int i = 2; i <= 100000; i++) {
			if(isprime[i]) {
				for(int j = 2; i*j <= 100000; j++) {
					isprime[i*j] = false;
				}
				if(i%2 == 1 && isprime[(i+1)/2]) {
					likenum[i] = 1;
				}
			}
		}

		for(int i = 1; i <= 100000; i++) {
			sum[i] = sum[i-1] + likenum[i];
		}

		for(int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			System.out.println(sum[r] - sum[l-1]);
		}

		sc.close();
	}
}

Measured memory_bytes: 66304
main :: IO ()
main = putStrLn =<< winner <$> getLine <*> getLine <*> getLine

winner :: String -> String -> String -> String
winner = go 'a'
  where
    go 'a' [] _ _       = "A"
    go 'a' (x:xs) ys zs = go x xs ys zs
    go 'b' _ [] _       = "B"
    go 'b' xs (y:ys) zs = go y xs ys zs
    go 'c' _ _ []       = "C"
    go 'c' xs ys (z:zs) = go z xs ys zs

Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <ext/rope>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define vi vector<int>
#define pii pair<int,int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
const int maxn=1e5+10;
const int dis[4][2]={{0,1},{-1,0},{0,-1},{1,0}};
using namespace std;
using namespace __gnu_cxx;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m;
ll a[maxn],ma,ans;
int main()
{
    int i,j,k,t;
    scanf("%d%d",&n,&m);
    rep(i,1,n)scanf("%d",&a[i]);
    rep(i,1,n-1)if(ma<a[i]+a[i+1])ma=a[i]+a[i+1],ans=i;
    if(ma<m)puts("Impossible");
    else
    {
        puts("Possible");
        for(int i=1;i<ans;i++)printf("%d\n",i);
        for(int i=n-1;i>ans;i--)printf("%d\n",i);
        printf("%d\n",ans);
    }
    //system ("pause");
    return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
int main()
{
	long long int k;
	scanf("%lld", &k);
	long long  int i, n = 50;
	long long int a[50];
	for (i = 0; i < n; i++)
		a[i] = n - 1 + k / n;
	k %= n;
	for (i = 0; i < k; i++)
		a[i] += n - k + 1;
	for (i = k; i < n; i++)
		a[i] -= k;
	printf("%lld\n", n);
	for (i = 0; i < n - 1; i++)
		printf("%lld ", a[i]);
	printf("%lld\n", a[n - 1]);
	return 0;
}

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

void solve() 
{
    int n,p;string s;cin>>n>>p>>s;
    int64_t ans=0;
    if(p==2||p==5){
        REP(i,n)if(!((s[i]-'0')%p))ans+=i+1;
    }else{
        map<int,int>cnt;
        cnt[0]=1;
        int64_t cur=0,ten=1;
        REP(i,n){
            (cur+=(s[n-1-i]-'0')*ten)%=p;
            ans+=cnt[cur]++;
            (ten*=10)%=p;
        }
    }
    cout<<ans<<endl;
}

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


Measured memory_bytes: 916
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
/* テンプレートここまで */
void no(){
  cout << "IMPOSSIBLE" << endl;
  exit(0);
}
int main() {
  ll a,b; cin >> a >> b;
  if(a>b) swap(a,b);
  if((b-a)%2==0) cout << (a+b)/2 << endl;\
  else no();
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    readLine()!!
    val list = readLine()!!.split(" ").map(String::toInt)
    val pointMin = list.average().toInt()
    val pointMax = pointMin + 1
    val resultA = list.asSequence().map { it - pointMin }.map { it * it }.sum()
    val resultB = list.asSequence().map { it - pointMax }.map { it * it }.sum()
    println(Math.min(resultA, resultB))
}

Measured memory_bytes: 36136
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<assert.h>

int main()
{
	int k = 0, u = 0;
	scanf("%d", &k);
	u = (k / 500) * 1000;
	k %= 500;
	u += (k / 5) * 5;

	printf("%d", u);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>

int main () {
    int N;
    std::cin >> N;
    std::string ans = "hon";
    N %= 10;
    N %= 10;
    if (N == 3) {
        ans="bon";
    } else if (N == 0 || N == 1 || N == 6 || N == 8) {
        ans = "pon";
    }
    std::cout << ans ;
    return 0;
}

Measured memory_bytes: 3596
N=int(input())
F=list(map(int,input().split()))
s=0
ans=0
while True:
  while F[s]==0:
    s+=1
    if s==N:
      break
  if s==N:
    break
  t=s
  while F[t]!=0:
    t+=1
    if t==N:
      break
  m=min(F[s:t])
  for j in range(s,t):
    F[j]-=m
  ans+=m
print(ans)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		long[] a = new long[n];
		long[] d = new long[n];
		for (int i = 0;i < n;i++) a[i] = sc.nextLong();
		Arrays.sort(a);
		d[0] = a[0];
		for (int i = 1;i < n;i++) d[i] = a[i] + d[i-1];
		int ret = 1;
		for (int i = n-2;i >= 0;i--) {
			if (d[i]*2>=a[i+1]) {
				ret++;
			} else {
				break;
			}
		}
		System.out.println(ret);
	}
}

Measured memory_bytes: 63820
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string atc[101];
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++)
    {
        cin>>atc[i];
        cout<<atc[i]<<endl<<atc[i]<<endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int maxn = 1024;

int a[12], b[12], c[12];

int main() {
    int T; scanf("%d", &T);
    while(T--) {
        for(int i = 0; i < 10; ++i)
            scanf("%d", &a[i]);
        bool flag = false;
        for(int i = 0; i < maxn; ++i) {
            int pos1 = 0, pos2 = 0;
            for(int j = 0; j < 10; ++j) {
                if(i & (1 << j)) b[pos1++] = a[j];
                else c[pos2++] = a[j];
            }
            flag = false;
            for(int j = 0; j < pos1 - 1; ++j) {
                if(b[j] > b[j+1]) {
                    flag = true; break;
                }
            }
            if(flag) continue;
            for(int j = 0; j < pos2 - 1; ++j) {
                if(c[j] > c[j+1]) {
                    flag = true; break;
                }
            }
            if(flag) continue;
            break;
        }
        puts(flag ? "NO" : "YES");
    }
    return 0;
}



Measured memory_bytes: 2484
#include <bits/stdc++.h>
using namespace std;
void a(string t){
  cout<<t<<endl;
  exit(0);
}
int main() {
  int n; string s; cin>>n>>s;
  if(n%2==1) a("No");
  for(int i=0;i<n/2;i++){
    if(s.at(i)!=s.at(i+n/2)) a("No");
  }
  a("Yes");
}

Measured memory_bytes: 256
n=int(input())
cnt=0
ans=0
for i in range(n):
    d,e=map(int,input().split())
    if d!=e:
        if cnt==3:
            ans=1
            break
        cnt=0
    else:
        cnt+=1
        if cnt==3:
            ans=1
            break
if cnt>=3:
    ans=1
if ans==1:
    print("Yes")
else:
    print("No")


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

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

int main() {
	int n = ri();
	int m = ri();
	int l = ri();
	std::vector<std::pair<int, int> > hen[n];
	for (int i = 0; i < m; i++) {
		int a = ri() - 1, b = ri() - 1, c = ri();
		hen[a].push_back({b, c});
		hen[b].push_back({a, c});
	}
	int res[n][n];
	for (int i = 0; i < n; i++) {
		std::vector<std::pair<int, int> > dist(n, {1000000001, 0});
		dist[i] = {0, 0};
		using T = std::pair<std::pair<int, int> , int>;
		std::priority_queue<T, std::vector<T>, std::greater<T> > que;
		que.push({{0, 0}, i});
		while (que.size()) {
			auto cur = que.top();
			que.pop();
			int i = cur.second;
			int cnt = cur.first.first;
			int left = l - cur.first.second;
			for (auto j : hen[i]) {
				if (j.second > l) continue;
				std::pair<int, int> new_cost;
				if (j.second > left) {
					new_cost = {cnt + 1, j.second};
				} else new_cost = {cnt, cur.first.second + j.second};
				if (new_cost < dist[j.first]) dist[j.first] = new_cost, que.push({new_cost, j.first});
			}
		}
		for (int j = 0; j < n; j++) res[i][j] = dist[j].first == 1000000001 ? -1 : dist[j].first;
	}
	int q = ri();
	for (int i = 0; i < q; i++) {
		int a = ri() - 1, b = ri() - 1;
		std::cout << res[a][b] << std::endl;
	}
	return 0;
}



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

using namespace std;

long long attack(long long g) {
    if (g > 1) {
        return 2 * attack(g / 2) + 1;
    }
    else {
        return 1;
    }
}

int main() {
    long long h;
    scanf("%lld", &h);

    printf("%lld\n", attack(h));

    return 0;
}

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

int main(){
    int H,W,h,w;
    cin>>H>>W>>h>>w;

    cout << H*W-(H*w+W*h-(w*h)) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};



int main() {
	int N;cin>>N;
	vector<pair<unsigned long long int, pair<int, int>>>edges;
	for (int i = 0; i < N - 1; ++i) {
		int a,b,c;cin>>a>>b>>c;
		pair<unsigned long long int,pair<int,int>> edge(make_pair(c,make_pair(a,b)));
		edges.push_back(edge);
	}
	sort(edges.begin(),edges.end());
	UnionFind uf(N);
	unsigned long long int ans=0;
	for (auto edge : edges) {
		int a=edge.second.first;
		int b=edge.second.second;
		unsigned long long int c=edge.first;
		ans+=c*uf.size(a)*uf.size(b);
		uf.unionSet(a,b);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7000
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;


ll dfs(int x,int a) {
    if(x==0) return 1;
    ll ret=0;
    rep(i,18) if(a<=i) {
        if(x-i*i>=0) {
            ret+=dfs(x-i*i,i);
        }
    }

    return ret;
}

int main() {
    ll x;
    while(cin>>x) {
        if(x==0) break;
        cout<<dfs(x,1)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1164
# frozen_string_literal: true

# Fenwick Tree
class FenwickTree
  def initialize(arg)
    case arg
    when Array
      @size = arg.size
      @data = Array.new(@size + 1, 0)
      arg.each_with_index { |e, i| add(i + 1, e) }
    when Integer
      @size = arg
      @data = Array.new(@size + 1, 0)
    else
      raise ArgumentError
    end
  end

  def add(i, x)
    while i <= @size
      @data[i] += x
      i += (i & -i)
    end
  end

  def sum(l, r)
    _sum(r) - _sum(l)
  end

  def _sum(i)
    res = 0
    while i > 0
      res += @data[i]
      i &= i - 1
    end
    res
  end
end

FeTree            = FenwickTree
BinaryIndexedTree = FenwickTree

n, q = gets.split.map { |e| e.to_i }
a    = gets.split.map { |e| e.to_i }
 
ft = FeTree.new(a)
 
q.times do
  t, u, v = gets.split.map { |e| e.to_i }
 
  if t == 0
    ft.add(u + 1, v)
  else
    puts ft.sum(u, v)
  end
end


Measured memory_bytes: 57356
#include<bits/stdc++.h>
    using namespace std;
     
    int main(){
      int n;
      cin>>n;
	  if(n%1000==0){
		  cout<<(n%1000);
	  }
	  else{
		cout<<(1000-(n%1000));
	  }
          return 0;
    }

Measured memory_bytes: 3592
#include<stdio.h>
int main() {
	int i, j, a, b ,c;
	j = 0;
		scanf("%d %d %d",&a ,&b ,&c );
		for (i = a; i <= b; i++) {
			if (c % i == 0) j++;
		}
		printf("%d\n", j);
	return 0;
}

Measured memory_bytes: 2756
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

typedef  long long ll;

#define rep(i,a,n) for(ll (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(ll (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007


using namespace std;

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

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

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}


void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int dig(int d){
    int ans = 1;
    if(d == 0) return ans;
    while(d != 0){
        d--;
        ans*=100;
    }
    return ans;
}

ll divisors(ll n) {
    vector<ll> res;

    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i-1);
        if(n/i == i) continue;
        res.push_back((n/i)-1);
    }

    ll ans = 0;

    rep(i,0,res.size()){
        if(res[i] != 0)
        if(n/res[i] == n%res[i]) ans += res[i];
    } 
    return ans;
}

void solve(void){
    ll n,k;
    cin >> n >> k;
    ll a[n];
    rep(i,0,n) {
        cin >> a[i];
    }
    //ll r = (n-1)/(k-1) ? 1 : 0;
    cout << (n-2)/(k-1) + 1<< endl;
 
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

const double pi = 3.141592653589793238462643383279;
using namespace std;
using namespace __gnu_pbds;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

const long double EPS = 1e-6, PI = acos((long double)-1);

//ここから編集
vector<vector<int>> g(501010);
vector<vector<int>> rg(501010);
bool used[501010];
vector<int> vs;
int cmp[501010];
void dfs(int v){
  used[v] = true;
  for(auto u: g[v]) if(!used[u]) dfs(u);
  vs.push_back(v);
}
void rdfs(int v, int k){
  used[v] = true;
  cmp[v] = k;
  for(auto u: rg[v]) if(!used[u]) rdfs(u, k);
}
int scc(int N){
  memset(used, false, sizeof(used));
  REP(i,N){
    if(!used[i]) dfs(i);
  }
  memset(used, false, sizeof(used));
  memset(cmp, -1, sizeof(cmp));
  reverse(all(vs));
  int k = 0;
  for(auto i: vs){
    if(!used[i]) {
      rdfs(i, k);
      k++;
    }
  }

  return k;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N, M; cin >> N >> M;
  REP(i,M){
    int a, b; cin >> a >> b;
    g[a].push_back(b);
    rg[b].push_back(a);
  }

  int k = scc(N);
  vector<vector<int>> ans(k);
  REP(i,N){
    ans[cmp[i]].push_back(i);
  }
  cout << k << endl;
  for(int i=0; i<k; i++){
    cout << ans[i].size();
    for(int j=0; j<ans[i].size(); j++){
      cout << " " << ans[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 80048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var s = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var i = 0;
            for (int j = 1; j < s.Length - 1; j++)
            {
                var a = new[] { s[j - 1], s[j], s[j + 1] }
                .OrderBy(_=>_).ToArray () ;

                if ( a[1] == s[j])
                {
                    i++;
                }
            }
            Console.WriteLine(i);
        }
    }
}


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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m;
int a[N];
int b[N];
int d[N];
int c[N];
map < int, int > e[N];
bool u[N];

vector < int > g[N];

void dfs (int v, int pr = 0) {
    u[v] = 1;

	for (auto i : g[v]) {
		int to = v ^ a[i] ^ b[i];
		if (to == pr) continue;
		
		if (u[to]) {
			if (e[v][to] == 0 && e[to][v] == 0) {
				e[v][to] = 1;
				d[v] ^= 1;
			}

		} else {
			dfs(to, v);

			if (d[to]&1) {
				e[to][v] = 1;
				d[to] ^= 1;
			} else {
				e[v][to] = 1;
				d[v] ^= 1;
			}
		}
	} 
}

int main () {
	SpeedForce;
	cin >> n >> m;
	if (m % 2) {
		puts("-1");
		exit(0);
	}
	for (int i = 1; i <= m; i ++) {
		cin >> a[i] >> b[i];
		g[a[i]].pb(i);
		g[b[i]].pb(i);
	}

	for (int i = 1; i <= n; ++i) {
		
		if (!u[i]) {
			dfs(i);
		}
	}

	for (int i = 1; i <= m; i ++) {
		if (e[b[i]][a[i]] == 1) cout << b[i] << ' ' << a[i];
		else cout << a[i] << ' ' << b[i];
		cout << '\n';
	}

   	return Accepted;
}

// B...a

Measured memory_bytes: 70144
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)

const int nn = 2e5 + 5, mod = 1e9 + 7;
int fac[nn + 1], rev[nn + 1];

int power (int a, int b = mod - 2)
{
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

inline int ncr (int a, int b) {return fac[a] * rev[b] % mod * rev[a - b] % mod;}

signed main() 
{
    fac[0] = rev[0] = 1;
    FOR (i, 1, nn) fac[i] = fac[i - 1] * i % mod;
    FOR (i, 1, nn) rev[i] = power(fac[i]);
    
    int n, k, sum = 0;
    cin >> n >> k;
    
    FOR (i, 0, min(n, k))
        sum = (sum + ncr(n, i) * ncr(n - 1, n - i - 1)) % mod;
    
    cout << sum;
}

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

using namespace std;

const int INF = 1e9 + 10;

int main() {
  while (true) {
    int N;
    cin >> N;
    if (N == 0) {
      break;
    }
    int t[17][17];
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N + 1; j++) {
        cin >> t[i][j];
      }
    }
    int dp[1 << 17 - 1];
    for (int i = 0; i < 1 << 17 - 1; i++) {
      dp[i] = INF;
    }
    dp[0]  = 0;

    for (int i = 0; i < (1 << N); i++) {
      for (int j = 0; j < N; j++) {
        if (i & (1 << j)) {
          continue;
        }
        int costMin = t[j][0];
        for (int k = 0; k < N; k++) {
          if (i & (1 << k)) {
            costMin = min(costMin, t[j][k + 1]);
          }
        }
        dp[i | (1 << j)] = min(dp[i | (1 << j)], dp[i] + costMin);
      }
    }
    cout << dp[(1 << N) - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 3348
#include <stdio.h>
#include <iostream>
#include <cstring>
using namespace std;
#define maxn 1000+10
char s[maxn];
char t[maxn];
int main ()
{
	int n;
	int ok = 0;
	cin>>n;
	cin>>s>>t;
	int cnt = 0;
	for(int i=0; i<n; i++){
		int flag = 1;
		for(int j=0; i+j<n; j++){
			if(s[i+j] != t[j]){
				flag = 0;
				break;
			}
		}
		if(flag == 1){
			ok = 1;
			cout<<i+n<<endl;
			break;
		}
	}
	if(ok  == 0){
		cout<<n*2<<endl;
	}
    return 0;
}


Measured memory_bytes: 384
n, t = map(int, input().split())
a = tuple(map(int, input().split()))
b = tuple(a_ato - a_mae for a_ato, a_mae in zip(a[1:], a))
print(sum(map(lambda x: min(x, t), b)) + t)

"""
最後の人が出したシャワーは、時間いっぱい出る
それ以前の人が出したシャワーは、
時間いっぱいか、次の人が押すまでの時間のうち、短い時間だけ出る
"""


Measured memory_bytes: 25328
#include<iostream>
#include<stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  //整数の時はint
  long long a,b,c,k,n=0;
  cin>>a>>b>>c>>k;
  for(int i=0;i<k;i++){
    if(i<a)n++;
    else if(i>=b+a && i<a+b+c)
      n--;
  }
  cout<<n<<endl;
     
     
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);  
    int N,M,X,Y;
    string ans = "War";
    cin >> N >> M >> X >> Y;
    vector<int> x(N),y(M);
    for(int i = 0;i < N;i ++){
        cin >> x[i];
    }
    for(int i = 0;i < M;i ++){
        cin >> y[i];
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    if(max(X,x[N-1])<min(Y,y[0])) ans = "No War";
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
n = ip()                                     #入力整数1つ
#a,b,c= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
k = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(3)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
k-=1
b = []
for i in range(n):
    if a[i] == a[k]:
        b.append(a[k])
    else: b.append('*')
print(''.join(b))

Measured memory_bytes: 19876
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

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


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

template<typename T> inline void fastin(T &num) {
  T c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}
 
template<typename T> void fastout(T &n) {
  T N = n, rev, count = 0;
  rev = N;
  if (N == 0) { 
    putchar_unlocked('0');
    putchar_unlocked('\n');
    return;
  }
  while ((rev % 10) == 0) { 
    ++count; rev /= 10;
  }
  rev = 0;
  while (N != 0) { 
    rev = (rev << 3) + (rev << 1) + N % 10;
    N /= 10;
  }
  while (rev != 0) { 
    putchar_unlocked(rev % 10 + '0');
    rev /= 10;
  }
  while (count--) putchar_unlocked('0');
  putchar_unlocked('\n');
}

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

    int N; fastin(N);
    vector<int> A(N), B(N);
    rep(i, 0, N) {
        fastin(A[i]);
        B[i] = A[i]-(i+1);
    }

    sort(B.begin(), B.end());

    int b = B[N/2];
    ll res = 0;
    rep(i, 0, N) res += abs(A[i]-b-(i+1));

    fastout(res);
}

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

int main() {

    // input from txt （提出時にこの箇所は削除すること）
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    int K;
    cin >> K;
    string S;
    cin >> S;
    if(S.size() <= K){
        cout << S << endl;
    }
    else{
        cout << S.substr(0,K) + "..." << endl;
    }
}



Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <vector>
#include <algorithm>
using namespace std;

int num(char *buf, int &i)
{
    int n = buf[i++] - '0';
    while(isdigit(buf[i])) n = n*10 + buf[i++] - '0';
    return n;
}

int solve(char *buf, int &i)
{
    int ans = 0;
    ++i;    // skip '['

    if (isdigit(buf[i])) {
        ans = num(buf, i) / 2 + 1;
    } else {
        vector<int> v;
        while (buf[i] == '[') {
            v.push_back(solve(buf, i));
        }
        sort(v.begin(), v.end());

        for (int i = 0; i < v.size() / 2 + 1; ++i) {
            ans += v[i];
        }
    }

    ++i;    // skip ']'
    return ans;
}

int main()
{
    int n;
    char buf[10001];

    scanf("%d ", &n);
    for (int i = 0; i < n; ++i) {
        int j = 0;
        gets(buf);
        printf("%d\n", solve(buf, j));
    }
}

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

int main(int argc, const char * argv[]) {
    int H, W, i1, i2;
    
    while(true){
        cin >> H >> W;
        if(H==0 && W==0)
            break;
        
        for(i1=0;i1<H;i1++){
            for(i2=0;i2<W;i2++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#!/usr/bin/env python3
import sys
import numpy as np

def solve(K: int, N: int, A: "List[int]"):

    a = np.array(A)
    p = a[1:] - a[:-1]
    q = K - a[-1] + a[0]
    print(K -max(np.max(p),q))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(K, N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 46432
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while ((buf = br.readLine())!=null) {
				StringTokenizer st = new StringTokenizer(buf);
				int A = Integer.parseInt(st.nextToken());
				int B = Integer.parseInt(st.nextToken());
				System.out.println(A+B);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  out((b-1) / (a-1) + (bool)((b-1) % (a-1)));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int solve() {
  int N, L;
  cin >> N >> L;
  int sum = N * (L - 1) + N * (N + 1) / 2;
  if (L > 0) return sum - L;
  if (L + N - 1 > 0) return sum;
  return sum - L - N + 1;
}
int main() {
  cout << solve() << endl;
}

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

using namespace std;

#define io freopen("test.txt", "r", stdin);
#define fast ios_base::sync_with_stdio(0);cin.tie(0);


#define ull unsigned long long int
#define lli long long int
#define li long int
#define ld long double

#define cout(x) cout<<x<<" "
#define coutn(x) cout<<x<<endl
#define newline cout<<endl

#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define ar array

#define pii pair<int,int>
#define pll pair<lli,lli>
#define pps pair<pair<int,int>, string>

const int MOD=1000000007;
const lli INF=1e18;
const int MX=100001;
const int N=1000000;


void solve(){

    int n;
    cin>>n;

    vector<pair<int,int>>v(n);
    for(int i=0;i<n;i++) cin>>v[i].first>>v[i].second;

    int i=0;
    while(i<n-2){
        if(v[i].first==v[i].second && v[i+1].first==v[i+1].second && v[i+2].first==v[i+2].second){
            cout<<"Yes\n";
            return;
        }
        i++;
    }
    cout<<"No\n";
    return;
}


int main(){
    fast
    // #ifndef godzqa
    //     io
    // #endif

    lli t;
    // cin>>t;
    t=1;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3652
import sys

input = sys.stdin.readline


def main():
    N, A, B = map(int, input().split())

    if A > B:
        ans = 0
    elif N == 1:
        if A == B:
            ans = 1
        else:
            ans = 0
    else:
        min_sum = A * (N-2)
        max_sum = B * (N-2)
        ans = max_sum - min_sum + 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <stdio.h>


int main(){
  int i,H,A[251];
  scanf("%d",&H);
  for(i=1;i<=H;i++)
    scanf("%d",&A[i]);
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i!=1)printf("parent key = %d, ",A[i/2]);
    if(2*i<=H)printf("left key = %d, ",A[2*i]);
    if(2*i+1<=H)printf("right key = %d, ",A[2*i+1]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2052
#include<bits//stdc++.h>
using namespace std;
typedef pair< int, int > Pi;
const int INF = 1 << 30;
struct edge: vector< Pi > {
  void add_edge(int to, int cost){
    push_back(Pi(to,cost));
  }
} info[100000];
int hoge[100000];
void bfs(const int& st, const int& V){
  fill_n( hoge, V, INF);
  queue< int > que;que.push(st);
  hoge[st] = 0;
  while(!que.empty()){
    int p = que.front();
    que.pop();
    for(int i = 0 ; i < info[p].size() ; i++){
      int cost = info[p][i].second;
      int to = info[p][i].first;
      if( cost + hoge[p] < hoge[to]){
        que.push(to);
        hoge[to] = cost + hoge[p];
      }
    }
  }
}
int main(){
  int N;
  scanf("%d", &N);
  for(int i = 0; i < N; i++){
    int u, k;
    scanf("%d %d", &u, &k);
    u--;
    while(k--){
      int v;
      scanf("%d", &v);
      info[u].add_edge( v - 1, 1);
    }
  }
  bfs(0, N);
  for(int i = 0 ; i < N ; i++ ){
    printf("%d %d\n", i + 1, hoge[i]==INF?-1:hoge[i]);
  }
}


Measured memory_bytes: 5568
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int main() {
    long long N;
    while (cin >> N) {
        vector<long long> A(5);
        long long mi = 1LL<<60;
        for (int i = 0; i < 5; ++i) cin >> A[i], mi = min(mi, A[i]);
        cout << (N + mi - 1) / mi + 4 << endl;
    }
}

Measured memory_bytes: 256
def main():
    n,k = map(int, input().split())
    high = [0] * 110000
    line = list(map(int, input().split()))
    for i in range(n):
        high[i] = line[i]
    INF = float("inf")

    def chmin(a, b):
        if a > b:
            a = b
        return a

    dp = [INF] * (n + k)

    dp[0] = 0

    for i in range(n):
        for j in range(1, k + 1):
            dp[i + j] = chmin(dp[i + j], dp[i] + abs(high[i] - high[i + j]))
    
    print(dp[n - 1])

if __name__ == "__main__":
  	main()


Measured memory_bytes: 54880
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a<=8 && b<=8){
      System.out.println("Yay!");
    }else{
      System.out.println(":(");
    }
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (ll i=a;i<=b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define mod 998244353
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N=100000+5;
int arr[105]= {},vis[105]= {};
int main()
{
#ifdef ONLINE_JUDGE
    FAST;
#endif
    int n,a,b,cnt=0;
    cin>>n>>a>>b;
    lp(i,1,n)
    cin>>arr[i];
    lp(i,1,n)
    {
        if (vis[i])
            continue;
        lp(j,1,n)
        {
            if (vis[j]||vis[i])
                continue;
            lp(k,1,n)
            {
                if (vis[k]||vis[i]||vis[j])
                    continue;
                //i j k
                if (arr[i]<=a&&arr[j]>=a+1&&arr[j]<=b&&arr[k]>=b+1)
                {
                    vis[i]=vis[j]=vis[k]=true;
                    cnt++;
                    continue;
                }
                //j i k
                if (arr[j]<=a&&arr[i]>=a+1&&arr[i]<=b&&arr[k]>=b+1)
                {
                    vis[i]=vis[j]=vis[k]=true;
                    cnt++;
                    continue;
                }
                //k j i
                if (arr[k]<=a&&arr[j]>=a+1&&arr[j]<=b&&arr[i]>=b+1)
                {
                    vis[i]=vis[j]=vis[k]=true;
                    cnt++;
                    continue;
                }
                //j k i
                if (arr[j]<=a&&arr[k]>=a+1&&arr[k]<=b&&arr[i]>=b+1)
                {
                    vis[i]=vis[j]=vis[k]=true;
                    cnt++;
                    continue;
                }
                //k i j
                if (arr[k]<=a&&arr[i]>=a+1&&arr[i]<=b&&arr[j]>=b+1)
                {
                    vis[i]=vis[j]=vis[k]=true;
                    cnt++;
                    continue;
                }
                //i k j
                if (arr[i]<=a&&arr[k]>=a+1&&arr[k]<=b&&arr[j]>=b+1)
                {
                    vis[i]=vis[j]=vis[k]=true;
                    cnt++;
                    continue;
                }

            }
        }
    }
    cout<<cnt<<"\n";
    return 0;
}


Measured memory_bytes: 256