akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
typedef long long ll;

int N, x, xMin, ans;

int main(int argc, char *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N;
  cin >> x;
  xMin = x;
  ans = -(1 << 30);
  REP(i,N-1){
    cin >> x;
    ans = max(ans, x - xMin);
    xMin = min(x, xMin);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1196
n = int(input())
dp = [10 ** 9] * (n + 5)
dp[0] = 0

idx = 0
while dp[n] == 10 ** 9:
    for i in range(n):
        if dp[i] == idx:
            for j in range(10):
                if i + 6 ** j > n: break
                dp[i + 6 ** j] = min(dp[i + 6 ** j], dp[i] + 1)
            for j in range(10):
                if i + 9 ** j > n: break
                dp[i + 9 ** j] = min(dp[i + 9 ** j], dp[i] + 1)
    idx += 1
print(dp[n])



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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

  int n; cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  int tmp = 0;
  rep(i, n) {
    if((i+1) != p[i]) tmp++;
  }

  cout << (tmp == 2 || tmp == 0 ? "YES" : "NO") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  int n;
  cin>>n;
  vector<int>a(n-1),b(n-1),c(n),ans(n);
  vector<int>d[n];
  rep(i,n-1){
    cin>>a.at(i)>>b.at(i);
    a.at(i)--;
    b.at(i)--;
    d[a[i]].push_back(b[i]);
    d[b[i]].push_back(a[i]);
  }
  int to=0;
  rep(i,n){
    cin>>c.at(i);
  }
  sort(c.begin(),c.end());
  reverse(c.begin(),c.end());
  rep2(i,1,n){
    to+=c[i];
  }
  queue<int>q;
  q.push(0);
  vector<bool>v(n);
  v[0]=true;
  int p=0;
  while(!q.empty()){
    int now=q.front();q.pop();
    v[now]=true;
    rep(i,d[now].size()){
      if(!v[d[now][i]]){
        q.push(d[now][i]);
      }
    }
    ans[now]=c[p];
    p++;
  }
  cout<<to<<endl;
  rep(i,n){
    cout<<ans.at(i)<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 4388
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int result = 0;
			int count = 0;
			long before = 0;
			for (int i = 0; i < n; i++) {
				long tmp = sc.nextLong();
				if (tmp <= before) {
					count++;
				} else {
					if (result < count) {
						result = count;
					}
					count = 0;
				}
				before = tmp;
			}
			if (result < count) {
				result = count;
			}
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 48840
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a, b, c, d = [int(x) for x in input().split()]
e = lcm(c, d)

ac = (a-1) // c
ad = (a-1) // d
ae = (a-1) // e
bc = b // c
bd = b // d
be = b // e
print((b-a+1) - ((bc + bd - be) - (ac + ad - ae)))


Measured memory_bytes: 5116
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let N = get!(usize);
    let mut a = get!(Vec<usize>);

    a.push(0);
    let (ans, _) = (0..N).fold(
            (0, 1),
            |(acc, b), i| if a[i] == a[i + 1] {
                (acc, b + 1)
            } else {
                (acc + b / 2, 1)
            }
        );
    println!("{}", ans);
}


Measured memory_bytes: 4352
N, T = map(int, input().split())
A = [int(Ai) for Ai in input().split()]
Amin = A[0]
Bmax = 0
count = 0
for i in range(1, len(A)):
    Amin = min(A[i-1], Amin)
    Bi = A[i] - Amin
    if Bmax == Bi:
        count += 1
    elif Bmax < Bi:
        Bmax = Bi
        count = 1
print(count)


Measured memory_bytes: 14252
N, K = list(map(int,input().split()))
a = list(map(int,input().split()))

if K <= N:
    position = 0
    for k in range(K):
        position = a[position] - 1
    print(position + 1)
    exit()
else:
    flag = 0
    position = 0
    visit = [False] * N
    visit[position] = True

    time = 0
    while flag == 0:
        position = a[position] - 1
        time += 1
        if visit[position]:
            flag = 1
        else:
            visit[position] = True

    time_second = time
    position_loop_start = position
    position = 0
    for t in range(time):
        if position == position_loop_start:
            time_first = t
        position = a[position] - 1
    #print(time_first,time_second)
    time_loop = time_second - time_first

    K_nokori = (K - time_first)%time_loop
    position = position_loop_start

    for k in range(K_nokori):
        position = a[position] - 1
    print(position + 1)


Measured memory_bytes: 32244
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
#define first fi
#define second se
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int sosu(int a){
    if(a==2){
        return 1;
    }
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s,ss[220000],sa;
char ch[110][110];
queue<int> que;
signed main(){
    cin>>n>>m;
    rep(i,m){
        cin>>aa[i];
        ab[aa[i]]=-1;
    }
    ab[0]++;
    ab[1]++;
    srep(i,2,n+1){
        if(ab[i]==-1){
            ab[i]=0;
        }else{
            ab[i]=ab[i-1]+ab[i-2];
        }
        ab[i]%=INF;
    }
    cout<<ab[n]<<endl;
}

Measured memory_bytes: 11908
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    int n;
    cin>>n;
    int cnt=(n+1000-1)/1000;
    int ans=1000*cnt-n;
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
let rec buy m lst = match lst with
  | [] -> 0
  | (x, y) :: tail ->
    if m <= y then x * m
    else x * y + buy (m-y) tail
let () =
  let (n, m) = Scanf.scanf "%d %d\n" (fun x y -> (x, y)) in
  let lst = List.fast_sort (fun (a, _) (b, _) -> if a > b then 1 else if a < b then -1 else 0) (Array.to_list (Array.init n (fun _ -> Scanf.scanf "%d %d\n" (fun x y -> (x, y))))) in
  Printf.printf "%d\n" (buy m lst)

Measured memory_bytes: 16768
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;
 
void main() {
    auto N = readln.chomp.to!int;
    auto G = new int[][](N);
    foreach (_; 0..N-1) {
        auto s = readln.split.map!(to!int);
        G[s[0]-1] ~= s[1]-1;
        G[s[1]-1] ~= s[0]-1;
    }

    if (N == 1) {
        writeln("First");
        return;
    } else if (N == 2) {
        writeln("Second");
        return;
    }

    Tuple!(int, int) dfs(int n, int p) {
        auto ret = tuple(0, n);
        foreach (m; G[n]) {
            if (m == p) continue;
            auto t = dfs(m, n);
            t[0] += 1;
            ret = max(ret, t);
        }
        return ret;
    }

    auto d = dfs(dfs(0, -1)[1], -1)[0];
    int g = (d - 1) % 3;
    writeln(g > 0 ? "First" : "Second");
}


Measured memory_bytes: 24828
import Control.Monad
import Control.Applicative
readDigits = map read <$> words <$> getLine :: IO [Int]

solve :: [String] -> [String]
solve [] = []
solve (line:lines) =
    let [a,op,b] = words line in
    case (go (read a) op (read b)) of
    Just x -> show x : solve lines
    Nothing -> []
    where
    go :: Int -> String -> Int -> Maybe Int
    go a "+" b = Just $ a + b
    go a "-" b = Just $ a - b
    go a "*" b = Just $ a * b
    go a "/" b = Just $ a `div` b
    go _ _ _ = Nothing

main = 
    mapM_ putStrLn =<< solve <$> lines <$> getContents

Measured memory_bytes: 4076
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n,k; cin >> n >> k;
    vi a(n+10);
    rep(i,n){
        int x; cin >> x;
        a[x]++;
    }
    sort(a.rbegin(), a.rend());
    rep(i,k) n -= a[i];
    cout << n << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int r , x, y;
	cin >> x >> y;
	if (x < y){
		swap(x, y);
	}
	while (y > 0){
		r = x % y;
		x = y;
		y = r;
	}
	cout << x << endl;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  OUT((N+1)/2);

  return 0;
}

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

ll f(ll a,ll b){
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

int main(){
  int i,j,cnt=0;
  ll n,m;
  string s,t;
  cin>>n>>m;
  cin>>s>>t;
  ll d=f(n,m);
  for(i=0;i<d;i++){
    if(s[n*i/d]!=t[m*i/d]){
      cout<<-1;
      return 0;
    }
  }
  cout<<n*m/d;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 20000;
const int MOD = 998244353;
char A[N], B[N];
int n, X, Y, ans;
int powi(int a, int b)
{
    int c = 1;
    for (; b; b >>= 1, a = 1ll * a * a % MOD)
        if (b & 1) c = 1ll * c * a % MOD;
    return c;
}
int fac[N], inv[N];
struct poly
{
    int d[N];
    poly () {memset(d, 0, sizeof d);}
} P, Q;
int L;

int tmpA[N * 4], tmpB[N * 4];
void NTT(int A[], int n, int fl)
{
	for (int i = 1; i < n; ++ i)
	{
		int d = 0;
		for (int j = 1, k = n >> 1; k; j <<= 1, k >>= 1)
			if (i & j) d |= k;
		if (d < i) swap(A[d], A[i]);
	}
	for (int i = 2; i <= n; i <<= 1)
	{
		int w0 = powi(3, (MOD - 1) / i);
		if (fl < 0) w0 = powi(w0, MOD - 2);
		for (int j = 0; j < n; j += i)
		{
			int w = 1;
			for (int k = j; k < j + (i >> 1); ++ k)
			{
				int u = A[k], v = 1ll * A[k + (i >> 1)] * w % MOD;
				A[k] = (u + v) % MOD; A[k + (i >> 1)] = (u - v + MOD) % MOD;
				w = 1ll * w * w0 % MOD;
			}
		}
	}
	if (fl < 0)
    {
        int inv = powi(n, MOD - 2);
        for (int i = 0; i < n; ++ i) A[i] = 1ll * A[i] * inv % MOD;
    }
}

poly operator * (const poly &a, const poly &b)
{
    poly c;
    int nn = 1; while (nn <= L) nn *= 2; nn *= 2;
    for (int i = 0; i < L; ++ i) tmpA[i] = a.d[i]; for (int i = L; i < nn; ++ i) tmpA[i] = 0;
    for (int i = 0; i < L; ++ i) tmpB[i] = b.d[i]; for (int i = L; i < nn; ++ i) tmpB[i] = 0;
    NTT(tmpA, nn, 1); NTT(tmpB, nn, 1);
    for (int i = 0; i < nn; ++ i) tmpA[i] = 1ll * tmpA[i] * tmpB[i] % MOD;
    NTT(tmpA, nn, -1);
    for (int i = 0; i < L; ++ i) c.d[i] = tmpA[i];
    return c;
}
poly operator ^ (poly a, int b)
{
    poly c; c.d[0] = 1;
    for (; b; b >>= 1, a = a * a)
        if (b & 1) c = c * a;
    return c;
}
int C(int a, int b)
{
    return 1ll * fac[a] * inv[b] % MOD * inv[a - b] % MOD;
}
int main()
{
    scanf("%s%s", A, B); n = strlen(A);
    for (int i = 0; i < n; ++ i)
        if (A[i] == '1' && B[i] == '1') X ++;
        else if (A[i] == '1') Y ++;
    fac[0] = 1;
    for (int i = 1; i < N; ++ i) fac[i] = 1ll * fac[i - 1] * i % MOD;
    inv[N - 1] = powi(fac[N - 1], MOD - 2);
    for (int i = N - 2; ~i; -- i) inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;

    L = X + Y + 1;
    for (int i = 1; i < L; ++ i) P.d[i] = inv[i];
    Q = P ^ Y;
    for (int i = 0; i < L; ++ i) P.d[i] = 1;
    Q = Q * P;
    ans = 1ll * Q.d[X + Y] * fac[X] % MOD * fac[Y] % MOD * fac[X + Y] % MOD;
    printf("%d\n", ans);
}


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

using namespace std;

#define F first
#define S second

string world[8] = {"U", "D", "R", "L", "UL", "UR", "DR", "DL"};
const int rx[8] = { -1,  1,  0,  0,  -1,  -1,   1,   1};
const int ry[8] = { 0,  0,  1, -1,  -1,   1,   1,  -1};


int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    long long a[3];
    cin >> a[0] >> a[1] >> a[2];
    for (int i = 0; i < 3; i++){
        if (a[i] % 2 == 0){
            cout << 0;
            return 0;
        }
    }
    sort(a, a + 3);
    cout << a[0] * a[1];
#ifdef TIME
    cerr << "TIME = " << 1. * clock() / CLOCKS_PER_SEC;
#endif
    return 0;
}


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

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

    // 入力
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    // 処理
    // 出力
    cout << (s1[s1.size() - 1] == s2[0] && s2[s2.size() - 1] == s3[0] ? "YES "
                                                                      : "NO")
         << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int CalcTotalVal(int iTargetNumber, int iSetNumber, int iSetValue);

int main(int argc, char *argv[])
{
    // 条件を入力してもらう
    int iTargetNumber = 0, iSetANumber = 0, iSetAValue = 0, iSetBNumber = 0, iSetBValue = 0;
    scanf("%d %d %d %d %d",&iTargetNumber,&iSetANumber,&iSetAValue,&iSetBNumber,&iSetBValue);
    
    // ASet、BSetの必要金額を計算
    int iSetATotalVal = 0, iSetBTotalVal = 0;
    iSetATotalVal = CalcTotalVal(iTargetNumber, iSetANumber, iSetAValue);
    iSetBTotalVal = CalcTotalVal(iTargetNumber, iSetBNumber, iSetBValue);
    
    // 安い方を出力
    int iAnsVal = 0;
    if(iSetATotalVal < iSetBTotalVal){
        iAnsVal = iSetATotalVal;
    }
    else{
        iAnsVal = iSetBTotalVal;
    }
    printf("%d\n", iAnsVal);

    return 0;
}

int CalcTotalVal(int iTargetNumber, int iSetNumber, int iSetValue)
{
    int iSetCount = 0;
    if(iSetNumber != 0){
        iSetCount = iTargetNumber / iSetNumber;
        if(iTargetNumber % iSetNumber != 0){
            iSetCount += 1;
        }
    }
    return iSetValue * iSetCount;
}


Measured memory_bytes: 2740
import bisect
n = int(input())
l = sorted(map(int, input().split()))
ans = 0
for mid in range(n-1, -1, -1):
    for low in range(mid - 1, -1, -1):
        itr = bisect.bisect_left(l, l[mid] + l[low])
        ng = n - itr
        ans += ((n - 1 - mid) - ng)
print(ans)


Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const long long MAX = 10000000000LL;

int main()
{
    map<long long, long long> square;
    for(long long i=2; i*i<=MAX; ++i)
        square[i*i] = i;

    int n;
    cin >> n;
    map<map<long long, int>, int> m;
    for(int i=0; i<n; ++i){
        long long a;
        cin >> a;

        map<long long, int> x;
        for(long long j=2; j*j*j<=MAX; ++j){
            int cnt = 0;
            while(a % j == 0){
                a /= j;
                cnt = (cnt + 1) % 3;
            }
            if(cnt != 0)
                x[j] = cnt;
        }

        if(a > 1){
            if(square.find(a) != square.end())
                x[square[a]] = 2;
            else
                x[a] = 1;
        }

        ++ m[x];
    }

    int ans = 0;
    for(const auto& p : m){
        map<long long, int> x = p.first;
        if(x.size() == 0){
            ++ ans;
            continue;
        }

        for(auto& a : x)
            a.second = 3 - a.second;

        if(m.find(x) == m.end()){
            ans += p.second;
        }
        else if(m[x] <= p.second){
            ans += p.second;
            m[x] = 0;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35584
#include<iostream>
#include<stdio.h>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep3(i,k,n) for(int i = k; i < n; i++)
#define INFTY 2000000000
#define MAX 500000
using namespace std;

typedef struct Card{ char s;int x;}C;
int n;
C L[MAX/2+2],R[MAX/2+2];

void merge(C c[],int n,int left,int mid,int right){
    int n1 = mid-left;
    int n2 = right - mid;
    rep(i,n1){
        L[i]=c[left+i];
    }
    rep(i,n2){
        R[i]=c[mid+i];
    }
    L[n1].x=INFTY;
    R[n2].x=INFTY;
    int i=0,j=0,k;
    rep3(k,left,right){
        if(L[i].x<=R[j].x){
            c[k]=L[i++];
        }else{
            c[k]=R[j++];
        }
    }
}

void MergeSort(C c[],int n, int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        MergeSort(c,n,left,mid);
        MergeSort(c,n,mid,right);
        merge(c,n,left,mid,right);
    }
}

int parti(C c[],int p,int r){
    C x=c[r];
    int i=p-1;
    rep3(j,p,r){
        if(c[j].x<=x.x){
            i++;
            swap(c[i],c[j]);
        }
    }
    swap(c[i+1],c[r]);
    return i+1;
}

void QuickSort(C c[],int p,int r){
    if(p<r){
        int q=parti(c,p,r);
        QuickSort(c,p,q-1);
        QuickSort(c,q+1,r);
    }
}

void CardPrint(C c){
    cout<<c.s<<" "<<c.x<<endl;
}

int main(void){
    cin >> n;
    C M[MAX],Q[MAX];
    int v;
    char S[20];    
    rep(i,n) {
        scanf("%s %d",S,&v);
        M[i].s=S[0];M[i].x=v;
        Q[i]=M[i];
    }

    MergeSort(M,n,0,n);
    QuickSort(Q,0,n-1);

    int isStable=1;
    rep(i,n){
        if(M[i].s!=Q[i].s) isStable=0;
    }

    if(isStable) cout <<"Stable"<<endl; else cout <<"Not stable"<<endl;
    rep(i,n) CardPrint(Q[i]);
    return 0;
}

Measured memory_bytes: 5464
def main():
    N, K = map(int, input().split())

    having_candy = [False for _ in range(N)]

    for i in range(K):
        _ = input()
        ds = map(int, input().split())

        for s in ds:
            having_candy[s-1] = True

    print(N - sum(having_candy))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9084
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[0].split(' ')
a = []
for(i=0;i<3;i++){
    a[inp[i]] = (a[inp[i]] || 0) + 1 
}
console.log(a[5] == 2 && a[7] == 1 ? 'YES' : 'NO')

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  ll Ans=0;
  rep(i, N){
    cin>>A[i];
    if(i==0)continue;
    if(A[i-1]<=A[i])continue;
    Ans+=A[i-1]-A[i];
    A[i]=A[i-1];
  }
  cout<<Ans<<endl;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    string n;
    cin >> n;

    if(n[0] == n[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    double xa, ya, ra, xb, yb, rb;
    cin >> n;
    while(n--){
        cin >> xa >> ya >> ra >> xb >> yb >> rb;
        double distance = sqrt( (xb - xa) * (xb - xa) + (yb - ya) * (yb - ya) );
        if(distance > ra + rb)
            cout << 0 << endl;
        else if(distance + rb < ra)
            cout << 2 << endl;
        else if(distance + ra < rb)
            cout << -2 << endl;
        else
            cout << 1 << endl;
    }
}

Measured memory_bytes: 1232
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main() 
{
  ll X; cin>>X;
  if(400<=X&&X<600) cout<<8<<endl;
  if(600<=X&&X<800) cout<<7<<endl;
  if(800<=X&&X<1000) cout<<6<<endl;
  if(1000<=X&&X<1200) cout<<5<<endl;
  if(1200<=X&&X<1400) cout<<4<<endl;
  if(1400<=X&&X<1600) cout<<3<<endl;
  if(1600<=X&&X<1800) cout<<2<<endl;
  if(1800<=X&&X<2000) cout<<1<<endl;
  return 0;
}


Measured memory_bytes: 3604
from collections import deque

X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

R.sort()
R = deque(R)

P.sort(reverse=True)
Q.sort(reverse=True)
P = P[:X]
Q = Q[:Y]

S = [P, Q]

A = [(0, i, p) for i, p in enumerate(P)] + [(1, i, q) for i, q in enumerate(Q)]
A.sort(reverse=True, key=lambda a: a[2])

while R and R[-1] > A[-1][2]:
    k, i, _ = A.pop()
    S[k][i] = R.pop()

print(sum(P) + sum(Q))


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

int main() {
    int n; cin >> n;
    for (int i = 1; i <= 9; i++) for (int j = 1; j <= 9; j++) {
        if (i * j == n) return !(cout << "Yes" << endl);
    }
    cout << "No" << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int x;
  cin >> x;
  vector<bool> dp(100001);
  dp[0] = true;
  for (int i = 1; i < 100; i++) dp[i] = false;
  for (int i = 100; i < 106; i++) dp[i] = true;
  for (int i = 106; i < 100001; i++) {
    if (dp[i - 100] || dp[i - 101] || dp[i - 102] || dp[i - 103] ||
        dp[i - 104] || dp[i - 105]) {
      dp[i] = true;
    }
  }
  cout << dp[x];
}

Measured memory_bytes: 256
from collections import deque


S = deque(input())
Q = int(input())
QUERY = [input().split(" ") for i in range(Q)]
reverse_f = 0

for query in QUERY:
    if query[0] == "1":#反転
        reverse_f = (reverse_f+1)%2
    else:#=="2"
        if query[1] == "1":
            if reverse_f:
                S.append(query[2])
            else:
                S.appendleft(query[2])

        else:#=="2"
            if reverse_f:
                S.appendleft(query[2])
            else:
                S.append(query[2])

if reverse_f:
    S.reverse()
print("".join(list(S)))

Measured memory_bytes: 44788
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Map<Integer,Integer> map = new TreeMap<>();
        int[] p = new int[m];
        int[] y = new int[m];
        for (int i=0;i<m;i++){
            p[i] = sc.nextInt();
            y[i] = sc.nextInt();
            map.put(y[i],i);
        }
        int[] orderP = new int[n];
        int[] num    = new int[m];
        for (int k:map.keySet()){
            int prefecture = p[map.get(k)];
            orderP[prefecture-1]++;
            num[map.get(k)]=orderP[prefecture-1];
        }
        for (int i=0;i<m;i++){
            System.out.println(String.format("%06d",p[i])+String.format("%06d",num[i]));
        }
    }
}


Measured memory_bytes: 169824
/// 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 rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#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
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;
}

int n,x[500];
string s[500];
set<string> st;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

        cin >> n;
        for(int i=1;i<=n;i++){
                cin >> s[i] >> x[i];
                st.insert( s[i] );
        }
        vi ans;
        for(auto t:st){

                vpi v;
                for( int i=1;i<=n;i++ ){
                        if( s[i] == t ){
                                v.pb( { x[i],i } );
                        }
                }
                sort(all(v));
                reverse(all(v));
                for(auto u:v){
                        ans.pb( u.sc );
                }

        }

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


return 0;
}
///....


Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <queue>
#include <vector>

using namespace std;

int main() {
  int w, n, ws[31];
  scanf("%d\n%d", &w, &n);
  for (int i = 1; i <= w; i++)
    ws[i] = i;
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d,%d", &a, &b);
    swap(ws[a], ws[b]);
  }
  for (int i = 1; i <= w; i++)
    printf("%d\n", ws[i]);
  return 0;
}

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

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

    int s = 0;

    for(int k = n; k; k /= 10) s += k % 10;

    if(n % s == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;

#define int long long
#define PB push_back
#define ALL(V) V.begin(), V.end()
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;

constexpr int INF = 1LL<<60;
constexpr int MOD = 1000000007;
//constexpr int MAX_N = 100005;
constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

int r, w[2], h[2], ex[2], ey[2], fld[2][505][505], d[2][505][505];

vector<pii> lvs[2];
vector<int> templvs[2];

void Dijkstra(int k) {
    fill(d[k][0], d[k][505], INF);
    priority_queue<pipii, vector<pipii>, greater<pipii>> pq;
    d[k][ex[k]][ey[k]] = 1;
    pq.push({1, {ex[k], ey[k]}});

    while (pq.size()) {
        pipii p = pq.top();
        pq.pop();
        int x = p.second.first, y = p.second.second;
        if (d[k][x][y] < p.first) continue;

        for (int i = 0; i < 4; ++i) {
            int tx = x + dx[i], ty = y + dy[i], lv = max(p.first, fld[k][tx][ty]);
            if (fld[k][tx][ty] == 0) continue;
            if (d[k][tx][ty] <= lv) continue;
            d[k][tx][ty] = lv;
            pq.push({lv, {tx, ty}});
        }
    }
}

bool Solve() {
    cin >> r;
    if (r == 0) return false;
    memset(fld, 0, sizeof(fld));

    for (int i = 0; i < 2; ++i) {
        cin >> w[i] >> h[i] >> ex[i] >> ey[i]; 

        for (int y = 1; y <= h[i]; ++y) {
            for (int x = 1; x <= w[i]; ++x) {
                cin >> fld[i][x][y];
            }
        }
    }

    Dijkstra(0);
    Dijkstra(1);

    for (int i = 0; i < 2; ++i) {
        lvs[i].clear();
        templvs[i].clear();

        for (int y = 1; y <= h[i]; ++y) {
            for (int x = 1; x <= w[i]; ++x) {
                templvs[i].PB(d[i][x][y]);
            }
        }

        sort(ALL(templvs[i]));
        templvs[i].PB(INF);
        lvs[i].PB({0, 0});
        for (int j = 0; j < templvs[i].size(); ++j) {
            for (int c = 1; j + c <= templvs[i].size(); ++c) {
                if (templvs[i][j + c - 1] == templvs[i][j]) continue;
                c--;
                lvs[i].PB({c + lvs[i][lvs[i].size() - 1].first, templvs[i][j]});
                j += c - 1;
                break;
            }
        }
        lvs[i].PB({INF, INF});
    }

    int ans = INF;
    for (int i = 0; i < lvs[0].size(); ++i) {
        int cnt = lvs[0][i].first;
        if (cnt + w[1] * h[1] < r) continue;
        
        auto s = upper_bound(ALL(lvs[1]), pii(r - cnt - 1, INF));
        if (s == lvs[1].end()) continue; 
        ans = min(ans, lvs[0][i].second + s->second);
    }

    cout << ans << endl;

    return true;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    while(Solve());
}

Measured memory_bytes: 19700
#include <bits/stdc++.h>
 
using namespace std;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
 
typedef long long tint;

const int INF = 1e6;
const long double PI = acos(-1);
 
int main() {
	int n; cin >> n;
	vector<int> p(n);
	int maxi = 0, sum = 0;
	forn(i, n){
		cin >> p[i];
		maxi = max(maxi, p[i]);
		sum+=p[i];
	}
	cout << sum-(maxi/2) << endl;
}


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

int main() {
    int a,b,c,d; cin >> a >> b >> c >> d;
    while(a > 0 && b > 0) {
        c -= b;
        if(c <= 0) {
            cout << "Yes\n";
            return 0;
        }
        a -= d;
        if(a <= 0) {
            cout << "No\n";
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;
int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    int K;
    cin >> K;
    cout << arr[K - 1] << endl;
}

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

using namespace std;

const int P=1e9+7;

int n,m;
char str[1010];
int f[1010][1010];

int main(){
	scanf("%d%d",&n,&m);
	f[1][1]=1;
	for(int i=1;i<=n;i++){
		scanf("%s",str+1);
		for(int j=1;j<=m;j++){
			if(str[j]=='.' && (i!=1 || j!=1))
				f[i][j]=(f[i-1][j]+f[i][j-1])%P;
		}
	}
	//printf("%d\n",f[1][2]);
	printf("%d\n",f[n][m]);
	
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  bool ok = true;
  for (int i = 0; i < n - 1; ++i) {
    if (a[i] == a[i + 1]) {
      ok = false;
    }
  }
  if (ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
unsigned long long a[100005];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	int t=0,sum=0;
	for(int i=0;i<n-1;i++)
	{
		if(a[i]>=a[i+1])
		sum++;
		else
		{
			if(sum>t)
			t=sum;
			sum=0;
		}
	}
	if(sum>t)
	t=sum;
	cout<<t;
}

Measured memory_bytes: 1024
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
ab=array(N)
N.times do|i|
    ab[i]=get_i
end
a=ab.sort{|x,y| x[0]<=>y[0]}
b=ab.sort{|x,y| x[1]<=>y[1]}
if N.odd?
  puts b[N/2][1]-a[N/2][0]+1
else
  puts b[N/2-1][1]+b[N/2][1]-(a[N/2-1][0]+a[N/2][0])+1
end

Measured memory_bytes: 32452
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)




int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ac, ad, bc, bd;
  ac = a * c;
  ad = a * d;
  bc = b * c;
  bd = b * d;
  //vector<ll> a(N);
  //vector<vector<int>> data(3, vector<int>(4));
  
  cout << max(bc ,max(bd, max(ac, ad))) << endl;

  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    int n;
    int l,r;
    int ans = 0;
    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();
    for(int i=0;i<n;i++){
      l = sc.nextInt();
      r = sc.nextInt();
      ans += r - l + 1;
    }
    System.out.println(ans);
  }
}


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

typedef long long ll;
typedef long double ld;
const int mod= 1e9+7;
ll power(ll x,ll y){ll res=1;x=x%mod;while(y>0){if(y&1)res=((res%mod)*(x%mod))%mod;y=y>>1;x=((x%mod)*(x%mod))%mod;}return res;}
int main ()
{
   ll n;
   ll k;
   cin>>n>>k;
   vector <ll> a(n,0);
   vector <ld> ans(n,0);
   for (ll i=0;i<n;i++)
   {
      cin>>a[i];
   }
   for (ll i=0;i<n;i++)
   {
      ans[i]=(a[i]+1)/2.0;
      //cout<<ans[i];
   }
   for (ll i=0;i<n;i++)
   {
      if (i)
      {
         ans[i]+=ans[i-1];
      }
   }
   ld fans=ans[k-1];
   for (ll i=k;i<n;i++)
   {
      fans=max(fans,ans[i]-ans[i-k]);
   }
   cout<<fixed<<setprecision(12)<<fans;

}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#include <unordered_map>
#define inputarr(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define prllarr(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define pb push_back
#define ll long long
#define mod 1000000007
#define foi ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define in(n) scanf("%lld",&n);
#define in2(x,y) scanf("%lld %lld",&(x),&(y));
#define in3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z));
#define out(n) printf("%lld\n",n);
#define out2(x,y) printf("%lld %lld\n",x,y);
#define test(t)  ll t; in(t);while(t--)
#define set(arr,n,s) for(ll i=0;i<n;i++){arr[i]=s;}


ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1){res=(res*x)%p;} y=y>>1;x=(x*x)%p;}return res;}
ll modInverse(ll a,ll p){return power(a,p-2,p);}//used with feemat little

