akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile

INF = float("inf")


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in readi(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[0]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    N = readi()
    x = readi(N, 3)
    dp = arr(N + 1, 3)
    for i in range(N):
        for j in range(3):
            dp[i + 1][j] = max(
                dp[i + 1][j], dp[i][(j + 1) % 3] + x[i][j], dp[i][(j + 2) % 3] + x[i][j]
            )
    print(max(dp[N]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 45944
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    std::vector<int> a(5);
    rep(i, 5) std::cin >> a[i];
    int tmp = 0;
    rep(i, 5) tmp += (a[i] + 10 - 1) / 10 * 10;
    int ans = 1e9;
    rep(i, 5) {
        ans = std::min(ans, tmp - (a[i] + 10 - 1) / 10 * 10 + a[i]);
    }
    std::cout << ans << std::endl;
}

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

Measured memory_bytes: 256
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import sys

sys.setrecursionlimit(10000)
INF = float('inf')


a = list(map(int, input().split()))
a.sort()

if a == [5,5,7]:
    print('YES')
else:
    print('NO')



Measured memory_bytes: 13572
#!python3

# input
N = int(input())


def main():
    n = int(N ** 0.5)
    for a in range(n, 0, -1):
        if N % a == 0:
            b = N // a
            ans = len(str(b))
            print(ans)
            return


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner sn, PrintWriter out) {
            char a[] = sn.next().toCharArray();
            int arr[] = new int[26];
            for (int i = 0; i < a.length; i++) {
                arr[a[i] - 'a']++;
            }
            String r = "";
            String al[] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};

            for (int i = 0; i < 26; i++) {
                if (arr[i] == 0) {
                    r = al[i];
                    break;
                }
            }
            if (r.equals("")) {
                out.println("None");
            } else {
                out.println(r);
            }
        }

    }
}



Measured memory_bytes: 27052
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <complex>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack> 
#include <bitset>
#include <queue>
#include <assert.h>
#include <unordered_map>
using namespace std;

const int N = 2000010;
char s[N], str[N];

int main()
{
	scanf("%s%s", s, str);
	int ans = 0;
	for (int i = 0; s[i]; i++)
		ans += s[i] != str[i];
	cout << ans << endl;
	return 0;
}


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

using ll = long long int;

int t;
ll a, b, c, d;

string ans;

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

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

  for (int i = 0; i < t; ++i) {
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

    if (a < b) ans = "No";
    else if (d < b) ans = "No";
    else if (c >= b) ans = "Yes";
    else {
      ll g = gcd(b, d);
      ans = ((a % g + b - g) > c) ? "No" : "Yes";
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1000000007;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  while(1){
    int a,b;
    char op;
    cin >> a >> op >> b;
    if (op == '+') {
      cout << a+b << endl;
    } else if (op == '-') {
      cout << a-b << endl;
    } else if (op == '*') {
      cout << a*b << endl;
    } else if (op == '/') {
      cout << a/b << endl;
    } else break;
  }
}


Measured memory_bytes: 3068
#include <cstdio>
#include <cstdlib>
struct Node {
	int key;
	Node *p, *l, *r;
};
Node *root;
void insert(int key_) {
	Node *x = root, *y = 0, *z;
	z = (Node*)malloc(sizeof(Node));
	z->key = key_, z->l = 0, z->r = 0;
	while (x) y = x, x = (z->key < x->key) ? x->l : x->r;
	z->p = y;
	if (!y) root = z;
	else if (z->key < y->key) y->l = z;
	else y->r = z;
}
void walk1(Node *x) { if (!x) return; walk1(x->l); printf(" %d", x->key); walk1(x->r); }
void walk2(Node *x) { if (!x) return; printf(" %d", x->key); walk2(x->l); walk2(x->r); }
int n, v; char c[8];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", &c);
		if (c[0] == 'i') scanf("%d", &v), insert(v);
		else walk1(root), printf("\n"), walk2(root), printf("\n");
	}
}

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

bool works(int ans, int a, int b) {
	bool w1 = floor(ans * .08) == a;
  	bool w2 = floor(ans * .10) == b;
  	return w1 && w2;
}

int main() {
	int a, b; cin >> a >> b;
  	for (int ans = 1; ans <= 200000; ans++) {
     	if (works(ans, a, b)) {
         	cout << ans << endl;
          	return 0;
        }
    }
  	cout << -1 << endl;
}

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

