akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
string board[1005];
bool sym[1005][1005];
int C,N;
int ans=0;
int miss=0;
unordered_set<int> rowdif;
unordered_set<int> coldif;
vector<set<int> > rowdifset(1005);
vector<set<int> > coldifset(1005);
void judge()
{
    for(int i=0;i<N/2;i++)
    {
        for(int j=0;j<N;j++)
        {
            if(board[i][j]!=board[N-1-i][j])
            {
                if(i<N/2)
                {
                    rowdifset[j].insert(i);
                }
                else
                {
                    rowdifset[j].insert(N-1-i);
                }
            }
        }
    }
    for(int i=0;i<N/2;i++)
    {
        for(int j=0;j<N;j++)
        {
            if(board[j][i]!=board[j][N-1-i])
            {
                if(i<N/2)
                {
                    coldifset[j].insert(i);
                }
                else
                {
                    coldifset[j].insert(N-1-i);
                }
            }
        }
    }

    for (int i = 0; i < N; ++i) {
        if(!rowdifset[i].empty())rowdif.insert(i);
        if(!coldifset[i].empty())coldif.insert(i);
    }
}

int main(void)
{
    cin >> C >> N;
    for(int i=0;i<N;i++)
    {
        cin >> board[i];
    }
    judge();
    if(rowdif.empty() && coldif.empty()) ans++;
    for(int i=0;i<C-1;i++)
    {
        int change;
        cin >> change;
        for(int j=0;j<change;j++)
        {
            int row,col;
            cin >> row >> col;
            row--,col--;
            int trow=row,tcol=col;
            if(row>=(N/2)) trow=N-1-row;
            if(col>=(N/2)) tcol=N-1-col;
            auto it=rowdifset[col].find(trow);
            if(it==rowdifset[col].end())
            {
                rowdifset[col].insert(trow);
                rowdif.insert(col);
            }
            else
            {
                rowdifset[col].erase(trow);
                if(rowdifset[col].empty())
                {
                    rowdif.erase(col);
                }
            }
            it=coldifset[row].find(tcol);
            if(it==coldifset[row].end())
            {
                coldifset[row].insert(tcol);
                coldif.insert(row);
            }
            else
            {
                coldifset[row].erase(tcol);
                if(coldifset[row].empty())
                {
                    coldif.erase(row);
                }
            }
        }
        if(rowdif.empty() && coldif.empty())
        {
            //cout << "Now Tile No. " << i+2 << endl;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 24192
#include <stdio.h>

int main(void)
{
    int N;
    char tmp[10];
    int AC=0, WA=0, TLE=0, RE=0;

    scanf("%d",&N);
    for(int i=0; i<N; i++){
        scanf("%s",tmp);
        if(tmp[0] == 'A') AC++;
        if(tmp[0] == 'W') WA++;
        if(tmp[0] == 'R') RE++;
        if(tmp[0] == 'T') TLE++;
    }

    printf("AC x %d\n",AC);
    printf("WA x %d\n",WA);
    printf("TLE x %d\n",TLE);
    printf("RE x %d\n",RE);

    return 0;
}

Measured memory_bytes: 1732
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        int candidate = Integer.MAX_VALUE;
        int totalTaste = 0;
        boolean isMinus = false;
        for(int i = 1; i <= n; i++) {
            int taste = l + i - 1;
            int a = Math.abs(0 - taste);
            if(a < candidate) {
                candidate = a;
                if (taste < 0) isMinus = true;
                else isMinus = false;
            }
                totalTaste += taste;
        }
        if(isMinus) {
            System.out.println(totalTaste + candidate);
        } else {
            System.out.println(totalTaste - candidate);
        }
    }
}


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

int main()
{
	int N,i;
	cin >>N;
	int H[N],ans = 1,maxh;
	for(i=0;i<N;i++){
		cin>> H[i];
	}
	maxh = H[0];
	for(i=1;i<N;i++){
		if(maxh<=H[i]){
			ans +=1;
			maxh =H[i];
		}
	}
	cout <<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <vector>
#include <cmath>
#include <ctime>        // time
#include <cstdlib>      // srand,rand
#include <fstream>
#include <string>
#include <sstream>      //文字ストリーム
#include <iterator>
#include <map>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <limits>
#include <typeinfo>

#include <stdio.h>
#include <string.h>


using namespace std;

int main(int argc, char* argv[])
{
	long long N,M;
	cin >> N >> M;
 
	vector<long long> a(M), b(M), c(M);
	for(int i=0;i<M;i++){
		cin >> a[i] >> b[i] >> c[i];
	}
 
	long long d[1010];
	d[0] = 0;
	for(int i=1;i<1010;i++){
		d[i] = -(1e17);
	} 
 
	long long  count = 0;
	long long temp;
 
	while (count < N*2+1) {
 
		if (count == N) {
			temp = d[N - 1];
		}
 
		for(int i=0;i<M;i++){
			d[b[i]-1] = max(d[b[i]-1], d[a[i]-1]+c[i]);
		}
 
		if (count == (N*2)) {
			break;
		}
		count++;
	}
 
	if (d[N - 1] > temp) {
		cout << "inf" << endl;
	}
	else {
		cout << d[N - 1] << endl;
	}
 
 
	return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
    int a;
    int b;
    int c;
 
   cin >> a >> b >> c;
  
   int ans = 0;
   for(int i=a;i>0;i--){
     
     if(b%i==0&&a%i==0){
     
       ans=ans+1;
       
       if(ans==c){
         
         cout << i << endl;
         break;
       }
       
       
     }
     
     
   }
    
  

  
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	sum := 0
	for i := 1; i <= n; i++ {
		for j := 1; j <= n; j++ {
			for k := 1; k <= n; k++ {
				sum += gcdWrapper(i, j, k)
			}
		}
	}
	fmt.Println(sum)
}

func gcdWrapper(a, b, c int) int {
	if a <= b && b <= c {
		return gcdBy3(a, b, c)
	} else if a <= c && c <= b {
		return gcdBy3(a, c, b)
	} else if b <= a && a <= c {
		return gcdBy3(b, a, c)
	} else if b <= c && c <= a {
		return gcdBy3(b, c, a)
	} else if c <= a && a <= b {
		return gcdBy3(c, a, b)
	}
	// else if c <= b && b <= a {
	return gcdBy3(c, b, a)
}

func gcdBy3(a, b, c int) int {
	abGcd := gcd(a, b)
	if abGcd < c {
		return gcd(abGcd, c)
	}
	return gcd(c, abGcd)
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 1848
#include<iostream>
using namespace std;
int main(){
    bool flag[8] = {};
    int N,v,a;
    int other = 0;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> a;
        for(int i=0;i<8;i++){
            if(a < 400*(i+1)){
                flag[i] = true;
                break;
            }
        }
        if(a >= 3200) other++;
    }
    v = 0;
    for(int i=0;i<8;i++){
        if(flag[i]) v++;
    }
    cout << max(v,1) << " " << v+other << endl;
    return 0;
}


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

int main()
{

    int t;
    t=1;
    while(t--)
    {
        string s;
        cin>>s;

        int cnt=0;
        int rans=0;

        for(int i=0;i<s.size();i=i+0)
        {
            if(s[i]=='R')
            {
                cnt=0;
                while(s[i]=='R')
                {
                    cnt++;
                    i++;
                }
                rans=max(rans,cnt);
            }
            else
            {
                i++;
            }

        }
        cout<<rans<<endl;
    }
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main() {
    long long int a, b, c, d;

    cin >> a >> b >> c >> d;
    long long int x[4];
    x[0] = a * c;
    x[1] = a * d;
    x[2] = b * c;
    x[3] = b * d;
    
    long long int max = x[0];
    for(int i = 1; i < 4; i++) {
        if(x[i] > max) {
            max = x[i];
        }
    }

    cout << max << endl;


}


Measured memory_bytes: 3188
# A
import datetime
s = str(input())

y = int(s[0:4])
m = int(s[5:7])
d = int(s[8:10])
date = datetime.date(y,m,d)
threshold_date = datetime.date(2019,4,30)
if date <= threshold_date:
    print('Heisei')
else:
    print('TBD')

Measured memory_bytes: 3440
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int n;
vector<int> a;

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

void solve() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int ans;
    for (int i = 0; i < n; ++i) {
        while(a[i] % 2 == 0) {
            a[i] /= 2;
            ans++;
        }
    }
    cout << ans << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}



Measured memory_bytes: 256
# そのまま入力文字列の入力
n = int(input())
bn = list(map(int, input().split()))

an = []

if n == 2:
    print(bn[0] * n)
    exit(0)

for i in range(0, n - 1 - 1):
    b = bn[i]
    if i == 0:
        an.append(bn[0])
    an.append(min(bn[i], bn[i+1]))

an.append(max(an[-1], bn[-1]))

print(sum(an))

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

func main() {
	var (
		s string
		k int
	)
	fmt.Scan(&s, &k)

	m := make(map[string]bool, len(s)*k)
	xs := make([]string, 0, len(m))
	for i := 1; i <= k; i++ {
		for j := 0; j+i <= len(s); j++ {
			w := s[j : j+i]
			if m[w] {
				continue
			}
			m[w] = true
			xs = append(xs, w)
		}
	}

	sort.Strings(xs)
	fmt.Println(xs[k-1])
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int modi = 1e9+7;


void solve(){

	string s;
	cin >> s;
	int n = s.length();
	if(s[n-1]=='s'){
		cout << s << "es" << endl;
	}
	else
		cout << s<< "s" << endl;

}


int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3680
n = int(input())
x = list(map(int,input().split()))
x_ = x.copy()
x_.sort()
l = x_[len(x)//2-1]
r = x_[len(x)//2]
for i in range(len(x)):
    if x[i]<=l:
        print(r)
    else:
        print(l)

Measured memory_bytes: 26352
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    string s, p;
    cin >> s >> p;
    s += s;
    cout << (s.find(p) != string::npos ? "Yes" : "No") << endl;
    return 0;
}




Measured memory_bytes: 3192
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

const long MOD = 10^^9 + 7;
const long INF = 1L << 59;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    s = readln.split.map!(to!int);
    auto S = s[0] - 1;
    auto T = s[1] - 1;
    auto G = new Tuple!(int, long)[][](N);

    foreach (_; 0..M) {
        s = readln.split.map!(to!int);
        int u = s[0] - 1;
        int v = s[1] - 1;
        long d = s[2].to!long;
        G[u] ~= tuple(v, d);
        G[v] ~= tuple(u, d);
    }


    void dijkstra(int start, long[] dist) {
        dist.fill(INF);
        auto pq = new BinaryHeap!(Array!(Tuple!(int, long)), "a[1] > b[1]");
        pq.insert(tuple(start, 0L));

        while (!pq.empty) {
            auto t = pq.front;
            pq.removeFront;
            auto u = t[0];
            auto d = t[1];
            if (d >= dist[u]) continue;
            dist[u] = d;
            foreach (tt; G[u]) {
                auto v = tt[0];
                auto c = tt[1];
                if (dist[v] < d + c) continue;
                pq.insert(tuple(v, d + c));
            }
        }
    }

    auto distS = new long[](N);
    auto distT = new long[](N);
    dijkstra(S, distS);
    dijkstra(T, distT);
    auto D = distS[T];


    void dpdp(int start, long[] dp, long[] dist1, long[] dist2) {
        dp[start] = 1;
        auto pq = new BinaryHeap!(Array!(Tuple!(int, long)), "a[1] > b[1]");
        pq.insert(tuple(start, 0L));
        auto used1 = new bool[](N);
        auto used2 = new bool[](N);

        while (!pq.empty) {
            auto tt = pq.front;
            pq.removeFront;
            auto u = tt[0];
            if (used1[u]) continue;
            used1[u] = true;
            foreach (t; G[u]) {
                int v = t[0];
                long d = t[1];
                if (!used1[v] && dist1[u] + d + dist2[v] == D) {
                    dp[v] += dp[u];
                    dp[v] %= MOD;
                    if (!used2[v]) pq.insert(tuple(v, dist1[v]));
                    used2[v] = true;
                }
            }
        }
    }

    auto dpS = new long[](N);
    auto dpT = new long[](N);
    dpdp(S, dpS, distS, distT);
    dpdp(T, dpT, distT, distS);

    long ans = dpS[T] * dpS[T] % MOD;

    if (D % 2 == 0) {
        foreach (i; 0..N) {
            if (distS[i] * 2 == D) {
                ans -= dpS[i] * dpT[i] % MOD * dpS[i] % MOD * dpT[i] % MOD;
                ans %= MOD;
            }
        }
    }


    foreach (u; 0..N) {
        if (distS[u] * 2 >= D) continue;
        foreach (e; G[u]) {
            auto v = e[0];
            auto d = e[1];
            if (distS[v] * 2 <= D) continue;
            if (distS[u] + d != distS[v]) continue;
            ans -= dpS[u] * dpT[v] % MOD * dpS[u] % MOD * dpT[v] % MOD;
            ans %= MOD;
        }
    }

    ans = (ans + MOD) % MOD;
    ans.writeln;
}


Measured memory_bytes: 34984
#include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
using namespace std;
int main(void){
    int sum,a,b,c,d;
    cin>>a>>b>>c>>d;
    sum=a+b+c+d;
    cin>>a>>b>>c>>d;
    if(sum>a+b+c+d)cout<<sum;
    else cout<<a+b+c+d;
    puts("");
    return 0;
}

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

int main(){
	int C,R,i,j,k,s=0,count=0,MAX=0,flag;
	cin >> R >> C;
	int O[10][10000];
	while(R!=0&&C!=0){
		for(i=0;i<R;i++){
			for(j=0;j<C;j++){
				cin >> O[i][j];
				if(O[i][j] == 0){MAX++;}
			}
		}
		k = pow(2,R);
		for(flag=0;flag<k;flag++){
			for(j=0;j<C;j++){
				for(i=0;i<R;i++){
					if((flag & (1 << i)) != 0){if(O[i][j]==1){s++;}}
					else if(O[i][j]==0){s++;}
				}
				if(s>(R-s)){count += s;}
				else{count += (R-s);}
				s=0;
			}
			if(count>MAX){MAX = count;}
			count = 0;
		}
		cout << MAX << endl;
		cin >> R >> C;
		MAX=0;
	}
	return 0;
}

Measured memory_bytes: 3568
n=int(input())
l,r=0,n
print(0,flush=True)
s=input()
sl,sr=s,s
if s!="Vacant":
  while True:
    m=(l+r)//2
    print(m,flush=True)
    sm=input()
    if sm==sl and (m-l)%2==0:
      l=m
      sl=sm
    elif sm!=sl and (m-l)%2!=0:
      l=m
      sl=sm
    else:
      r=m
      sr=sm

Measured memory_bytes: 3660
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    int N = readln.chomp.to!int;
    int[][] ary = new int[][](3, N);
    foreach(i; 0..N) {
        int[] input = readln.split.to!(int[]);
        foreach(j; 0..3) {
            ary[j][i] = input[j];
        }
    }
    foreach(i; 0..N) {
        int ans = 0;
        foreach(j; 0..3) {
            if (!(ary[j][0..i]~ary[j][i+1..$]).canFind(ary[j][i])) ans += ary[j][i];
        }
        ans.writeln;
    }
}

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

#define ll long long
#define ldb long double
#define rep(i, x, n, j) for(int i=x;i<(int)n;i+=j)
#define F first
#define S second
#define per(i, x, n, j) for(int i=(int)n-1;i>=0;i-=j)
#define all(v) v.begin(),v.end()
#define sz(a) (int)a.size()

const int N = 2000100;
const ll MOD = 1e9+7;
const ll inf = 1e18+5;

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

int _;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	char c; cin >> c;
	if(c>='a' && c<='z') cout << 'a' << endl;
	else cout << 'A' << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define INF 1000000000000
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
int n,p;
cin>>n>>p;
cout<<(n*3+p)/2<<endl;
return  0;
}






Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
    
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
    
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};