ll gcd(ll x,ll y){if(x==0 || y==0){return max(y,x);}return gcd(y%x,x);}
ll gcdExtended(ll a,ll b,ll &x,ll &y){if(a==0){x=0;y=1;return b;}ll x1,y1;ll gcd = gcdExtended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return gcd;}//o(log(b))
;
void prac(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
   #endif 
}

vector<ll>adj[100004];

pair<ll,ll> dfs(ll cur,ll par){
	if((adj[cur].size()==1LL && adj[cur][0]==par) || adj[cur].size()==0){
		return {1LL,1LL};
	}
	ll first=1LL;
	ll second=1LL;
	
	for(ll son:adj[cur]){
		if(son!=par){
			auto f=dfs(son,cur);
			first*=(f.first+f.second);
			first%=mod;
			second*=f.first;
			second%=mod;
		}
	}
	return {first,second};
}
int main() 
{
  	// prac();
  	ll n;
  	in(n)
  	for(ll i=0;i<n-1;i++){
  		ll x,y;
  		in2(x,y)
  		adj[x].pb(y);
  		adj[y].pb(x);
  	}
  	auto f=dfs(1,0);
	out((f.first+f.second)%mod)  	;
  	
   



}
/*error-----
convert every int to long long eg-1LL
create array with proper analysis of problem constrain
check mod also
*/






Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int W,a,b;
    cin >> W >> a >> b;
    if(b > a) pr(max(b-(a+W),0));
    else pr(max(a-(b+W),0));
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