int main()
{
  int k, t;
  scanf("%d%d", &k, &t);
  int max = 0;
  for (int i = 0; i < t; ++i)
  {
    int a;
    scanf("%d", &a);
    if (a > max) max = a;
  }
  printf("%d\n", std::max(max - 1 - (k - max), 0));
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int s = scan.nextInt();
        int[] t = new int[n];
        for(int i = 0; i < n; i++){
            t[i] = scan.nextInt();
        }
        int out = s;
        for(int i = 1; i < n; i++){
            out += Math.min(t[i] - t[i - 1], s);
        }
        System.out.println(out);
    }
}

Measured memory_bytes: 63868
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"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)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() (int, int) {
	return scanInt(sc), scanInt(sc)
}

func resolve(l, r int) int {
	df := r - l
	if df+1 >= 2019 {
		return 0
	}
	min := 2019
	for i := 0; i < df; i++ {
		for j := i + 1; j <= df; j++ {
			v := (l + i) * (l + j) % 2019
			if min > v {
				min = v
			}
			if v == 0 {
				return 0
			}
		}
	}
	return min
}

// 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: 1780
#include <bits/stdc++.h>
 
 
#define pb push_back
#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod) x-=mod;if(x<0) x+=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))
#define Set(N,cur) N=(N|(1LL<<cur))
#define Reset(N,cur) N=(N&(~(1LL<<cur)))
#define Check(N,cur) (!((N&(1LL<<cur))==0))
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define dump(x) cerr<<"~ "<<#x<<" = "<<x<<endl
//Imran addition
#define rep(i,n) for(int i = 1; i <= n; i++)
#define mem CLR
#define pf printf
#define sc scanf
#define endl "\n"
#define gi(k) scanf("%d",&k)
#define gl(k) scanf("%lld",&k)
#define NMAX 2147483647
#define LMAX 9223372036854775807LL
 
using namespace std;
 
 
#define LL long long
#define LLU long long unsigned int
typedef long long vlong;
typedef unsigned long long uvlong;
typedef pair < int, int > pii;
typedef pair < vlong, vlong > pll;
typedef vector<int> vi;
typedef vector<vlong> vl;
typedef vector<pll> vll;
 
inline vlong gcd ( vlong a, vlong b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}
 
 
const vlong inf = 2147383647;
const vlong mod = 1000000007;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-9;
 
 
 
int main () {
 
 	#ifdef forthright48
    freopen ( "00_input.txt", "r", stdin ); //freopen ( "00_output.txt", "w", stdout );
 	#endif

    int n,t,a,x,tmp,dif,ans;
 
    cin >> n;
    cin >> t >> a;

    t *= 1000;
    a *= 1000;
    dif = 2e9;

    rep(i,n) {
        gi(x);

        tmp = t - x*6;

        if(dif > ABS(tmp-a)) {
            dif = ABS(tmp-a);
            ans = i;
        }
    }

    //dump(dif);
	
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200200;
int uf[maxn];
int find(int x){
	if(x == uf[x]) return x;
	return uf[x] = find(uf[x]);
}
int main(){
	iota(uf, uf + maxn, 0);
	int n, m; cin >> n >> m;
	for(int i = 0; i < n; i++){
		int k; cin >> k;
		for(int j = 0; j < k; j++){
			int x; cin >> x; x--; x += n;
			uf[find(x)] = find(i);
		}
	}
	for(int i = 0; i < n; i++) if(find(i) != find(0)){
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	return 0;
}


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

namespace ABC114
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int[] a = new int[s.Length];
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = int.Parse(s.Substring(i, 1));
            }
            int ans = int.MaxValue;
            int value = 0;
            for (int i = 0; i < a.Length - 2; i++)
            {
                value = a[i] * 100 + a[i + 1] * 10 + a[i+2];
                ans = Math.Min(ans, Math.Abs(value - 753));
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
N, M = map(int, input().split())
data = [list(map(int, input().split())) + [i] for i in range(M)]
data.sort(key=lambda x: [x[0], [x[1]]])

res = [None] * M
prev_n = data[0][0]
m_count = 1
for d in data:
    n, m, idx = d
    if prev_n != n:
        prev_n = n
        m_count = 1
    res[idx] = str(prev_n).zfill(6) + str(m_count).zfill(6)
    m_count += 1
    
print(*res, sep='\n')


Measured memory_bytes: 43804
#include<cstdio>
#include<math.h>
#include<algorithm>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int INF=1001001001;
int N,K;
int A[100002];


int main(){
	while(1){
	scanf("%d %d",&N,&K);
	if(N==0&&K==0)break;
	rep(i,N)scanf("%d",&A[i]);
	long long int ans=0;
	long long int sans=0;
	rep(i,K)sans+=A[i];
	ans=sans;
	rep(i,N-K){
		sans-=A[i];
		sans+=A[i+K];
		ans=max(ans,sans);
	}
	printf("%lld\n",ans);
	}
}

Measured memory_bytes: 1416
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, k, i, j, x, y, s;
	cin >> n >> k;
	vector<int> a(n), b(n);
	for (i = 0; i < n; i++) cin >> a[i];

	if (k > 100) k = 100;
	while (k--) {
		vector<int> in(n, 0), out(n, 0);
		for (i = 0; i < n; i++) {
			x = max(0, i - a[i]);
			y = min(n - 1, i + a[i]);
			in[x]++;
			out[y]++;
		}

		s = 0;
		for (i = 0; i < n; i++) {
			s += in[i];
			b[i] = s;
			s -= out[i];
		}

		swap(a, b);
	}

	for (i = 0; i < n; i++) cout << a[i] << " ";
	cout << "\n";



	return 0;
}


Measured memory_bytes: 5988
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=200000;
int n;
int a[N+1];
int buc[N+1];
signed main()
{
	cin>>n;
 	for(int i=1;i<=n;i++)cin>>a[i],buc[a[i]]++/*???*/;
 	int ans=0;
 	for(int i=1;i<=n;i++)ans+=buc[i]*(buc[i]-1)/2;//???????? 
 	for(int i=1;i<=n;i++)cout<<ans-(buc[a[i]]-1)<<"\n";
 	return 0;
}

Measured memory_bytes: 4736
// AOJ 2013 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2013)
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)
#define clr(a,v) memset((a),(v),sizeof(a))

