akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;
#define PI 3.14159265358979323846264338327950L
const int mod =  998244353;



#define SIZE 200005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

struct BIT{
	int bit[SIZE];
	
	void init(){memset(bit,0,sizeof(bit));}
    
	void add(int k,int x) {
		k++;
		while(k<SIZE){
			bit[k]+=x;
			k+=k&-k;
		}
	}
	int get(int k){
		k++;
		int ret=0;
		while(k>0){
			ret+=bit[k];
			k-=k&-k;
		}
		return ret;
	}
    
	int get(int s,int t){
		return get(t)-get(s-1);
	}
    
	int pos(int k){ //k番目
		int l=0,r=SIZE;
		while(r-l>1)
		{
			int m=(l+r)/2;
			if(get(m)<k) l=m;
			else r=m;
		}
		return r;
	}
};


BIT bit;




void solve(){
    ll a,v;
    ll b,w;
    ll t;
    cin >> a >> v >> b >> w >> t;
    ll d = abs(a-b);
    if (d == 0){
        cout <<"YES";
        return;
    }
    if (d!=0 && v <= w){
        cout << "NO";
        return;
    }
    
    if (t*(v-w) >= d){
        cout <<"YES";
        return;
    }
    else{
        cout <<"NO";
        return;
    }
    

}


int main(){
    int T;
    T = 1;
    while(T--){
        solve();
        cout << endl;
    }
}


Measured memory_bytes: 3640
#include <iostream>
#include<map>
#include<string>

using namespace std;

int main() {
	int n;
	int num;
	long int min = 10000000, max = -10000000, sum = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> num;
		if (num < min)min = num;
		if (num > max)max = num;
		sum += num;
	}
	cout << min << " " << max << " " << sum << endl;

	return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define in(x) scanf("%d",&x)
#define inn(x,y) scanf("%d%d",&x,&y)
#define innn(x,y,z) scanf("%d%d%d",&x,&y,&z)

using namespace std;
const int N=2e6+5;
const int mod=1e9+7;

int ar[N];

int main(){
    int n,m,h;
    cin>>n>>m;
    for(int i=0;i<n;i++) cin>>ar[i];
    sort(ar,ar+n);
    ll sum=0;
    for(int i=0;i<n-m;i++) sum+=ar[i];
    cout<<sum;
    return 0;
}

Measured memory_bytes: 1024
import sys
if __name__ == '__main__':
    a = [0]*101
    for tmp_line in sys.stdin:
        n = (int)(tmp_line)
        a[n-1] += 1
    b = [i+1 for i,x in enumerate(a) if x == max(a)]
    b.sort()
    for x in b:
        print(x)

Measured memory_bytes: 5600
#include <iostream>

using namespace std;

int main()
{
	const int comb[] = { 0, 1, 2, 4, 7, 13, 24, 44, 81, 149, 274, 504, 927, 1705, 3136, 5768, 10609, 19513, 35890, 66012, 121415, 223317, 410744, 755476, 1389537, 2555757, 4700770, 8646064, 15902591, 29249425, 53798080 };

//	cut here before submit 
//	freopen ("testcase.kannondou", "r", stdin );
	int n;

	while (1){
		cin >> n;

		if (n == 0 ){
			break;
		} // end if
		int num = comb[n];

		if (num >= 10 ){
			num = (num / 10) + (num % 10 != 0 ? 1 : 0 );
		} // end if

		int res = num/365 + (num % 365 != 0 ? 1 : 0 );
		cout << res << endl;
	} // end loop

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long
#define BS 50
signed main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(auto& i:a)cin>>i;
  vector<int> bit(BS,0);
  for(int i=0;i<n;++i){
    int t=a[i];
    for(int j=0;t>0;++j,t>>=1)bit[j]+=t&1;
  }
  vector<bool> suit(BS,false),lim(suit);
  for(int i=0;i<BS;++i)if(bit[i]*2<n)suit[i]=true;
  for(int i=0,t=k;t>0;++i,t>>=1)lim[i]=t&1;
  auto f=[&](vector<bool>& v,vector<int>& a){
    int x=0,sum=0;
    for(int i=BS-1;i>0;--i,x<<=1,x+=v[i]);
    for(auto& i:a)sum+=(i^x);
    return sum;
  };
  int ans=0;
  for(int i=0;i<BS;++i){
    int j=BS-1-i;
    if(suit[j]&&lim[j]){
      suit[j]=false;
      ans=max(ans,f(suit,a));
      suit[j]=true;
    }
    if(lim[j]&&!suit[j])break;
    if(!lim[j]&&suit[j])suit[j]=false;
  }
  cout<<max(ans,f(suit,a))<<endl;
}

Measured memory_bytes: 1024
import sys
#input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations
#from itertools import accumulate, product
from bisect import bisect_left,bisect_right
from math import floor, ceil
#from operator import itemgetter

#mod = 1000000007

n, m = map(int, input().split())

res = [0]*n

l = [list(map(int, input().split())) for _ in range(m)]


for i in range(m-1):
    for j in range(i+1, m):
        if l[i][0]==l[j][0] and l[i][1]!= l[j][1]:
            print(-1)
            exit()