class UnionFind
{
    private:
        std::vector<int> parent;  // parent[x]: x の根の番号
                                  //            x が根の場合はその連結成分の大きさ
        std::vector<int> rank;    // rank[x]  : x が属する木の高さ
        std::size_t sz;           // 連結成分の数

    public:
        // x が親の場合、parent[x] = -(その連結成分の大きさ)
        UnionFind( std::size_t n ): parent(n, -1), rank(n, 0), sz(n) {}

        // x が属する集合の親を返し、x を親に直接繋ぎ直す(経路圧縮)
        int find( int x )
        {
            if( parent[x] < 0 ) return x;
            else return parent[x] = find( parent[x] );
        }

        // x が属する集合と y が属する集合を統合する
        bool unite( int x, int y )
        {
            x = find( x );
            y = find( y );
            if( x == y ) return false;

            // 大きい方(x)に小さい方(y)を繋げる
            if( rank[x] < rank[y] ) std::swap( x, y );

            parent[x] += parent[y];  // x に連結している成分の大きさを更新する
            parent[y] = x;           // y を x に繋ぐ
            if( rank[x] == rank[y] ) rank[x]++;
            sz--;

            return true;
        }

        bool same( int x, int y ) { return find(x) == find(y); }
        std::size_t size()        { return sz; }
        std::size_t size( int x ) { return - parent[find(x)]; }
};


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

    UnionFind uni(N);
    REP(i, M){
        int X, Y, Z;
        cin >> X >> Y >> Z;
        --X, --Y;
        uni.unite(X, Y);
    }
    cout << uni.size() << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