const int MAX_H = 24, MAX_M = 60, MAX_S = 60;

int n;
int S[MAX_H*MAX_M*MAX_S];

int main()
{
	while( scanf( "%d", &n ), n )
	{
		clr( S, 0 );

		rep( i, n )
		{
			int hh, mm, ss;
			scanf( "%d:%d:%d", &hh, &mm, &ss );
			++S[hh*60*60+mm*60+ss];
			scanf( "%d:%d:%d", &hh, &mm, &ss );
			--S[hh*60*60+mm*60+ss];
		}

		int ans = S[0];
		rep( i, MAX_H*MAX_M*MAX_S-1 )
		{
			S[i+1] += S[i];
			ans = std::max( ans, S[i+1] );
		}

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

	return 0;
}

Measured memory_bytes: 1372
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

ll dp[105][2][2][105];
int visited[105][2][2][105];
int lim, k;

vector<int> digit;
int cnt;

ll solve(int pos, int isSmall, int isStart, int value)
{
    //cout<<pos<<endl;
    if(value > k)
        return 0;
    if(pos == lim){
        if(value == k)
            return 1;
        return 0;
    }
    if(dp[pos][isSmall][isStart][value] != -1)
        return dp[pos][isSmall][isStart][value];


    int last = isSmall ? 9 : digit[pos];
    ll ret = 0;

    if(!isStart){
        for(int i = 0; i <= last; i++){
            ret += solve(pos + 1, isSmall | i < digit[pos], 0, ((i != 0) ? 1 : 0) + value);
        }
    }
    else{
        for(int i = 1; i <= last; i++){
            ret += solve(pos + 1, isSmall | i < digit[pos], 0, 1 + value);
        }
        ret += solve(pos + 1, 1, 1, 0);     //we need this call because leading zero is not allowed
    }

    return dp[pos][isSmall][isStart][value] = ret;
}


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

    string str;

    cin>>str;
    cin>>k;

    memset(dp, -1, sizeof(dp));
    for(int i = 0; i < (int) str.size(); i++){
        digit.pb(str[i]-48);
    }

    lim = digit.size();
    ll result = solve(0, 0, 0, 0);

    cout<<result<<endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<vector<int>> edges(N);
	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;
		edges[a - 1].push_back(b - 1);
		edges[b - 1].push_back(a - 1);
	}

	long long V = 0, K1 = 0, K2 = 0; 
	vector<int> mark(N, -1);
	
	for (int i = 0; i < N; i++)
	{
		if (mark[i] == -1)
		{
			queue<int> que;
			que.push(i);
			mark[i] = 0;
			bool cycle = false;
			int count = 0;
			while (!que.empty())
			{
				int u = que.front();
				count++;
				que.pop();
				int val = mark[u] ^ 1;
				for (int v : edges[u])
				{
					if (mark[v] == -1)
					{
						mark[v] = val;
						que.push(v);
					}
					else if(mark[v] != val)
						cycle = true;
				}
			}

			if (count == 1)
				V++; 
			else if (cycle)
				K1++;
			else
				K2++;
		}
	}

	cout << K1 * K1 + 2 * K1 * K2 + 2 * K2 * K2 + V * (2 * N - V);
	return 0;
}