for x,y in l:
    if x==1 and y==0 and n!=1:
        print(-1)
        exit()

if m==0:
    if n==1:
        print(0)
        exit()
    if n==2:
        print(10)
        exit()
    if n==3:
        print(100)
        exit()


for x,y in l:
    res[x-1] = y

if n==3:
    if res[0]==0:
        res[0]=1
if n==2:
    if res[0]==0:
        res[0]=1
res = list(map(str, res))
print(''.join(res))





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

int abs(int a)
{
	return a>0?a:-a;
}

int main()
{
	int N;
	cin>>N;
	int a;
	int b;
	
	cin>>a>>b;
	int max = abs(a-b);
	
	for(int i = 3;i <= N;i++)
	{
		int c;
		cin>>c;
		
		int d = abs(a-c);
		int e = abs(b-c);

		if(d > e && d > max)
		{
			b = c;
			max = d;
		}
		
		else if(d < e && e > max)
		{
			a = c;
			max = e;
		}
	}
	
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String s = r.readLine();
		String[] parts = s.split(" ");
		int K = Integer.parseInt(parts[0]);
		int T = Integer.parseInt(parts[1]);
		s = r.readLine();
		parts = s.split(" ");
		int max = 0;
		for (int i = 0; i < T; i++) {
			int curr = Integer.parseInt(parts[i]);
			if (curr > max) {
				max = curr;
			}
		}
		boolean pre = false;
		int count = K - max;
		for (int i = 0; i < K; i++) {
			if (!pre && max > 0) {
				max--;
				pre = true;
			} else if (count > 0){
				pre = false;
				count--;
			}
		}
		System.out.println(max);
	}

}


Measured memory_bytes: 7892
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,x;
  cin >> n >> x;
  vi check(2*n+1,0);
  if(x >= 2 and x<=2*n-2){
    cout<<"Yes"<<endl;
    vi ans;
    int a = 1;
    check[x] = 1;
    check[x-1] = 1;
    check[x+1] = 1;
    rep(i,n-2){
      while(check[a]) a++;
      ans.push_back(a);
      check[a] = 1;
    }
    ans.push_back(x-1);
    ans.push_back(x);
    ans.push_back(x+1);
    rep(i,n-2){
      while(check[a]) a++;
      ans.push_back(a);
      check[a] = 1;
    }
    rep(i,sz(ans)){
      cout<<ans[i]<<endl;
    }
  }
  else cout<<"No"<<endl;
  return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long N, long long M){

    lli ans = min(N,M/2);
    N-=ans;
    M-=ans*2;

    ans += M/4;

    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    func(N, M);
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"log"
)

func main() {
	var length int
	if n, err := fmt.Scanf("%d", &length); n != 1 || err != nil {
		log.Fatalln(n, err)
	}

	array := make([]int, length)
	for i := 0; i < length; i++ {
		if n, err := fmt.Scanf("%d", &array[i]); n != 1 || err != nil {
			log.Fatalln(n, err)
		}
	}

	count := selectionSort(array, length)
	printArray(array, length)
	fmt.Println(count)
}

func selectionSort(array []int, length int) int {
	count := 0
	for i := 0; i < length-1; i++ {
		min := i
		for j := i + 1; j < length; j++ {
			if array[min] > array[j] {
				min = j
			}
		}
		if min != i {
			array[i], array[min] = array[min], array[i]
			count++
		}
	}

	return count
}

func printArray(array []int, length int) {
	fmt.Print(array[0])
	for i := 1; i < length; i++ {
		fmt.Printf(" %d", array[i])
	}
	fmt.Print("\n")
}


Measured memory_bytes: 1224
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;
#define BUF (1000)

int n;
char st[51];
void input(void){
	cin >> st;
}

int main(void){
	input();
	int l = strlen(st);
	st[l-8]=0;
	cout << st <<endl;	
}


Measured memory_bytes: 256
import java.io.*;
import  java.util.*;

import static java.lang.System.in;

class Main{
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(), K=sc.nextInt();
        System.out.println(help(N,K));
    }
    static long help(int N, int K){
        if(K==0) return ((long) N)*((long) N);
        long ans = 0;
        for(int a=K;a<=N;a++) ans += N-a;
        for(int b=K+1;b<N;b++){
            int x0 = N/b;
            ans += (x0-1)*(b-K);
            ans += Math.max(0,N-x0*b-K+1);
        }
        return ans;
    }
}


Measured memory_bytes: 22612
package main
import (
        "bufio"
        "fmt"
        "os"
        "strings"
        "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func Atoi2(c string) int {
  tmp, _ := strconv.Atoi(c)
  return tmp
}

func main() {
	input := nextLine()
	rec := strings.Split(input, " ")
	var hoge []int
  var output string

	for _, c := range rec{
		hoge = append(hoge, Atoi2(c))
	}

  if hoge[0] < hoge[1] && hoge[1] < hoge[2]{
    output = "Yes"
  }else{
    output = "No"
  }

	fmt.Println(output)
}