/*
レート 1-399：灰色
レート 400-799：茶色
レート 800-1199：緑色
レート 1200-1599：水色
レート 1600-1999：青色
レート 2000-2399：黄色
レート 2400-2799：橙色
レート 2800-3199：赤色

*/

int col[9];


int main(){
	int n, a;
	cin >> n;
	FORI(0, n) {
		cin >> a;
		int t = a / 400;
		t = min(8, t);
		col[t]++;
	}
	int ans = 8 - count(col, col + 8, 0);

	int ma = ans + col[8];
	int mi = max(1, ans);
	cout << mi << " " << ma << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(long long)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const long long d5 = 114514;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1.0);

signed main(){
    long long n;
    cin>>n;
    vector<long long> a(n);
    for(long long i=0;i<n;i++)cin>>a[i];
    //+-+-...と-+-+で決めうって貪欲
    long long res1=0,res2=0;
    long long sum1=0,sum2=0;
    //+-+-について
    for(long long i=0;i<n;i++){
        sum1+=a[i];
        if(i%2==0){
            if(sum1<1){
                res1+=abs(1-sum1);
                sum1=1;
            }
        }
        else{
            if(sum1>-1){
                res1+=abs(-1-sum1);
                sum1=-1;
            }
        }
    }
    for(long long i=0;i<n;i++){
        sum2+=a[i];
        if(i%2==0){
            if(sum2>-1){
                res2+=abs(-1-sum2);
                sum2=-1;
            }
        }
        else{
            if(sum2<1){
                res2+=abs(1-sum2);
                sum2=1;
            }
        }
    }
    cout<<min(res1,res2)<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i< n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 29;
const double EPS = 1e-10;

int main(){
  ll n;
  while(cin >> n){
    ll n2 = 1;
    int cnt = 0;
    while(n2 < n){
      cnt++;
      n2 *= 3;
    }
    cout << cnt << endl;
  }
  return 0;
}

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

int main(){
int N,D;
  cin >> N >> D;
  if(N % (D*2+1) != 0)
    cout << (N / (D*2+1))+1 << endl;
  else 
    cout << N / (D * 2 + 1) << endl;


}

Measured memory_bytes: 256