Measured memory_bytes: 7296
from itertools import cycle

INITIALIZE = 32

while True:

    input_count = int(input())

    if input_count == 0:
        break

    get_list = [int(item) for item in input().split(" ")]

    ohajiki = INITIALIZE
    output = []

    for get_count in cycle(get_list):

        ohajiki -= (ohajiki - 1) % 5
        print(ohajiki)

        if get_count < ohajiki:
            ohajiki -= get_count
            print(ohajiki)
        else:
            print(0)
            break



Measured memory_bytes: 5644
m,d = input().split()

M = int(m)
D = int(d)
count = 0
for i in range(1, M + 1):
    for j in range(1, D + 1):
        if j < 10:
            continue
        else:
            d1 = int(j % 10)
            d10 = int(j / 10)
            if d1 < 2 or d10 < 2:
                continue

            if i == d1 * d10:
                count += 1

print(count)

Measured memory_bytes: 3060
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMAX）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int lb(int l,int r,int n,int *d){
  if(n>(1<<29))return r;
  while(l-r){
    int m=(l+r)/2;
    n<=d[m]?(r=m):(l=m+1);
  }
  return l;
}

int n,i,j,k,s=0,c,a[200010],b[200010],d[200010];
int main(){
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%lld",&a[i]);
  for(i=0;i<n;i++)scanf("%d",&b[i]);
  for(i=0;i<29;i++){
    R=C=1;
    k=(1<<i);//printf("%d\n",k);
    for(j=0;j<n;j++)hin(b[j]&((2<<i)-1));
    for(j=0;j<n;j++)d[j]=N[hout()];
    //for(j=0;j<n;j++)printf("%d ",d[j]);printf("\n");
    for(j=c=0;j<n;j++)c+=((lb(0,n,2*k-(a[j]&((2<<i)-1)),d)-
			   lb(0,n,1*k-(a[j]&((2<<i)-1)),d))%2+
			  (n-
			   lb(0,n,3*k-(a[j]&((2<<i)-1)),d))%2);
    s+=c%2*k;
    /*or(j=0;j<n;j++)printf("%d %d %d %d\n",s,
			   lb(0,n,2*k-(a[j]&((2<<i)-1)),d),
			   lb(0,n,1*k-(a[j]&((2<<i)-1)),d),
			   lb(0,n,3*k-(a[j]&((2<<i)-1)),d));//*/
  }
  printf("%d\n",s);
  return 0;
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    ll a;
    long double b; cin >> a >> b;
    ll ans = a * b;
    cout << ans << endl;
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int cnt[10][10];

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

    int n;
    cin >> n;
    for (int i=1; i<10; i++)
        for (int j=1; j<10; j++)
            for (int x=1; x<=n; x++)
                if (x % 10 == j) {
                    int y = x;
                    while (y >= 10) y /= 10;
                    if (y == i) cnt[i][j]++;
                }

    long long ret = 0;
    for (int i=1; i<10; i++)
        for (int j=1; j<10; j++)
            ret += (long long) cnt[i][j] * cnt[j][i];

    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;cin >> N;
    list<int> li;
    vector<int> vec;
    for(int a = 0;a < N;a++){
        int b;cin >> b;
        vec.push_back(b);
    }
    for(int a = 0;a < N;a++){
        if(a % 2==0){
            li.push_back(vec.at(a));
        }else{
            li.push_front(vec.at(a));
        }
    }
    vector<int> v;
    for(int a:li){
        v.push_back(a);
    }
    if(N%2==0){
        for(int a:v)cout<<a<<" ";
    }else{
        for(int a = v.size()-1;a >= 0;a--)cout<<v[a]<<" ";
    }
    std::cout<<std::flush;
    return 0;
}


Measured memory_bytes: 10100
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

vector<vector<int>> all;
vector<int> tmp1, tmp2;