Measured memory_bytes: 1076
<?php
$map = array_fill(0,100001,1);
$map[1] = 0;
for($i = 1; $i <= 3200; $i++){
  if($map[$i] == 1){
    for($j = 2; $i * $j < 100000; $j++){
      $map[$i*$j] = 0;
    }
  }
}
$sum[-1] = 0;
for($i = 1; $i < 100000; $i+=2){
  $sum[$i] = $sum[$i-2] + $map[$i]*$map[($i+1)/2];
}
$Q = intval(fgets(STDIN));
for($i = 0; $i < $Q; $i++){
  fscanf(STDIN, "%d%d", $l, $r);
  $result[] = $sum[$r]-$sum[$l-2];
}
echo implode("\n", $result),"\n";



Measured memory_bytes: 19064
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
using namespace std;

int main()
{
    ll n,x,i,j;
    cin>>n;
    bool ok=1;
    for( i=0; i<n; i++)
    {
        cin>>x;
        if(x%2==0)
        if(x%3&&x%5){
            ok=0;
        }
    }
    if(ok)
        cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;

    return 0;
}





Measured memory_bytes: 3612
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]
e = [[] for i in range(N)]
for i in range(M):
    e[AB[i][0]-1].append(AB[i][1]-1)
    e[AB[i][1]-1].append(AB[i][0]-1)
ans = 0
for i in range(N):
    if len(e[i]) == 0:
        ans += 1
        continue
    h = H[i]
    f = False
    for j in e[i]:
        if h <= H[j]:
            f = True
    if not f:
        ans += 1
print(ans)
    

Measured memory_bytes: 47596
#include <iostream>
#include <algorithm>
#include <climits>

int n;
int a[102][102];

int main(){
	std::cin >> n;
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			std::cin >> a[i][j];
	
	for(int i = 1; i <= n; i++)
		for(int j = 2; j <= n; j++)
			a[i][j] += a[i][j - 1];
	
	for(int i = 1; i <= n; i++)
		for(int j = 2; j <= n; j++)
			a[j][i] += a[j - 1][i];
			
			
	int ans = INT_MIN;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			for(int k = i; k <= n; k++){
				for(int l = j; l <= n; l++){
					ans = std::max(ans, a[k][l] - a[i - 1][l] - a[k][j - 1] + a[i - 1][j - 1]);
				}
			}
		}
	}
	
	std::cout << ans << std::endl;
	
	return 0;
}

Measured memory_bytes: 1204
#include<stdio.h>