int main(){
    ll N, M; cin >> N >> M;
    UnionFind U(N);
    vector<PII> E(M);
    for(int i=0; i<M; i++){
        ll a, b; cin >> a >> b;
        a--; b--;
        E[i] = PII(a, b);
    }
    
    ll X = (N-1)*N/2;
    vector<ll> G(N);
    vector<ll> S(N, 1);
    vector<ll> Ans;
    
    for(ll i=M-1; i>=0; i--){
        Ans.push_back(X);
        ll a = E[i].first;
        ll b = E[i].second;
        if(U.root(a)!=U.root(b)){
            ll dec = S[U.root(a)]*S[U.root(b)];
            ll sze = S[U.root(a)] + S[U.root(b)];
            X -= dec;
            U.unite(a, b);
            S[U.root(a)] = sze;
        }
    }
    
    for(int i=M-1; i>=0; i--)
        cout << Ans[i] << endl;
    
    return 0;
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100+5;
const int maxw = 1e5+5;
long long dp[maxw];
int main(int argc, char const *argv[])
{
	int n, w;
	scanf("%d%d", &n, &w);
	
	memset(dp, 0, sizeof dp);
	int x, v;
	for(int i = 0; i < n; i++){
		scanf("%d%d", &x, &v);
		for(int j = w; j >= x; j--){
			dp[j] = max(dp[j], dp[j-x] + v);
		}
	}

	printf("%lld\n", dp[w]);
	return 0;
}

Measured memory_bytes: 4588
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<set>
#include<string>
#include<vector>

#include<stack>
#include<queue>
#include<utility>
#include<tuple>
#include<cstdio>
#include<cstdlib>
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(){
  int p,q,r;
  cin >> p >> q >> r;
  cout << p + q + r - max({p,q,r});
  return 0;
}


Measured memory_bytes: 256
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        
		
        String s=sc.next();
		int a=s.length();
  		String ans="";
  		
		for(int c=0;c<a;c++){
    		ans+="x";
    	}
    
 	

    	System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define  N 666666
vector<int> v1,v2,v3;
int dp[66];
string s;
int n;
int slove(char a,char b,char c){
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++){
		dp[3]=(dp[3]+(s[i]==c)*dp[2]);
        dp[2]=(dp[2]+(s[i]==b)*dp[1]);
        dp[1]=(dp[1]+(s[i]==a));
	}
	return dp[3];
}
signed main(){
	int ans=0;
	cin>>n>>s;
	ans+=slove('R','G','B')+slove('R','B','G');
	ans+=slove('B','R','G')+slove('B','G','R');
	ans+=slove('G','B','R')+slove('G','R','B');
	//cout<<ans<<'\n';
	for(int i=0;i<n;i++){
		for(int j=1;j<=n;j++){
			if(i-j>=0&&i+j<n){
				set<char> ss;
				ss.insert(s[i]);
				ss.insert(s[i-j]);
				ss.insert(s[i+j]);
				if(ss.size()==3) ans--;
			}else{
				break;
			}
		}
	}
	cout<<ans;
	return 0;
}

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