int main()
{
    IO;
    int n, d;
    cin >> n >> d;
    for(int i = 0; i < n; i++)
    {
        for(int i = 0; i < d; i++)
        {
            int a;
            cin >> a;
            tmp1.push_back(a);
        }
        all.push_back(tmp1);
        tmp1.clear();
    }
    tmp1.clear();
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        tmp1 = all[i];
        for(int j = i + 1; j < n; j++)
        {
            tmp2 = all[j];
            int sum = 0;
            for(int k = 0; k < d; k++)
                sum += (tmp1[k] - tmp2[k]) * (tmp1[k] - tmp2[k]);
            int aux = sqrt(sum);
            if(aux * aux == sum)
                ans++;
        }
    }
    cout << ans;
    return 0;
}


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

int main(){
    int P,Q;
    while(cin>>P>>Q){
        map<int,int> latte;
        int m=0,l=0,r=0;
        vector<int> ans;
        latte[P%Q] = 0;
        m = P%Q;
        while(m){
            int nm = m*10%Q;
            ans.push_back(m*10/Q);
            if(latte.find(nm)!=latte.end()){
                l = latte[nm]; r = ans.size(); break;
            }
            latte[nm] = ans.size();
            m = nm;
        }
        for(int i=0;i<ans.size();i++) printf("%d",ans[i]); puts("");
        if(r!=0){
            for(int i=0;i<ans.size();i++){
                if(l<=i) printf("^");
                else printf(" ");
            }puts("");
        }
    }
    return 0;
}

Measured memory_bytes: 1212
/* Author darklight13 -_- 
   IIT Patna 
*/
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
// typedef tree<int, null_type, less<int>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//     data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " is " << (x) << endl
#define dbg(x)     cout << x << ' '
#define here cout << " Hey! ";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld PI = 3.1415926535898;
set<string> ans;
int n;
void solve(int idx, string s) 
{
	if(idx==n)	{
		ans.insert(s);
		return;
	}
	set<char> used_char;
	for(auto it : s)	used_char.insert(it);
	int new_char = (char)('a'+sz(used_char));
	string tmp = s;
	tmp.pb(new_char);
	solve(idx+1,tmp);
	for(auto it : used_char) {
		tmp = s;
		tmp.pb(it);
		solve(idx+1,tmp);
	}
	return;	
}
int32_t main()
{
	SYNC
	cin >> n;
	string t = "";
	solve(0,t);
	for(auto it : ans) {
		cout << it << '\n';
	}
    return 0;
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
typedef long long ll;
const int N=0;
string s;
vector<int>v;
int main(){

	ll n,a,b;
	cin >> n >> a >>b;
	ll cycle = n/(a+b);
	ll rem = n%(a+b);

	cout << cycle*a+min(rem,a);


	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll k;
  cin>>k;

  ll n=50;
  vll v;
  REP(i,n)v.push_back(i);

  ll m=k%n;
  REP(i,m){
    v[0] += n;
    REP1(i,n)v[i]--;
    sort(v.begin(), v.end());
  }

  REP(i,n)v[i]+=k/n;
  cout<<n<<endl;
  cout<<v[0];
  REP1(i,n)cout<<" "<<v[i];
  cout<<endl;

}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var p = Array.ConvertAll(line, int.Parse);
        getAns(n, p);
    }
    static void getAns(int n, int[] p)
    {
        var min = 300000;
        var count = 0;
        for (int i = 0; i < n; i++)
            if (p[i] < min)
            {
                count++;
                min = p[i];
                if (min == 1) { Console.WriteLine(count); return; }
            }
    }
}


Measured memory_bytes: 31452
#include "bits/stdc++.h"
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long int
#define tc int t; cin>>t; while(t--)
#define fora(i,n) for(int i=0;i<n;i++)
#define forb(i,a,n) for(int i=a;i<n;i++)
#define mod 1000000007

template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1);}

int32_t main()
{
    fastio

 	char ch; cin>>ch;
 	if(towupper(ch)==ch) cout<<'A';
 	else cout<<'a';  


    return 0;


}

Measured memory_bytes: 3644
#include <iostream>
#include <map>

using namespace std;

int main(void){
  char b;
  map<char, char> pair{
    {'A','T'},
    {'T','A'},
    {'C','G'},
    {'G','C'}
  };
  
  cin >> b;
  
  cout << pair[b] << endl;
  
  return 0;
}
  
  

Measured memory_bytes: 256
#include <cstdio>
#include <string>