void trace(int A[],int N){
    int i;
    for(i=0;i<N;i++){
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

void insertionSort(int A[],int N){
    int i,j,v;
    for(i=1;i<N;i++){
        v=A[i];
        j=i-1;
        while(j>=0 && A[j] > v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }
}

int main(){
    int N, i;
    int A[100];
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    trace(A,N);
    insertionSort(A,N);
    return 0;
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout<<fixed;

    int n, k;
    cin>>n>>k;
    map<int, int> m;
    for(int i=0; i<k; ++i) {
      int d;
      cin>>d;
      for(int j=0; j<d; ++j) {
	int x;
	cin>>x;
	m[x]++;
      } 
    }
    int ans=0;
    for(int i=1; i<=n; ++i) {
      if(m[i]==0) ans++;
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int
#define modm 1000000007




static int x = []() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  return 0;
}();




int main()
{

    ll t ;
    cin>>t;
    if(t%10==7)
    {

        cout<<"Yes"<<endl ;
        return 0 ;
    }
    t=t/10 ;
    if(t%10==7)
    {

        cout<<"Yes"<<endl ;
        return 0 ;
    }

    t=t/10 ;
    if(t%10==7)
    {

        cout<<"Yes"<<endl ;
        return 0 ;
    }

    cout<< "No"<<endl ;

    return 0 ;
}


Measured memory_bytes: 3668
n=int(input())
s=list(input())

rn=s.count('R')
gn=s.count('G')
bn=n-rn-gn

ans=bn*gn*rn
if n>2:
  
  for x in range(n-2):
    
    y=(n-1-x)//2
    for i in range(1,y+1):
      if  (not s[x]==s[x+i]) & (not s[x]==s[x+i+i]) & (not s[x+i]==s[x+i+i]):
        ans-=1
        
  print(ans)
    
else:
  print(0)


Measured memory_bytes: 73516
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
 
using namespace std;
 
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
 
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}


#define left left228
#define right right228
#define prev prev228
#define mp make_pair
#define all(v) v.begin(), v.end()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define firn(i, n) for (int i = 1; i < (int)n; ++i)
#define x first
#define y second

const int N = 100 * 1000 + 228;

int n;
int a[N];
int dp[N];
int leftinc[N], leftdec[N];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        leftinc[i] = leftdec[i] = i;
        if (a[i - 1] <= a[i] && i - 1) leftdec[i] = leftdec[i - 1];
        if (a[i - 1] >= a[i] && i - 1) leftinc[i] = leftinc[i - 1];
    }
    for (int i = 1; i <= n; ++i) {
        dp[i] = min(dp[leftdec[i] - 1], dp[leftinc[i] - 1]) + 1;
    }
    cout << dp[n] << endl;
    return 0;
}
 
/*



3
0 1
-2 3
2 2

3
0 1
-2 2
2 2

*/

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N; cin >> N;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  ll M; cin >> M;
  vector<ll> b(M);
  rep(i,M) cin >> b[i];

  map<ll,ll> m;
  rep(i, (1 << N)){
    ll tmp = 0;
    rep(j,N){
      if( (i >> j) % 2 ){
        tmp += a[j];
      }
    }
    // cout << tmp << endl;
    m[tmp]++;
  }

  rep(i,M){
    if(m[b[i]]) cout << "yes" <<endl;
    else cout << "no" << endl;
  }
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define debug(x) cerr<<#x<<":"<<x<<endl;

int n, init;
vector<int> state[303];

bool visited[303];
void dfs(const int x){
  stack<int> st;
  st.push(x);
  
  while(!st.empty()) {
    int fr = st.top(); st.pop();
    state[init].emplace_back(fr);
    for(auto&& to: state[fr]){
      if(visited[to]) continue;
      visited[to] = true;
      st.push(to);
    }
  }
}

void check(){
  for(int i=0;i<n;++i){
    // initialize
    fill_n(visited, n, false);
    init = i;
    
    // dfs
    dfs(i);
    dfs(i);
    
    // compress the data
    sort(state[i].begin(), state[i].end());
    state[i].erase(unique(state[i].begin(), state[i].end()), state[i].end());
  }
}

signed main() {
  int m;cin>>n>>m;

  // add direct-path to myself
  for(int i=0;i<n;++i){
    state[i].emplace_back(i);
  }

  // add direct-path
  for(int i=0;i<m;++i){
    int a,b;cin>>a>>b;
    --a; --b;
    state[a].emplace_back(b);
  }

  // dfs from all points
  check();
  check();

  for(int i=0;i<n;++i){
    bool isFirst = true;
    for(int j=0;j<n;++j){
      if(binary_search(state[i].begin(), state[i].end(), j) &&
         binary_search(state[j].begin(), state[j].end(), i)) {
        if (!isFirst) cout<<" ";
        cout<<j+1;
        isFirst = false;
      }
    }
    cout<<endl;
  }
  return 0;
}



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

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

int main(){
    long long a,b,n,x;
    cin >> n >> a >> b;
    if(n%(a+b)<=a) cout  << ((n/(a+b))*a)+(n%(a+b)) << endl;
    else cout << ((n/(a+b))*a)+a << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n, m;
    ll a[60], b[60], c[60], d[60];
    cin >> n >> m;
    imfor(i, n) {
        cin >> a[i] >> b[i];
    }
    imfor(i, m) {
        cin >> c[i] >> d[i];
    }
    imfor(i, n) {
        int ans = -1;
        ll mind = 9999999999;
        imfor(j, m) {
            if ((abs(a[i] - c[j]) + abs(b[i] - d[j])) < mind) {
                mind = (abs(a[i] - c[j]) + abs(b[i] - d[j]));
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
        int a,b,c,x;
        scanf("%d",&a);
        scanf("%d",&b);
        scanf("%d",&c);
        scanf("%d",&x);
        int count=0;
        for (int i=0;i<=a;i++){
                for (int j=0;j<=b;j++){
                        for (int k=0;k<=c;k++){
                                if((500*i+100*j+50*k)==x){
                                        count++;
                                }
                        }
                }
        }
        printf("%d",count);
        return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
bool ok(long long x) {
  map<long long, long long> fac;
  for (long long i = 2; i <= x; i++) {
    while (x % i == 0) {
      fac[i]++;
      x /= i;
    }
  }
  if (x > 1) fac[x]++;
  for (auto i : fac) {
    if (i.first % 4 != 3) continue;
    if (i.second % 2 == 1) return true;
  }
  return false;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  long long s = n * n + m * m;
  //cerr << s << endl;
  for (long long i = 2; i * i <= s; i++) {
    if (s % i == 0) {
      //cerr << i << " " << s / i << endl;
      //cerr << ok(i) << " " << ok(s / i) << endl;
      if (ok(i) && ok(s / i)) continue;
      cout << "C" << '\n';
      return;
    }
  }
  cout << "P" << '\n';
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int q;
  cin >> q;
  while (q--) solve();
  return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int N;
string S;
vector<int> W(300001, 0);
vector<int> E(300001, 0);

int main(void){
    
    cin >> N >> S;
    
    int e_sum = 0, w_sum = 0;
    for(int i = 0; i < N; ++i){
        if(S[i] == 'W') ++w_sum;
        else ++e_sum;
        W[i] = w_sum;
        E[i] = e_sum;
    }
    
    int ans = INT_MAX;
    for(int i = 0; i < N; ++i){
        if(i) ans = min(ans, E[N - 1] - E[i] + W[i - 1]);
        else ans = min(ans, E[N - 1] - E[i]);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 1000
using namespace std;
int main() {
  int a, n;
  vector<int> v;
  cin >> n;
  while(n--) {
    cin >> a;
    v.push_back(a);
  }
  int cnt = 0;
  bool swap = false;
  for (int i = 0; i < v.size(); i++) {
    if (swap) {
      swap = false;
      continue;
    }
    if (i + 1 == v[i]) {
      cnt++;
      swap = true;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define ALPHABET 26
using namespace std;
int main() {
  string w;
  vector<int> W(ALPHABET);
  cin >> w;
  for (char c : w) {
    W[c-'a']++;
    W[c-'a'] %= 2;
  }
  if (count(W.begin(),W.end(),0) == ALPHABET) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int NextPow2(int x)
{
	x--;
	for(int i=1;i<32;i*=2) x|=x>>i;
	return x+1;
}
const int I=numeric_limits<int>::max();
int F(int a,int b){return min(a,b);}

struct SegmentTree{
	int size;
	vi data,index;
	SegmentTree(int n):size(NextPow2(n)),data(size,I),index(size*2){
		iota(size+all(index),0);
		peri(i,1,size) index[i]=index[i*2];
	}
	SegmentTree(const vi& a):size(NextPow2(a.size())),data(size,I),index(size*2){
		copy(all(a),begin(data));
		iota(size+all(index),0);
		peri(i,1,size){
			int u=index[i*2],v=index[i*2+1];
			index[i]=data[u]==F(data[u],data[v])?u:v;
		}
	}
	void Update(int i,int x){
		data[i]=x;
		for(i+=size;i/=2;){
			int u=index[i*2],v=index[i*2+1];
			index[i]=data[u]==F(data[u],data[v])?u:v;
		}
	}
	int QueryIndex(int a,int b,int i,int l,int r){
		if(b<=l || r<=a) return -1;
		if(a<=l && r<=b) return index[i];
		int u=QueryIndex(a,b,i*2,l,(l+r)/2),v=QueryIndex(a,b,i*2+1,(l+r)/2,r);
		if(u==-1 || v==-1) return u!=-1?u:v;
		return data[u]==F(data[u],data[v])?u:v;
	}
	int QueryIndex(int a,int b){
		return QueryIndex(a,b,1,0,size);
	}
};

int main()
{
	for(int n,q;cin>>n>>q && n|q;){
		SegmentTree st(n);
		rep(_,q){
			int t; cin>>t;
			if(t==0){ // update
				int i,x; cin>>i>>x;
				st.Update(i,x);
			}
			else{     // query
				int a,b; cin>>a>>b; b++;
				cout<<st.data[st.QueryIndex(a,b)]<<endl;
			}
		}
	}
}

Measured memory_bytes: 2580
#include<stdio.h>

#define INFTY 2000000000

long long count = 0;

void merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1], R[n2+1];
  for (int i = 0; i < n1; i++) L[i] = A[left + i];
  for (int i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1] = INFTY;
  R[n2] = INFTY;
  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      count += n1 - i;
      j++;
    }
  }
}

void mergeSort(int A[], int left, int right) {
  if (left+1 < right) {
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
	int n;
  scanf("%d", &n);
  int S[n];
  for ( int i = 0; i < n; i++ ) scanf("%d", &S[i]);
  mergeSort(S, 0, n);
  printf("%llu\n", count);

  return 0;
}



Measured memory_bytes: 4248
N,K = (int(i) for i in input().split()) 
A = [int(i) for i in input().split()] 
A_done = [0]*N
A_route = []
point = 1
end_point = 0
while A_done[point-1]==0:
  A_done[point-1] = 1
  A_route.append(point)
  point = A[point-1]
  if A_done[point-1]==1:
    end_point = point
cal = K%len(A_route)
roop = A_route.index(end_point)
f_len = len(A_route[:roop])
roop_len = len(A_route[roop:])
A_roop = A_route[roop:]
if K >= f_len + roop_len:
  cal = (K-f_len)%(len(A_roop))
  #print(cal)
  print(A_roop[cal])
else:
  print(A_route[K])

Measured memory_bytes: 32312
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int read(){
    int f=1,x=0;
    char ch;
    do{ch=getchar();if(ch=='0')f=-1;}while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
    return f*x;
}

string s[10001];
int n,l;
int main(){
    n=read();
    l=read();
    for(int i=1; i<=n; i++)
    cin>>s[i];
    sort(s+1,s+n+1);
    for(int i=1; i<=n; i++)
    cout<<s[i];
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int Q = sc.nextInt();
        int a[][] = new int[N+1][N+1];
        for (int i = 1; i <= M; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            a[l][r] += 1;
        }
        for (int i = 1; i <= N; i++) {
            int s = 0;
            for (int j = 1; j <= N; j++) {
                s += a[i][j];
                a[i][j] = s;
            }
        }
        for (int i = 1; i <= N; i++) {
            int s = 0;
            for (int j = 1; j <= N; j++) {
                s += a[j][i];
                a[j][i] = s;
            }
        }
        for (int i = 1; i <= Q; i++) {
            int p = sc.nextInt();
            int q = sc.nextInt();
            System.out.println(a[q][q] - a[p-1][q] - a[q][p-1] + a[p-1][p-1]);
        }
    }
}


Measured memory_bytes: 156100
from collections import Counter
moji = str(input())
guall = len(moji)//2
kiall = guall + len(moji) % 2
gucount=dict(Counter(moji[1::2]))
kicount=dict(Counter(moji[0::2]))
if len(moji) == 1:
    ans = 0
elif max(gucount, key=gucount.get) != max(kicount, key=kicount.get):
    ans = guall - max(gucount.values()) + kiall - max(kicount.values())
else:
    if kiall - max(kicount.values()) > guall - max(gucount.values()):
        ans = max(kicount.values()) + guall - max(gucount.values())
    else:
        ans = max(gucount.values()) + kiall - max(kicount.values())
print(ans)

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

using namespace std;
typedef unsigned int ui;
//using ui = unsigned int;

int main(void)
{
  string line;
  ui max_n, max_w;
  cin >> max_n >> max_w;
  ui v, w;

  vector<ui> table(max_w+1, 0);

  for(int i = 1; i <= max_n; ++i){
    cin >> v >> w;
    if(w <= max_w && table[w] < v)
      table[w] = v;
    for(int j = 1; j <= max_w - w; j++){
      if(table[j] != 0 && table[w+j] < table[j] + v)
        table[w+j] = table[j] + v;
    }
  }
  cout << *(max_element(begin(table), end(table))) << endl;

  return 0;

}

Measured memory_bytes: 3124
import java.util.*;

public class Main {
    
    static int MOD = (int) 1e9 + 7;
    
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        long[] dp = new long[N+1];
        int[] a = new int[M];
        for(int i = 0; i < M; i++){
            a[i] = sc.nextInt();
            dp[a[i]] = -1;
            if( (i > 0) && (a[i-1] + 1 == a[i]) ){
                System.out.println(0);
                return;
            }
        }
        
        dp[0] = 1;
        if( dp[1] != -1 ) dp[1] = 1;
        
        for(int i = 2; i <= N; i++){
            if(dp[i] == -1) continue;
            if(dp[i-2] != -1 ) dp[i] = (dp[i] + dp[i-2]) % MOD;
            if(dp[i-1] != -1 ) dp[i] = (dp[i] + dp[i-1]) % MOD;
        }
        
        System.out.println(dp[N]);
        
    }
}


Measured memory_bytes: 48476
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var dict = new Dictionary<long, long>();

            foreach (var a in A)
            {
                if (dict.ContainsKey(a))
                    dict[a]++;
                else
                    dict[a] = 1;
            }

            var count = 0;
            var firstVal = 0L;
            foreach (var d in dict.OrderByDescending(z => z.Key))
            {
                if (d.Value >= 2)
                {
                    count++;
                    if (count == 1)
                        firstVal = d.Key;
                    else
                    {
                        Console.WriteLine(d.Key * firstVal);
                        return;
                    }
                }
                if (d.Value >= 4)
                {
                    Console.WriteLine(d.Key * d.Key);
                    return;
                }
            }
            Console.WriteLine(0);
        }
    }
}


Measured memory_bytes: 27232
#include <stdio.h>


int main(void) {

	// 1_3-A Print Many Hello World

	int a,b,c;
	int i,ans = 0;
	scanf("%d %d %d",&a,&b,&c);

	for(i=1; i<=c; i++){
		if(c%i==0){
			if(a<=i && i<=b){
				ans++;
			}
		}
	}
	printf("%d\n",ans);
        return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

vi G[100010];
int ind[100010];

int main()
{
    int n = in();
    int m = in();

    rep(i, m) {
        int a = in() - 1, b = in() - 1;
        G[a].PB(b);
        ind[b]++;
    }

    bool f = false;

    vi ans;

    queue<int> q;
    rep(i, n) if (ind[i] == 0) {
        ans.PB(i);
        q.push(i);
    }

    while (q.size()) {
        f |= q.size() > 1;

        int v = q.front(); q.pop();

        int cnt = 0;

        for (int u : G[v]) {
            ind[u]--;

            if (ind[u] == 0) {
                q.push(u);
                ans.PB(u);
                cnt++;
            }
        }
    }

    for (int v : ans) printf("%d\n", v+1);
    printf("%d\n", f);
}

Measured memory_bytes: 6116
//by tzupengwang™
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

int n , k , l ;
map< ii , int > mp ;
vector< int > v1[ 200005 ] , v2[ 200005 ] ;

void init() {
  scanf( "%d%d%d" , &n , &k , &l ) ;
  for ( int i = 0 ; i < k ; i ++ ) {
    int x , y ;
    scanf( "%d%d" , &x , &y ) ;
    v1[ x ].push_back( y ) ;
    v1[ y ].push_back( x ) ;
  }
  for ( int i = 0 ; i < l ; i ++ ) {
    int x , y ;
    scanf( "%d%d" , &x , &y ) ;
    v2[ x ].push_back( y ) ;
    v2[ y ].push_back( x ) ;
  }
}

int id1[ 200005 ] , id2[ 200005 ] ;
int cnt ;

void dfs2( int now ) {
  id2[ now ] = cnt ;
  for ( int nxt : v2[ now ] ) if ( !id2[ nxt ] )
    dfs2( nxt ) ;
}

void dfs1( int now ) {
  id1[ now ] = cnt ;
  for ( int nxt : v1[ now ] ) if ( !id1[ nxt ] )
    dfs1( nxt ) ;
}

void process() {
  cnt = 0 ;
  for ( int i = 1 ; i <= n ; i ++ ) if ( id1[ i ] == 0 ) {
    cnt ++ ;
    dfs1( i ) ;
  }
  cnt = 0 ;
  for ( int i = 1 ; i <= n ; i ++ ) if ( id2[ i ] == 0 ) {
    cnt ++ ;
    dfs2( i ) ;
  }
  for ( int i = 1 ; i <= n ; i ++ ) {
    if ( !mp.count( ii( id1[ i ] , id2[ i ] ) ) ) {
      mp[ ii( id1[ i ] , id2[ i ] ) ] = 1 ;
    } else {
      mp[ ii( id1[ i ] , id2[ i ] ) ] ++ ;
    }
  }
  for ( int i = 1 ; i <= n ; i ++ ) {
    printf( "%d%c" , mp[ ii( id1[ i ] , id2[ i ] ) ] , " \n"[ i == n ] ) ;
  }
}

int main() {
/*
#ifdef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
  int Cases;
  scanf( "%d" , &Cases ) ;
  for ( int cases = 1 ; cases <= Cases ; cases ++ ) {
*/
    init() ;
    process() ;
/*
  }
*/
  return 0 ;
}


Measured memory_bytes: 27904
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef long double ld;

int MOD=1000000007;

int main(){
  ll X,ans=0;
  cin >> X;
  ans+=X/500*1000;
  X=X-X/500*500;
  ans+=X/5*5;
  cout << ans << endl;

}

Measured memory_bytes: 256
s = input()
n = len(s)
dp = [ [0,0] for i in range(n) ]
dp[0][0] = int(s[0])
dp[0][1] = 11-int(s[0])
for i in range(n-1):
  d = int(s[i+1])
  dp[i+1][0] = min(dp[i][0]+d, dp[i][1]+d)
  dp[i+1][1] = min(dp[i][0]+11-d, dp[i][1]+9-d)
print(min(dp[n-1][0],dp[n-1][1]))

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

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

  if((a==b&&a!=c)||(a==c&&a!=b)||(c==b&&a!=c))cout << "Yes";
  else cout << "No"; 
  
  return 0;
}


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

using namespace std;

constexpr long long MOD = 924844033;
constexpr long long g = 5;

vector<int> edges[200001];

int n;
long long a[524288], b[524288], om[524288], invom[524288];
long long inv[200001], invfac[200001];

long long qpow(long long x, long long y) {
	long long result = 1;
	while (y != 0) {
		if (y % 2 == 1) result = result * x % MOD;
		x = x * x % MOD;
		y /= 2;
	}
	return result;
}

void fft(long long *a, int k, long long *om) {
	for (int i = 0, j = 0; i < k; ++i) {
		if (i < j) swap(a[i], a[j]);
		for (int l = k / 2; (j ^= l) < l; l /= 2);
	}

	for (int i = 2; i <= k; i *= 2) {
		for (int j = 0; j < k; j += i) {
			for (int l = 0; l < i / 2; ++l) {
				long long t = a[j + i / 2 + l] * om[k / i * l] % MOD;
				a[j + i / 2 + l] = (a[j + l] + MOD - t) % MOD;
				a[j + l] = (a[j + l] + t) % MOD;
			}
		}
	}
}

int dfs(int x, int p) {
	int size = 1;
	for (auto y: edges[x]) if (y != p) {
		size += dfs(y, x);
	}
	
	if (p != 0) {
		--a[size];
		--a[n - size];
	}
	return size;
}

int main() {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
#endif

	cin >> n;
	for (int i = 1; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}

	dfs(1, 0);
	a[n] = n;

	inv[1] = 1;
	for (int i = 2; i <= n; ++i) inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;

	long long fac = 1;
	b[n] = invfac[0] = 1;
	for (int i = 1; i <= n; ++i) {
		fac = fac * i % MOD;
		a[i] = a[i] * fac % MOD;
		b[n - i] = invfac[i] = invfac[i - 1] * inv[i] % MOD;
	}

	int k = 1;
	while (k < n * 2 + 1) k *= 2;

	long long r = qpow(g, (MOD - 1) / k);
	om[0] = invom[0] = 1;
	for (int i = 1; i < k; ++i) om[i] = invom[k - i] = om[i - 1] * r % MOD;

	fft(a, k, om);
	fft(b, k, om);
	for (int i = 0; i < k; ++i) a[i] = a[i] * b[i] % MOD;
	fft(a, k, invom);

	k = qpow(k, MOD - 2);
	for (int i = 1; i <= n; ++i)
		cout << a[i + n] * k % MOD * invfac[i] % MOD << '\n';
	
	return 0;
}

Measured memory_bytes: 40576
#include "bits/stdc++.h"

using namespace std;

const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
#define ll long long

ll d[maxn * 2];

int main() {
    //freopen("input.txt", "r", stdin);
    ll n, m, temp,x, l, r, ans = 0;
    cin >> n >> m >> temp;
    for (int i = 1; i < n; i++) {
        cin >> x;
        r = x;
        l = temp;
        if (l > r)
            r += m;
        ans += r - l;
        if (r - l > 1) {
            d[l + 2] += 1;
            d[r + 1] -= (r - l);
            d[r + 2] += (r - l - 1);
        }
        temp = x;
    }
    for(int i=1;i<=2*m;i++) d[i]+=d[i-1];
    for(int i=1;i<=2*m;i++) d[i]+=d[i-1];
    ll maxx = 0;
    for(int i=1;i<=m;i++)
        maxx = max(maxx,d[i]+d[i+m]);
    cout<<ans-maxx<<endl;
    return 0;
}



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

int main(){
    string n,a,b;
    cin >> n;
    for(int i=0;i<n.size()-1;i++){
        if(n[i]=='A'&&n[i+1]=='C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
require 'set'; require 'prime'
INF=Float::INFINITY
s = gets.chomp.split(//)

k = 'keyence'.split(//)

s.size.times do |i|
  i.upto(s.size-1).each do |j|
    if s.slice(0,i) + s.slice(j,100) == k
      puts 'YES'
      exit
    end
  end
end

puts 'NO'



Measured memory_bytes: 3580
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	std::string s;
	std::cin >> s;

	int n = s.size();
	std::vector<std::vector<int> > next(n+1,std::vector<int>(26,n));
	rep(j,26) {
		int last = n;
		for(int i=n-1;i>=0;i--) {
			if(s[i]==j+'a') {
				last = i;
			}
			next[i][j]=last;
		}
	}

	std::vector<int> dp(n+1,1<<30);
	dp[n]=1;
	std::vector<std::pair<char,int> > recon(n+1, {'?', n});
	for(int i=n-1;i>=0;i--) {
		rep(j,26) {
			if(next[i][j]==n) {
				if(dp[i]>1) {
					dp[i]=1;
					recon[i] = {'a'+j,n};
				}
			}
			else if(dp[i]>dp[next[i][j]+1]+1) {
				dp[i] = dp[next[i][j]+1]+1;
				recon[i] = {'a'+j,next[i][j]+1};
			}
		}
	}

	// reconstruct
	std::string ans = "";
	int i = 0;
	while(i<n) {
		auto x = recon[i];
		ans+=x.first;
		i=x.second;
	}
	print(ans);

	return 0;
}


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


int main() {
  int n ;
  cin >> n ;
  
  for(int i = 3 ; i<=n;i++){
    if(i%3==0){
      cout << " " << i ;
      continue ;
    }
    if(i%10==3){
      cout << " " << i ;
      continue ;
    }
    int x=i;
    while(x>0){
      x/=10;
      if(x%10==3){
        cout << " " << i ;
        break;
      }
    }
    
  }
  cout << endl;
}
    


Measured memory_bytes: 3096
import java.util.*;

public class Main {
  public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	if(a > b * 2) {
          System.out.println(a- b*2);
        } else {
          System.out.println(0);
        }
  }
}

Measured memory_bytes: 21972
//I am so vegetable
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto p:st)
//#define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll maxn = 1e2 + 5;
const int MOD = 1e9 + 7;
const double exps = 1e-6;
#ifdef _LOCAL_
void deprint() {
	ofstream cout("E:\\acm dream\\debug.txt");
	return;
}
#endif
int main() {
#ifdef _LOCAL_
	ifstream cin("E:\\acm dream\\in.txt");
	ofstream cout("E:\\acm dream\\out.txt");
#endif
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n, m, ans[] = { 10,10,10 }; cin >> n >> m;
	int x, y;
	bool flag = false;
	_for(i, 0, m) {
		cin >> x >> y;
		if (ans[x - 1] != 10 && ans[x - 1] != y) flag = true;
		else ans[x - 1] = y;
	}
	if (ans[0] == 0 && n != 1 || flag)cout << -1;
	else {
		_for(i, 0, n) {
			if (i == 0 && ans[0] == 10 && n!= 1)cout << 1;
			else if (ans[i] == 10)cout << 0;
			else cout << ans[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
};
typedef struct node * Node;
Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key){
      u = u->left;
    }else{
      u = u->right;
    }
  }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;

  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->parent = y->parent;
  if(y->parent == NIL) root = x;
  else if( y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y != z) z->key = y->key; 
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }
}

void inorder(Node u){
  if(u != NIL){
    if(u->left != NIL) inorder(u->left);
    printf(" %d", u->key);
    if(u->right != NIL) inorder(u->right);
  }
}

void preorder(Node u){
  if(u != NIL){
    printf(" %d", u->key);
    if(u->left != NIL) preorder(u->left);
    if(u->right != NIL) preorder(u->right);
  }
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }
  }
  
  return 0;
}

Measured memory_bytes: 19364