int w, h;
char a[50][50];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

tuple<int, int, int> dfs(int y, int x){
  if(a[y][x]=='.') a[y][x]='#';
  int res=1, wcnt=0, bcnt=0;
  int rest, bct, wct;

  rep(i,4){
    int nx = x+dx[i], ny = y+dy[i];

    if(0<=nx and nx<w and 0<=ny and ny<h and a[ny][nx]!='#'){
      if(a[ny][nx]=='.'){
        tie(wct, bct, rest) = dfs(ny, nx);
        wcnt += wct;
        bcnt += bct;
        res += rest;
      }
      else if(a[ny][nx]=='W') wcnt += 1;
      else if(a[ny][nx]=='B') bcnt += 1;
    }
  }
  return forward_as_tuple(wcnt, bcnt, res);
}

int main() {
  int wcnt, bcnt, res;
  while(true){
    cin>>w>>h;
    if(w==0) break;

    int bans=0, wans=0;

    rep(i,h)rep(j,w){
      cin>>a[i][j];
    }
    rep(i,h)rep(j,w){
      if(a[i][j]=='.'){
        tie(wcnt, bcnt, res) = dfs(i,j);
        //cout<<i<<" "<<j<<" "<<bcnt<<" "<<wcnt<<" "<<res<<" "<<endl;
        if(wcnt>0 and bcnt==0) wans += res;
        else if(wcnt==0 and bcnt>0) bans += res;
      }
    }
    cout<<bans<<" "<<wans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3248
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/*-------------ここまで---------------------------------------------*/
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b / a) << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int Mod = 1000000007;
int n,m,f[N],ans;
int main()
{
	cin>>n;
	m=(1ll*(n-1)*(n-1))%Mod;
	if(n>2) ans=m+2;
	else ans=m+1;
	int sum=f[0]=1;
	for(int i=1;i<n;i++)
	{
		f[i]=sum;
		if(i-2>=0) f[i]=(f[i]-f[i-2]+Mod)%Mod;
		sum=(sum+f[i])%Mod;
		if(i!=n-1) ans=(ans+1ll*f[i]*(m+min(i+2,n-1))%Mod)%Mod;
        else ans=(ans+1ll*f[i]*n%Mod)%Mod;
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)

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

   int n;
   cin >> n;
   cout << (n + 1)  / 2 << endl;
}

Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

//ordered_set s;

int n,mp[101010],m;
vi adj[101010];
vpi v;
int ans = 0;
set<int> s;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


    cin >> n >> m;
    for(int i=1;i<=n;i++){
        int x,y;
        cin >> x >> y;
        v.pb({y,x});
        adj[x].pb(y);
    }
    sort(all(v));
//
    for(int i=1;i<=m;i++)s.insert(i);
//
//    int cur = m;
//
//    for(int i=0;i<m;i++){
//        if(cur+i>m)cur--;
//        while(!adj[cur].size() && cur>0 )cur--;
//        cout << cur << endl;
//        if(cur){
//            ans+=adj[cur].back();
//            adj[cur].pop_back();
//        }
//    }


    for(int i=n-1;i>=0;i--){
        int x = v[i].fs;
        int y = v[i].sc;
        auto it = s.lower_bound( y );
        if(it==s.end())continue;
        s.erase(it);
        ans+=x;
    }

    cout << ans << endl;

return 0;
}
///....