using namespace std;

int main() {
    char buf[1<<11];
    fgets(buf, 1<<11, stdin);
    string s(buf);

    for (char c: s)
        printf("%c", (c>='A'&&c<='Z')||(c>='a'&&c<='z')? c^0x20:c);

    return 0;
}

Measured memory_bytes: 2632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	try (Scanner sc = new Scanner(System.in)) {
	    int a = sc.nextInt();
	    int b = sc.nextInt();
	    System.out.printf("%d %d %f\n", a / b, a % b, (double) a / b);
	} catch (Exception e) {
	    System.out.println(e.getMessage());
	}
    }
}

Measured memory_bytes: 26328
package main

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

func check(b []byte) bool {
	for i := 0; i <= len(b)/2; i++ {
		if b[i] != b[len(b)-1-i] {
			return false
		}
	}
	return true
}

func main() {
	s := readBytes()
	n := len(s)

	if check(s) && check(s[:n/2]) && check(s[(n+3)/2-1:]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	rep(i,n) cin >> a.at(i) >> b.at(i);
	ll ans=0;
	rep(i,n){
		if((a.at(n-1-i)+ans)%b.at(n-1-i)!=0){
			ans+=b.at(n-1-i)-(a.at(n-1-i)+ans)%b.at(n-1-i);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

using Graph = vector<vector<int>>;
Graph G;
vector<ll> ans;
void dfs(int v, int p = -1){
  for (auto nv: G[v]){
    if (nv == p) continue;
    ans[nv] += ans[v];
    dfs(nv, v);
  }
}

int main(){
  int N, Q; cin >> N >> Q;
  G.resize(N);
  rep(i, N - 1){
    int a, b; cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  ans.resize(N);
  rep(i, Q){
    int p, x; cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0, -1);
  rep(i, N) cout << ans[i] << " ";
  cout << endl;
}


Measured memory_bytes: 24320
#include<iostream>
#include<vector>
using namespace std;
const int N = 20;

// DP version: O(n_max k_max s_max) for initialization, O(1) for each data
int dp[21][11][156];
void init(){
  // base case: n = 0. no solution except for k = 0 and s = 0
  for(int k = 0; k < 11; k++) {
    for(int s = 0; s < 156; s++) {
      dp[0][k][s] = 0;
    }
  }
  dp[0][0][0] = 1;
  // incrementing n
  for(int n = 1; n < 21; n++) {
    for(int k = 0; k < 11; k++) {
      for(int s = 0; s < 156; s++) {
        int cnt = 0;
        if(k > 0 && s >= n) cnt += dp[n-1][k-1][s-n]; // using n
        if(n > k) cnt += dp[n-1][k][s]; // not using n
        dp[n][k][s] = cnt;
      }
    }
  }
}
int main(int argc, char *argv[])
{
  init();
  for(;;) {
    int n, k, s;
    cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    cout << dp[n][k][s] << endl;
  }
  return 0;
}



Measured memory_bytes: 3144
#include<stdio.h>
int main(){
	int a[201][3]={0},n,i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++)for(j=0;j<3;j++)scanf("%d",&a[i][j]);
	for(j=0;j<3;j++){
		for(i=0;i<n;i++){
			for(k=i;k<n;k++){
				if(a[i][j]%100==a[k][j]%100 && i!=k)a[i][j]+=100,a[k][j]+=100;
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			if(a[i][j]>100)a[i][j]=0;
		}
	}
	for(i=0;i<n;i++)printf("%d\n",a[i][0]+a[i][1]+a[i][2]);
	return 0;
}



Measured memory_bytes: 2104
#include <stdio.h>

int main(void)
{
  int n,p,i,rem,ans;

  for(;;){
    int pro[50]={0};
    scanf("%d %d", &n, &p);
    if(n==0&&p==0) break;

    rem=p;
    for(i=0;;){
      if(rem==0&&pro[i]!=p){
	rem+=pro[i];
	pro[i]=0;
	if(i<n-1){
	  i++;
	  continue;
	}
	if(i==n-1) i=0;
	continue;
      }
      if(rem>0){
	rem--;
	pro[i]++;
      }
      if(rem==0&&pro[i]==p){
	ans=i;
	break;
      }
      if(i==n-1){
	i=0;
	continue;
      }
      if(i<n-1) i++;
    }
    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 600
#include <stdio.h>
#include <string.h>

int main(){
    int l = 0 ;
    char word[1001];

    scanf("%s",word);
    l = strlen(word);

    if(word[l-1] == 's')
        printf("%ses\n",word);
    else
        printf("%ss\n",word);

    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  cout<<a.at(N-1)-a.at(0)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin>>S;
    int count = 0, S_end = S.size()-1;
    for(int i = 0; i < S.size()/2; i++){
        if(S[i] != S[S_end - i]){
            count++;
        }
    }
    cout<<count<<endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    int N;
    cin >> N;
    string s = "No";
    for(int i=1;i<=9;i++){
        if(N%i==0){
            int b = N/i;
            if(1<=b&&b<=9){
                s = "Yes";
                break;
            }
        }
    }

    cout << s << endl;
}



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

int main(){
    string a,b;
    cin >> a >> b;
    string str=a+b;
    int num=stoi(str);
    bool judge=false;
    for(int i=1; i<num; i++){
        if(i*i==num){
            judge=true;
        }
        if(i*i>num){
            break;
        }
    }
    if(judge){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
from bisect import bisect_left

n = int(input())
l = [int(_) for _ in input().split()]
l.sort()
ans = 0

for s in range(n - 2):
    for t in range(s + 1, n - 1):
        x = bisect_left(l, l[s] + l[t])
        ans += x - t - 1

print(ans)

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

struct UnionFind{
  vector<int> root;
  vector<int> rank;
  vector<int> size;

  UnionFind(int N): root(N), rank(N), size(N,1){
    iota(root.begin(), root.end(), 0);
  }

  int find(int a){
    if(root.at(a)==a){
      return a;
    }
    else{
      return root.at(a)= find(root.at(a));
    }
  }

  void unify(int a, int b){
    int r_a= find(a);
    int r_b= find(b);
    if(r_a != r_b){
      if(rank.at(r_a) < rank.at(r_b)){
        root.at(r_a)= r_b;
        size.at(r_b)+= size.at(r_a);
        return;
      }
      else{
        root.at(r_b)= r_a;
        size.at(r_a)+= size.at(r_b);
        if(rank.at(r_a)==rank.at(r_b)) rank.at(r_a)++;
        return;
      }
    }
  }
  
  bool are_comrade(int a, int b){
    return find(a)==find(b);
  }

  int get_size(int a){
    return size.at(find(a));
  }
};

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

  UnionFind uf(N);
  vector<int> offset(N,1); // ans.at(i)= (iが属する連結成分のサイズ)- 1(自分自身)- (#iの友人)- (#iと同じ連結成分に属してブロック関係にある人)
                           //          = uf.get_size(i)        - offset.at(i)
  int buf1,buf2;
  for(int i_f=0; i_f<M; i_f++){
    cin >> buf1 >> buf2;
    buf1--; buf2--; // 1-indexed -> 0-indexed
    uf.unify(buf1, buf2);
    offset.at(buf1)++;
    offset.at(buf2)++;
  }
  for(int i_b=0; i_b<K; i_b++){
    cin >> buf1 >> buf2;
    buf1--; buf2--; // 1-indexed -> 0-indexed
    if(uf.are_comrade(buf1, buf2)){
      offset.at(buf1)++;
      offset.at(buf2)++;
    }
  }
  
  for(int i=0; i<N-1; i++){
    cout << uf.get_size(i)- offset.at(i) <<" ";
  }
  cout << uf.get_size(N-1)- offset.at(N-1) << endl;
}

Measured memory_bytes: 2432
x,y = map(int,input().split())

if y<x<0 or 0<y<x:
    print(abs(x-y)+2)
elif (y<x and x==0) or (y==0 and y<x):
    print(abs(x-y)+1)
elif x<=y<=0 or 0<=x<=y:
    print(abs(x-y))
elif x<0<y or y<0<x:
    print(abs(abs(x)-abs(y))+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef pair<int,int> P;
typedef long long ll;



int main() {
    int a, b;
    cin >> a >> b;
    
    if(a > 9 || b > 9) {
        cout << -1 << endl;
    }
    else {
        cout << a * b << endl;
    }
    
    
    return 0;
}




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

int main(void)
{
    string str[100 + 10];
    int n = 0;
    scanf("%d %*d", &n);
    for (int i = 0; i < n; i++)
        cin >> str[i];
    sort(str, str + n);
    for (int i = 0; i < n; i++)
        cout << str[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
sc = []
for _ in range(M):
    x = list(map(int,input().split()))
    sc.append(x)
if N == 3:
    ll = 1000
    ls = 100
elif N == 2:
    ll = 100
    ls = 10
elif N == 1:
    ll = 10
    ls = 0
ans = -1
for i in range(ls,ll):
    x = str(i)
    check = 1
    for j in sc:
        s = j[0]
        c = j[1]
        if int(x[s-1]) != c:
            check = 0
    #print(i,check) 
    if check == 1:
        ans = i
        break
print(ans)

Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <string>
#include <math.h>
#include<set>
#include<stdio.h>
#include <bitset>
#include<string.h>
#define ii int64_t
#define PI 3.14
#define lli long long int
#define li long int
#define deb(x) cout<<"\nhi"<<x<<"\n"
#define mod 1000000007
#define f(x,n) for(int x=0;x<n;++x)
#define ff(x,y,z) for(x=y;x<=z;++x)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// while(scanf("%d",&n)!=EOF)




using namespace std;
 

int main()
 
{
    fio
    ii n,W,i,j=0,x=0;
    cin>>n>>W;
    ii w,v,dp[100004];dp[0]=0;
    for(i=1;i<100005;i++)dp[i]=1000000009;
    
    for(i=1;i<=n;i++)
    {
        cin>>w>>v;
        x+=v;
        for(j=x;j>=v;j--)
        {
            dp[j]=min(dp[j],dp[j-v]+w);
        }
    }//cout<<i<<" "<<x<<" ";
    for(i=x;i>=0;i--)
        if(dp[i]<=W)
        {
            cout<<i;exit(0);
        }
    
    
}





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

using namespace std;

int main() {
    int n;
    while (cin >> n && n) {
        vector<int> vi;
        for (int i = 0; i < n; i++) {
            int a;
            cin >> a;
            vi.push_back(a);
        }

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

        int sum = 0;
        for (int i = 1; i < n - 1; i++) {
            sum += vi[i];
        }

        cout << sum / (n - 2) << endl;
    }
}


Measured memory_bytes: 3024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int N , K , X , Y;
   cin >> N >> K >> X >> Y;
   
   if ( N > K ) {
   cout << K * X + ( N - K ) * Y << endl;
   }else {
    cout << N * X << endl;}
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K;
    string S;
    cin >> N >> K >> S;
    S[K - 1] = tolower(S[K - 1]);
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,K,M;cin>>N>>K>>M;
        if(N+K+M==0) break;
        
        vector<int> A(N);
        iota(all(A),1);
        int nowsee=M-1;
        
        while(A.size()>1){
            A.erase(A.begin()+nowsee);
            nowsee=(nowsee+K-1)%(A.size());
        }
        
        cout<<A[0]<<endl;
    }
    
}



Measured memory_bytes: 3180
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf8');

// Your code here!
const max = (a)=>{
    let i = a.length;
    let max=-Infinity;
    while (i--) {
        if (a[i] > max)max = a[i];
    }
    return max;
}
const min = (a)=>{
    let i = a.length;
    let max=Infinity;
    while (i--) {
        if (a[i] < max)max = a[i];
    }
    return max;
}
const Main = (p)=>{
	// 1行目がinput[0], 2行目がinput[1], …に入る
	p = p.split("\n");
	//let N = parseInt(p[0].split(" ")[0]);
	let N = parseInt(p[0]);
	//let M = parseInt(p[0].split(" ")[1]);
	let h = (p[1].split(" ").map(Number));
	let i = N;
// 	while(i--){
// 	    h[i]=Math.floor(Math.random() * 100);
// 	}
	let c = new Array(N).fill(Infinity);
	//console.log(h)
    c[0]=0;
    c[1]=Math.abs(h[0]-h[1]);
    for(i=2;i<N;i++){
        c[i]=Math.min(c[i-2]+Math.abs(h[i]-h[i-2]),c[i-1]+Math.abs(h[i]-h[i-1]));
    }
	//文字列から10進数に変換するときはparseIntを使います
	console.log(c[N-1]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 30016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAXN=100005;
int read(){int x;scanf("%d",&x);return x;}
ll a[MAXN],ans;
struct node{int id,val;}b[MAXN];
int N;
bool cmp(node x,node y){return x.val<y.val;}
int main(){
	N=read();
	for(int i=1;i<=N;i++) b[i]=(node){i,read()};
	sort(b+1,b+N+1,cmp);
	for(int i=1;i<=N;i++) a[b[i].id]=i;
	for(int i=1;i<=N;i+=2) if(a[i]%2==0) ans++;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792