Measured memory_bytes: 11760
# -*- coding: utf-8 -*-
S = list(map(int,list(input())))
#1010...か、0101...の2パターンしかないので、塗替え回数の少ない方を選択
lnS = len(S)
pt1 = [0,1] * (lnS // 2)
if lnS % 2==1:
    pt1.append(0)

dif_S_pt1 = sum(list(map(lambda x,y:abs(x-y),S,pt1)))
print(min([dif_S_pt1,lnS - dif_S_pt1]))


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plp;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e15+7;


vector<pair<ll,pll>> edge[55];
vector<pll> ch;
int main(){
	ios_base::sync_with_stdio(false);
	ll N, M, S, ans=0;

	cin >> N >> M >> S;
	rep(i,M) {
		ll u, v, A, B;
		cin >> u >> v >> A >> B;
		u--; v--;
		edge[u].emplace_back(v, pll(A, B));
		edge[v].emplace_back(u, pll(A, B));
	}
	rep(i,N) {
		ll C, D;
		cin >> C >> D;
		ch.emplace_back(C, D);
	}

	chmin<ll>(S, 2500);

	ll D[55][2505] = {};
	Fill(D, INF);
	D[0][S] = 0;
	rep(i,S) D[0][i] = 0;
	priority_queue<plp, vector<plp>, greater<plp>> que;
	que.emplace(0, pll(0,S));
	while(!que.empty()){
		ll d = que.top().X;
		ll n = que.top().Y.X;
		ll c = que.top().Y.Y;
		//cout << d << " " << n << " " << c << endl;
		que.pop();
		if(d > D[n][c]){
			continue;
		}
		for(auto p: edge[n]) rep(i,2501) if(p.Y.X <= c + i * ch[n].X){
			ll nn = p.X;
			ll s = c + i * ch[n].X - p.Y.X;
			ll sm = min<ll>(s,2500);
			ll nex = d + i * ch[n].Y;
			if(D[nn][sm] > nex + p.Y.Y){
				rep(k,sm+1) chmin(D[nn][k], nex + p.Y.Y);
				rep(k,sm+1) chmin(D[n][k], nex);
				que.emplace(nex + p.Y.Y, pll(nn, sm));
			}
			if(s >= 2500){
				break;
			}
		}
		// for(auto p: edge[n]) if(p.Y.X <= c){
		// 	ll s = c - p.Y.X;
		// 	ll nex = d + p.Y.Y;
		// 	if(D[n][s] > nex){
		// 		D[n][s] = nex;
		// 		que.emplace(nex, pll(n, s));
		// 	}
		// }
	}

	reps(i,1,N){
		ans = INF;
		rep(c,2501) chmin(ans, D[i][c]);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 16552
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long n = scanner.nextLong();
		scanner.close();

		long minCount = Long.MAX_VALUE;
		for(long i = 1; i * i <= n; i++) {
			if(n % i == 0) {
				long j = n / i;
				long k = (i + j-2);
				minCount = minCount > k ? k : minCount;
			}
		}
		System.out.println(minCount);
	}

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;

int main()
{
	sync;
	ll n,m;
	cin>>n>>m;
	priority_queue<ll>q;
	for(ll i=0;i<n;i++)
	{
		ll x;cin>>x;
		q.push(x);
	}
	while(m--)
	{
		ll x=q.top();
		q.pop();
		q.push(x/2);
	}
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		ll x=q.top();
		q.pop();
		ans+=x;
	}
	cout<<ans;
}

Measured memory_bytes: 1400
import java.util.*;
public class Main{
    
    static final int MOD = (int)1e9+7;
    static final int MAX = (int)1e6+1;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        HashMap<Integer, Integer> h = new HashMap<>();
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(sc.next());
            h.put(a[i], h.getOrDefault(a[i], 0)+1);
        }
        Arrays.sort(a);
        
        boolean[] prime = new boolean[MAX];
        Arrays.fill(prime, true);
        boolean pc = true;
        for(int i=2; i<MAX; i++){
            if(!prime[i]){
                continue;
            }
            int cnt = 0;
            for(int j=i; j<MAX; j+=i){
                prime[j] = false;
                cnt += h.getOrDefault(j, 0);
            }
            if(cnt > 1){
                pc = false;
            }
        }
        
        long gcd = a[0];
        for(int i=1; i<n; i++){
            gcd = gcd(a[i], gcd);
        }
        
        if(pc && gcd==1){
            System.out.println("pairwise coprime");
        }else if(gcd==1){
            System.out.println("setwise coprime");
        }else{
            System.out.println("not coprime");
        }
        
    }
    
    static long gcd (long a, long b){
        if(a < b){
            return gcd(b, a);
        }
        return b>0 ? gcd(b,a%b) : a;
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
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<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

constexpr int INF=1e9;
vi g[252521];
int d[252521];

void dfs(int s){
	for(auto x : g[s]){
		if(d[x]!=INF){
			continue;
		}
		d[x]=d[s]+1;
		dfs(x);
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, a, b;
	cin>>n;
	REP(i, n-1){
		cin>>a>>b;
		--a;
		--b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	REP(i, n){
		d[i]=INF;
	}
	d[0]=0;
	dfs(0);
	int ma=0, cand=0;
	REP(i, n){
		if(ma<d[i]){
			cand=i;
			ma=d[i];
		}
	}
	REP(i, n){
		d[i]=INF;
	}
	d[cand]=0;
	dfs(cand);
	int ans=0;
	REP(i, n){
		CHMAX(ans, d[i]);
	}
	cout<<(ans%3==1 ? "Second" : "First")<<'\n';
	return 0;
}


Measured memory_bytes: 19456
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;

    cin >> a ;
    b = 0;
 
    for (int i = 0; b != 1; i++) {

      b = 1;

      for  (int j = 2; j < a ; j++) {
        if ((a % j) == 0){
          b += 1;
        }
      }

      a = a + 1;

    }

    cout << (a - 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
ll d1[9] = {1, 1, 1, 0, 0, 0, -1, -1, -1};
ll d2[9] = {1, 0, -1, 1, 0, -1, 1, 0, -1};
 
int main(){
    ll H, W, N;
    cin >> H >> W >> N;
    vector<ll> ans(10, 0);
    ans[0] = (H - 2) * (W - 2);
    set<pair<ll, ll>> st;
    rep(i, 0, N){
        ll th, tw;
        cin >> th >> tw;
        rep(j, 0, 9){
            ll h = th + d1[j];
            ll w = tw + d2[j];
            if(h < 2 || h > H-1) continue;
            if(w < 2 || w > W-1) continue;
            ll cnt = 0;
            rep(i, 0, 9){
                ll nh = h + d1[i];
                ll nw = w + d2[i];
                if(st.count({nh, nw}) > 0) cnt++;
            }
            ans[cnt]--;
            ans[cnt+1]++;
        }
        st.insert({th, tw});
    }
    rep(i, 0, 10) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 6528
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var a = int.Parse(spl[0]);
        var b = int.Parse(spl[1]);
        var k = int.Parse(spl[2]);

        for(int i= Math.Min(a,b); i>=1; i--) {
            if(a % i==0 && b % i == 0) {
                k--;
                if (k == 0) return i;
            }
        }

        return 1;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#define WHITE 0    //non-visited
#define GRAY 1     //visited
#define BLACK 2    //finished
#define N 101

void DFS_Visit(int);

int n = 0;
int tt=0;
int color[N],d[N],f[N];
int A[N][N];

void DFS(void){
  int i;
  for(i=1 ; i<=n ; i++){
    color[i] = WHITE;
    tt = 0;
  }
  


  for(i=1 ; i<=n ; i++) if(color[i] == WHITE) DFS_Visit(i);
}

void DFS_Visit(int u){
  int i; 
  color[u] = GRAY;
  d[u] = ++tt;
  for(i=1 ; i<=n ; i++) if(color[i] == WHITE && A[u][i]) DFS_Visit(i);
  color[u] = BLACK;
  f[u] = ++tt;
}

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);


  for(i=1 ; i<=n ; i++){
    for(j=1 ; j<=n ; j++){
      A[i][j] = 0;
    }
  }

  for(i=1 ; i<=n ; i++){
    scanf("%d%d",&u,&k);
    for(j=1 ; j<=k ; j++){
      scanf("%d",&v);
      A[u][v] = 1;
    }
  }

  DFS();

  for(i=1 ; i<=n ; i++){
    printf("%d ",i);
    printf("%d ",d[i]);
    printf("%d\n",f[i]);
  }
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005



int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n,m;
        cin >> n >> m;
        int i,a[n+1];
        int j;
        map<int,vector<int>>mp;
        for(i=1; i<=n; i++){
            cin >> a[i];
        }
        for(i=1; i<=m; i++){
            int x,y;
            cin >>x >> y;
            mp[x].pb(y);
            mp[y].pb(x);
        }
        int ans=0;
        for(i=1; i<=n; i++){
            int w=1;
            for(auto j :mp[i]){
                if(a[j]>=a[i]){
                    w=0;
                    break;
                }
            }
            ans=ans+w;
        }
        cout << ans;
        

}


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



int main(){
    int k,x,roop;
    cin >> k >> x;
    roop=k*2-1;
    //vector<vector<int>> x(n, vector<int>(d));
    for(int i=0;i<roop;i++){
        k-=1;
        cout << x-k;
      	printf(" ");
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;

int solve() {
    int L =(int)s.size();
    if (L == 1) return 1;
    int l = L/2-1, r = (L+1)/2;
    int res = (L+1) / 2;
    char c = s[L/2];
    while (l >= 0) {
        if (c == s[l] && c == s[r]) {
            res++;
            l--;
            r++;
        } else {
            break;
        }
    }
    return res;
}

void input() {
    cin >> s;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int[] arr = new int[N+1];
		int[] ar = new int[N+1];
		for(int i=1; i<=N; i++) {
			arr[i] = sc.nextInt();
			ar[i] = arr[i];
		}
		Arrays.sort(ar);
		for(int i=1; i<=N; i++) {
			
			if(arr[i] >= ar[N/2+1]) {
				System.out.println(ar[N/2]);
			} else {
				System.out.println(ar[N/2+1]);
			}
		}
		
				

	}

}


Measured memory_bytes: 65788
count_al = list(0 for i in range(26))
while True :
    try :
        a = str(input())
        b = a.lower()
        for i in range(len(b)) :
            c = ord(b[i])
            if c > 96 and c < 123 :
                count_al[c - 97] += 1
    except EOFError :
        break
    
for i in range(97, 123) :
    print(chr(i), ":", count_al[i-97])


Measured memory_bytes: 5564
#include <bits/stdc++.h>
#define ll long long
#define uint unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int n, m, ans[110][110];

int main()
{
    n = read();
    m = read();
    int p = read();
    int x = 1, y = 1, flag = 1;
    rep(i, 1, p)
    {
    	int now = read();
    	while(now --)
    	{
    		ans[x][y] = i;
    		y += flag;
    		if(y > m) y = m, x ++, flag = -1;
    		if(y == 0) y = 1, x ++, flag = 1;
    	}
    }
    rep(i, 1, n)
    {
    	rep(j, 1, m)
    		cout << ans[i][j] << " ";
    	puts("");
    }
	return 0;
}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int a[] = new int[N];

		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}

		int max = a[0];
		int min = a[0];

		for (int i = 0; i < a.length; i++) {
			int tmp = a[i];
			if(tmp > max) {
				max = tmp;
				continue;
			}
			if(tmp < min) {
				min = tmp;
				continue;
			}
		}
		System.out.println(max - min);
	}

}


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

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// view vector
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

// ***************************************

vector<set<ll>> num(26, set<ll>({1<<30}));
vector<char> S(5e5);

int cnt() {
	int l, r;
	cin >> l >> r; l--;

	int ret = 0;
	REP(i, 26) {
		if (num[i].empty()) continue;
		auto a = *num[i].lower_bound(l);
		auto b = *num[i].lower_bound(r);
		if (b > a) ret++;
	}

	return ret;
}

int main(){
	int N, Q;
	string tmp;
	cin >> N >> tmp >> Q;
	REP(i, N) {
		S[i] = tmp[i];
	}

	REP(i, N) {
		num[S[i] - 'a'].insert(i);
	}

	int q;
	REP(i, Q) {
		cin >> q;
		if (q == 1) {
			int idx;
			char c;
			cin >> idx >> c; idx--;
			if (S[idx] == c) continue;

			num[S[idx] - 'a'].erase(idx);
			num[c - 'a'].insert(idx);
			S[idx] = c;
		}
		else {
			cout << cnt() << endl;
		}
	}


	return 0;
}

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

int main(){
	int N;
	cin >> N;
	int L[2*N];
	for(int i=0; i<2*N; i++) cin >> L[i];
	sort(L, L+2*N);
	int ans = 0;
	for(int i=0; i<2*N; i=i+2){
		ans += L[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256