akhauriyash/Code-Regression huggingface dataset:
N = int(input())
l = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

def func(length):
    if length == 1:
        return ["a"]
    else:
        output = []
        for s in func(length-1):
            for i in range(len(set(list(s)))+1):
                output.append(s + l[i])
        return output

ans = func(N)
ans.sort()
for a in ans:
    print(a)

Measured memory_bytes: 12976
X,K,D=list(map(int,input().split()))
if X<0:
    X=-X
q=X%D
p=X//D
if p>K:
    print(X-K*D)
else:
    r=K-p
    if r%2==0:
        print(q)
    else:
        print(D-q)

Measured memory_bytes: 9172
#include <stdio.h>
#include <math.h>
 
int main(void)
{
    int n,i;
    double x[100],y[100],s;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%lf",&x[i]);
    for(i=0;i<n;i++)scanf("%lf",&y[i]);
    s=0;
    for(i=0;i<n;i++)s+=fabs(x[i]-y[i]);
    printf("%.6f\n",s);
    s=0;
    for(i=0;i<n;i++)s+=pow(fabs(x[i]-y[i]),2);
    printf("%.6f\n",sqrt(s));
    s=0;
    for(i=0;i<n;i++)s+=pow(fabs(x[i]-y[i]),3);
    printf("%.6f\n",pow(s,1./3));
    s=0;
    for(i=0;i<n;i++)if(fabs(x[i]-y[i])>s)s=fabs(x[i]-y[i]);
    printf("%.6f\n",s);
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
using namespace std;
#define mod 1000000007
int main () {
    int h, w;
    cin >> h >> w;
    char c;
    long long v[h + 1][w + 1];
    for (int i = 0; i <= h; i ++) {
        v[i][0] = 0;
    }
    for (int i = 0; i <= w; i ++) {
        v[0][i] = 0;
    }
    v[1][1] = 1;
    for (int i = 1; i <= h; i ++) {
        for (int j = 1; j <= w; j ++) {
            cin >> c;
            if (i * j != 1) v[i][j] = 0;
            if (c == '.') {
                v[i][j] = (v[i][j] + v[i - 1][j] + v[i][j - 1]) % mod;
            }
        }
    }
    cout << v[h][w];
    return 0;
}


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

using namespace std;

int binpow(int n, int k)
{
	if (k == 0)
		return 1;
	if (k % 2)
		return binpow(n, k - 1) * n;
	else
	{
		int temp = binpow(n, k / 2);
		return temp * temp;
	}
}

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

	int n, k;
	cin >> n >> k;
	cout << k * binpow(k - 1, n - 1);

	return 0;
}


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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

bool same(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 105; i <= N; i += 2) {
    int cnt = 0;
    for (int j = 1; j <= N; j++) {
      if (i % j == 0)
        cnt++;
      if (cnt > 8)
        break;
    }
    if (cnt == 8)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())

l1 = 2 * (b - x/(a * a))
l2 = (2 * x) / (a * b)
if x >= a * a * b / 2:
    print(math.degrees(math.atan2(l1,a)))

else:
        print(math.degrees(math.atan2(b,l2)))


Measured memory_bytes: 3060
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int N = Integer.parseInt(stdin.next());
		double A[] = new double[N];
		double sum=0;
		
		for(int i=0;i<N;i++) {
			A[i] = Integer.parseInt(stdin.next());
		}
		
		for(int i=0;i<N;i++) {
			sum += 1/A[i];
		}
		
		out.println(1/sum);
		
		out.flush();
	}
	
}

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

using namespace std;

typedef pair<int,int> P;
typedef long long ll; 

#define int ll

const ll mod = 1e9 + 7;

main(){
	int n;
	int a[1000];
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];

	int ans = 0;
	for(int i=0;i<n;i++){
		if(i%2==0 && a[i]%2!=0) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
int main(void){
  int i,kind,pw,m[100],sum,min;
  sum=0;
  min=10000;
  scanf("%d %d",&kind,&pw);
  for(i=0;i<kind;i++){
    scanf("%d",&m[i]);
    sum+=m[i];
    if(m[i]<min){
      min=m[i];
    }
  }
  pw-=sum;
  printf("%d\n",kind+pw/min);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64

// editorial(りんごさん)
// a,b,c,d,eという5つのゴミがあるとする
// この時, 遠い方から拾っていったほうが良いのはわかる
// a, b, c, d, eを拾うためのコストは次のようになる
//  (2^2+1)(e-d) + (3^2+1)(d-c) + (4^2+1)(c-b) + (5^2+1)(b-a) + (6-2+1)a
// = 5e + 5d + 7c + 9b + 11a
// ここで, 5(e+d) + 7c + 9b + 11a
// という風に最初の二項以降は2ずつ増えていることがわかる
//
// ここで, 1度に拾う個数を決めておけば, その部分をまとめて拾えることがわかる
//
// editorial 前計算
// 累積和により, 求めることが可能
// 差分を考えることで, 累積和で求められる
// 差分の増加は
// (k+1)^2*x - k^2*x = (2*k+1)*x
// であるから, 差分を考えることで実装可能

signed main() {
	int n,x; cin>>n>>x;
	vector<int> a(n);
	for(int i=0;i<n;++i) cin>>a[i];

  vector<int> sm(n+1,0);
  for(int i=0;i<n;++i) {
    sm[i+1] += sm[i] + a[i];
  }
  
	auto _cost = [&](int k) {
                 int res=0, now=n;
                 res += 5*sm[now];
                 now -= k*2;
                 while (now > 0) {
                   // オーバーフロー対策
                   if(numeric_limits<int>::max()-res < sm[now]*2) {
                     return (1LL<<60);
                   }
                   res += sm[now]*2;
                   now -= k;
                 }
                 return res;
               };
	
	int ans = 1LL<<60;
	// kは分割数
	for(int k=1;k<=n;++k) {
		ans = min(ans, _cost(k) + k*x);	
	}
	ans += n * x;
	cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3328
import sys
sys.setrecursionlimit(10**7)

N, M = map(int, input().split())
P = [[] for i in range(N)]
L = [[] for i in range(M)]
for i in range(N):
    I = list(map(int, input().split()))
    for l in I[1:]:
        P[i].append(l-1)
        L[l-1].append(i)

P_visited = [0] * N
L_visited = [0] * M


# flgが立っていれば、人を見ているとする
def dfs(n, flg):
    if flg:
        P_visited[n] = 1
        for l in P[n]:
            if not L_visited[l]:
                dfs(l, flg ^ 1)
    else:
        L_visited[n] = 1
        for p in L[n]:
            if not P_visited[p]:
                dfs(p, flg ^ 1)


dfs(0, 1)
print("YES" if all(P_visited) else "NO")


Measured memory_bytes: 36812
ilist = list(map(int, input().split()))
ilist.sort()
ans = 0
if (ilist[0] - ilist[1]) % 2 != 0:
  ilist[0] += 1
  ilist[2] += 1
  ans += 1
ans += (ilist[1] - ilist[0]) // 2
ans += ilist[2] - ilist[1]
print(ans)


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

int main()
{
    int N,M,P,i,j,k,sum=0,gold=0,h,w,get;
    int x[100];

    for (i=0; ; i++)
    {
        cin>>N>>M>>P;
        if (N==0&&M==0&&P==0)
        {
            break;
        }
        for (j=1; j<N+1; j++)
        {
            cin>>x[j];
            sum=sum+x[j];
        }
        gold=sum*100;
        w=100-P;
        h=gold*w/100;
        
        for (k=1; ; k++)
        {
            if (k==M)
            {
                if(x[k]==0)
                {
                    cout<<0<<endl;
                    break;
                }
                    
                get=h/x[k];
                cout<<get<<endl;
                break;
            }
        }
        sum=0;
        h=0;
    }

    return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int n,w;
	int i;
	int* list;
	scanf("%d",&w);
	scanf("%d",&n);
	list = (int*)malloc(sizeof(int)*w);
	for(i = 0;i < w;i++)
	{
		list[i] = i+1;
	}
	for(i = 0;i < n;i++)
	{
		int a,b;
		scanf("%d,%d",&a,&b);
		list[a-1] ^= list[b-1];
		list[b-1] ^= list[a-1];
		list[a-1] ^= list[b-1];
	}
	for(i = 0;i < w;i++)
	{
		printf("%d\n",list[i]);
	}
	return 0;
}

Measured memory_bytes: 0
H, W, K = map(int, input().split())
c = [["*"]*(W+1)]
num_black = 0
for i in range(H):
    inputed = ["*"] + list(input())
    num_black += inputed.count("#")
    c.append(inputed)
num_black_row = [0]*(H+1)
num_black_col = [0]*(W+1)
for i in range(1, H+1):
    num_black_row[i] = c[i].count("#")
    for j in range(1, W+1):
        if c[i][j] == "#":
            num_black_col[j] += 1
ans = 0
from itertools import combinations
for n_row in range(0, 7):
    for n_col in range(0, 7):
        row_pattern = list(combinations(range(1, H+1), n_row))
        col_pattern = list(combinations(range(1, W+1), n_col))
        for rows in row_pattern:
            for cols in col_pattern:
                temp = 0
                if len(rows) != 0:
                    for row in rows:
                        temp += num_black_row[row]
                if len(cols) != 0:
                    for col in cols:
                        temp += num_black_col[col]
                        dbl = 0
                        for row in rows:
                            if c[row][col] == "#":
                                dbl += 1
                        temp -= dbl
                if num_black - temp == K:
                    ans += 1
print(ans)    
            

Measured memory_bytes: 68520
n=int(input())
li=[input() for i in range(n)]
ac=li.count("AC")
wa=li.count("WA")
tle=li.count("TLE")
re=li.count("RE")
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 16204
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static int p;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		p=s[1];
		var t=sc.S;
		var h=new int[p+1];
		var a=new long[s[0]+1];
		h[0]++;
		long ans=0;
		for(int i = s[0]-1;i>=0;i--) {
			a[i]=((t[i]-'0')*Fp(10,s[0]-i-1)+a[i+1])%p;
			if(s[1]==2||s[1]==5){
				if((t[i]-'0')%s[1]==0){ans+=i+1;}
			}
			else{ans+=h[a[i]];}
			h[a[i]]++;
		}
		Console.WriteLine("{0}",ans);
	}
	static long Fp(long x,long e){
		long r=1;
		while(e>0){
			if((e&1)>0){r*=x;r%=p;}
			x=(x*x)%p;
			e>>=1;
		}
		return r;
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 15328
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

ll n;
ll cnt[1001];
void solve(ll x){
    for(ll i=2; i*i<=x; i++){
        if(x%i==0){
            while(x%i==0){
                x/=i;
                cnt[i]++;
            }
        }
    }
    if(x>1) cnt[x]++;
}

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

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(ll i=2; i<=n; i++){
        solve(i);
    }
    ll ans=1;
    for(ll i=2; i<=1000; i++){
        if(cnt[i]) ans=(ans*(cnt[i]+1))%mod;
    }
    cout << ans;
    return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
ans = float('inf')
h.sort()
for i in range(N-K+1):
    if ans > h[i+K-1] - h[i]:
        ans = h[i+K-1] - h[i]
print(ans)

Measured memory_bytes: 7384
#include <iostream>
#include <string>

int bucket[26];

int main()
{
  std::string S;
  std::cin >> S;

  for ( char c : S ) {
    int index = int(c) - 97;
    bucket[index]++;
  }

  bool is_missing = false;
  for ( int i = 0; i < 26; i++ ) {
    if ( bucket[i] == 0 ) { 
      std::cout << char( i + 97 ) << std::endl;
      is_missing = true;
      break;
    }
  }
  if ( !is_missing ) std::cout << "None\n";
  return 0;
}


Measured memory_bytes: 512
# https://atcoder.jp/contests/abc072/tasks/arc082_a



N = gets.to_i
as = gets.split.map(&:to_i)

max = 0
as.each_with_object(Hash.new(0)) do |ai, hash|
  hash[(ai - 1).to_s] += 1
  hash[ai.to_s] += 1
  hash[(ai + 1).to_s] += 1

  this_max = [hash[(ai - 1).to_s], hash[ai.to_s], hash[(ai + 1).to_s]].max
  if this_max > max
    max = this_max
  end
end

puts max


Measured memory_bytes: 21364
r, c = map(int, input().split())

ans = []
for i in range(r):
    tmp = list(map(int, input().split()))
    tmp.append(sum(tmp))
    ans.append(tmp)
    str_tmp = [str(s) for s in tmp]
    str_tmp = " ".join(str_tmp)
    print(str_tmp)

tmp = []
for i in range(c+1):
    total = 0
    for j in ans:
        total += j[i]
    tmp.append(total)
    
str_tmp = [str(s) for s in tmp]
str_tmp = " ".join(str_tmp)
print(str_tmp)



Measured memory_bytes: 5680
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

R = [False]*(N+1)
D = []

p = 1
while True:
    if R[p]:
        break
    D.append(p)
    R[p] = True
    p = A[p-1]

m = D.index(p)
c = len(D)-m

if K <= m:
    print(D[K])
else:
    print(D[m+(K-m) % c])


Measured memory_bytes: 32316
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    string A, B;
    cin >> A >> B;
    if(A.size() > B.size()) {
        cout << "GREATER" << endl;
        return 0;
    } else if(A.size() < B.size()) {
        cout << "LESS" << endl;
        return 0;
    } else {
        rep(i, A.size()) {
            if(A[i] - '0' > B[i] - '0') {
                cout << "GREATER" << endl;
                return 0;
            } else if(A[i] - '0' < B[i] - '0') {
                cout << "LESS" << endl;
                return 0;
            }
        }
    }
    cout << "EQUAL" << endl;
    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, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();

int main() {
  int n;
  scanf("%d", &n);

  vector<int> x(n);
  int sum = 0;
  REP(i, n) {
    scanf("%d", &x[i]);
    sum += x[i];
  }

  int p = (int)round((double)sum / n);

  int vit = 0;

  REP(i, n) {
    vit += pow(x.at(i) - p, 2);
  }

  printf("%d\n", vit);

  return 0;
}


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

using namespace std;

#define int long long
#define ll long long
#define rep(i,a,b) for(ll i=a; i<b; i++)

const int mod=1e9+7;

void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

const int Z=3e5+5;
int n;
int a[Z];
int ans;

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    rep(i,1,n+1) cin >> a[i];
    for(int i=0; i<62; i++){
        int p=0,q=0;
        for(ll j=1; j<=n; j++){
            if(a[j]&(1LL<<i)) p++;
            else q++;
        }
        int z=(p*q)%mod;
        z*=power(2,i);
        z%=mod;
        add(ans,z);
    }
    cout << ans;
    return 0;
}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=998244353;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a;
	return 0;
}

Measured memory_bytes: 3656
n,m = map(int, input().split())
if n >= m:
  print(0)
  quit()
X = list(map(int, input().split()))
X = sorted(X)
M = max(X)
mi = min(X)
ans = M - mi
itl = []
for i in range(m-1):
  k = X[i] - X[i+1]
  itl.append(k)
itl =sorted(itl)
for j in range(n-1):
  ans += itl[j]
print(ans)


Measured memory_bytes: 13960
hashmap = {"AC":0, "WA":0, "TLE":0, "RE":0}
a = int(input())
for i in range(a):
    hashmap[str(input())] += 1
print("AC x " + str(hashmap["AC"]))
print("WA x " + str(hashmap["WA"]))
print("TLE x " + str(hashmap["TLE"]))
print("RE x " + str(hashmap["RE"]))

Measured memory_bytes: 9040
#include <iostream>
using namespace std;
typedef long long LL;

LL gcd(LL x, LL y){return y?gcd(y,x%y):x;}
LL lcm(LL x, LL y){return x/gcd(x,y)*y;}
// |S| s.t. S = {x | 0<=x<=m, x%a!=0,x%b!=0}
LL f(LL m, LL a, LL b){
//  cout << m/a << " " << m/b << " " << m/lcm(a,b) << endl;
  return m - (m/a + m/b - m/lcm(a,b));
}

int main(void){
  LL a,b,c,d;

  cin >> a >> b >> c >> d;
  cout << f(b,c,d)-f(a-1,c,d) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
#include<cctype>
const int INF=1e9;
using namespace std;

int main(){
    int n;
    cin>>n;
    cout<<"ABC"<<n<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner vd = new Scanner(System.in);
		int n = vd.nextInt();
		int x = vd.nextInt();
		int[] m = new int[n];
		int min = Integer.MAX_VALUE;
		for(int i=0; i<n;++i) m[i]= vd.nextInt();
		for(int i=0; i<n;++i) x = x - m[i];
		for(int i=0; i<n;++i) {
			if(min>m[i]) min = m[i];
		}
		int ans = n + x/min;
		System.out.println(ans);

	}

}


Measured memory_bytes: 21844
n, k = map(int, input().split())
sunuke=[[]]*n
for i in range(k):
    d=int(input())
    lid=list(map(int, input().split()))
    for i2 in range(d):
        if d not in sunuke[lid[i2]-1]:
            sunuke[lid[i2]-1]=sunuke[lid[i2]-1] + [d]
ans=0
for item in sunuke:
    if item==[]:
        ans+=1
print(ans)

Measured memory_bytes: 9084
local h,w=io.read("n","n")
local c={}
for i=0,9 do
    c[i]={}
    for j=0,9 do
        c[i][j]=io.read("n")
    end
end

--Warshall-Floyd法
for k=0,9 do
    for i=0,9 do
        for j=0,9 do
            c[i][j]=math.min(c[i][j],c[i][k]+c[k][j])
        end
    end
end

local counter=0
for i=1,h do
    for j=1,w do
        local input=io.read("n")
        if input>=0 then
            counter=counter+c[input][1]
        end
    end
end
print(counter)

Measured memory_bytes: 2704
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 512

char s[N];
int dp[N][N][N];

int get(int x, int y, int z)
{
    if(x<0||y<0||z<0) return 0;
    return dp[x][y][z];
}

int main()
{
    int n, m;
    scanf("%s%d", s, &m), n = strlen(s);
    for(int i=0;i<n;++i)for(int j=0;j<n;++j)for(int k=0;k<=m;++k)
        dp[i][j][k] = s[i] == s[n-j-1] ?
            get(i-1,j-1,k)+1 :
            std::max(std::max(get(i-1,j,k),get(i,j-1,k)), get(i-1,j-1,k-1)+!!k);
    int ans = 0;
    for(int i=0;i<n;++i) ans = std::max(ans, get(i,n-i-1,m)*2-1);
    for(int i=0;i<n;++i) ans = std::max(ans, get(i,n-i-2,m)*2);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 181660
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

class Main {
    
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        List<Integer> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(scanner.nextInt());
        }
        scanner.close();
        Collections.sort(list);
        for(int i=0; i<list.size()-1; i++){
            if(list.get(i).compareTo(list.get(i+1))==0){
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
    
}

Measured memory_bytes: 87956
n = int(input())
h = list(map(int,input().split()))
dp = [0] * n

dp[1] = abs(h[0] - h[1])

for i in range(2,n):
    n = abs(h[i] - h[i-2]) + dp[i-2]
    m = abs(h[i] - h[i-1]) + dp[i-1]
    if n >= m:
        dp[i] = m
    else:
        dp[i] = n

print(dp[-1])

Measured memory_bytes: 20540
#include <bits/stdc++.h>
using namespace std;
long long ans;
int counta,countb,countc;
int main() {
	int n;
	cin>>n;
	vector<int>a(n),b(n),c(n);
	for (int i=0;i<n;++i) cin>>a[i];
	for (int i=0; i<n;++i) cin>>b[i];
	for (int i=0; i<n;++i) cin>>c[i];
	sort(a.begin(), a.end()),sort(b.begin(), b.end()),sort(c.begin(), c.end());
	for (int i=0;i<n;++i) {
		long long mona = distance(a.begin(), lower_bound(a.begin(), a.end(), b[i]));
		long long monc = distance(upper_bound(c.begin(), c.end(), b[i]), c.end());
		ans+=mona*monc;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1001001001001;

int main() {
    int a, b, q;
    cin >> a >> b >> q;
    ll s[a], t[b];
    for (int i = 0; i < a; i++) cin >> s[i];
    for (int i = 0; i < b; i++) cin >> t[i];
    for (int i = 0; i < q; i++) {
        ll x;
        cin >> x;
        ll ans = INF;
        int idx1 = lower_bound(s, s + a, x) - s;
        int idx2 = lower_bound(t, t + b, x) - t;
        if (idx1 < a && idx2 < b) ans = min(ans, abs(x - max(s[idx1], t[idx2])));
        if (idx1 > 0 && idx2 < b) ans = min(ans, abs(x - s[idx1 - 1]) + abs(s[idx1 - 1] - t[idx2]));
        if (idx1 > 0 && idx2 < b) ans = min(ans, abs(x - t[idx2]) + abs(t[idx2] - s[idx1 - 1]));
        if (idx1 < a && idx2 > 0) ans = min(ans, abs(x - t[idx2 - 1]) + abs(t[idx2 - 1] - s[idx1]));
        if (idx1 < a && idx2 > 0) ans = min(ans, abs(x - s[idx1]) + abs(s[idx1] - t[idx2 - 1]));
        if (idx1 > 0 && idx2 > 0) ans = min(ans, abs(x - min(s[idx1 - 1], t[idx2 - 1])));
        cout << ans << endl;
    }
}

Measured memory_bytes: 2816
#![allow(non_snake_case, dead_code)]
use std::collections::VecDeque;
use std::io::BufRead;

struct MyReader<R: BufRead> {
    __reader: R,
    queue: VecDeque<String>,
}
impl<R: BufRead> MyReader<R> {
    fn new(reader: R) -> MyReader<R> {
        MyReader {
            __reader: reader,
            queue: VecDeque::new(),
        }
    }
    fn read(&mut self) -> String {
        if self.queue.len() == 0 {
            self.__readFromStdin()
        };
        self.queue.pop_front().unwrap()
    }
    fn readN(&mut self) -> i32 {
        self.read().parse().ok().expect("failed paring")
    }
    fn readUN(&mut self) -> usize {
        self.read().parse().ok().expect("failed paring")
    }
    fn readT<T: std::str::FromStr>(&mut self) -> T {
        self.read().parse().ok().expect("failed parsing")
    }

    fn __readFromStdin(&mut self) {
        let mut s = String::new();
        self.__reader.read_line(&mut s).unwrap();
        for it in s.trim().split_whitespace() {
            self.queue.push_back(it.to_string());
        }
    }
}
//*****************************************
fn main() {
    let stdin = std::io::stdin();
    let input = stdin.lock();
    println!("{}", run(input))
}

fn run<R: BufRead>(reader: R) -> String {
    let mut myReader = MyReader::new(reader);
    let x = myReader.readUN();
    (if x == 1 { 0 } else { 1 }).to_string()
}

Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int bfs(const vector<string> &v, int x, int y) {
    int H = v.size(), W = v[0].size();
    vector<vector<int>> dist(H, vector<int>(W, -1));
    queue<pair<int, int>> que;

    int res = 0;
    que.push({x, y});
    dist[x][y] = 0;
    while (!que.empty()) {
        int x = que.front().first, y = que.front().second;
        res = max(res, dist[x][y]);
        que.pop();
        for (int dir = 0; dir < 4; ++dir) {
            int nx = x + dx[dir], ny = y + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (v[nx][ny] == '#') continue;
            if (dist[nx][ny] == -1) {
                dist[nx][ny] = dist[x][y] + 1;
                que.push({nx, ny});
            }
        }
    }

    return res;
}

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> v(H);
    for (int i = 0; i < H; ++i) { cin >> v[i]; }

    int res = 0;
    for (int x = 0; x < H; ++x) {
        for (int y = 0; y < W; ++y) {
            if (v[x][y] == '#') continue;
            res = max(res, bfs(v, x, y));
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp26
{
    class Program
    {
        static void Main(string[] args)
        {
			int For = int.Parse(Console.ReadLine());
            Decimal[] Ar = Array.ConvertAll(Console.ReadLine().Split(' '), decimal.Parse);
          Decimal Temp = 1;
          Array.Sort(Ar);
          if (Ar[0] == 0){
            Console.WriteLine("0");
            return;
          }
            for (int i = 0; i < For; i++){
              try{
              Temp = Temp * Ar[i];}
              catch{
                Console.WriteLine("-1");
                return;
              }
              if(Temp > 1000000000000000000) break;
            }
          if (Temp > 1000000000000000000){
            Console.WriteLine("-1");
          }
          else Console.WriteLine(Temp);
        }
          
    }
}


Measured memory_bytes: 36976
n = int(input())
a = list(map(int, input().split()))
table = [0] * 10**5
for i in range(n):
    table[a[i]] += 1
    if a[i] > 0:
        table[a[i] - 1] += 1
    if a[i] < 10**5 - 1:
        table[a[i] + 1]  += 1
print(max(table))

Measured memory_bytes: 13964
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A, B;
		A = sc.nextLong();
		B = sc.nextLong();
		sc.close();

		long gcd = 0;
		for (int i = 1; i < Math.max(A, B); i++) {
			if (A % i == 0 && B % i == 0) {
				gcd = i;
			}
		}
		long lcm = A * B / gcd;
		System.out.println(lcm);
	}
}

Measured memory_bytes: 21844
use proconio::{input, fastout};

const MOD: i32 = 2019;

#[fastout]
fn main() {
    input! {
        s: String,
    }

    let ss = s.chars().rev().map(|n| n.to_string().parse::<i32>().unwrap()).collect::<Vec<i32>>();

    let mut r = vec![0; MOD as usize];
    let mut digit = 1;
    let mut total = 0;
    r[0] = 1;
    for i in 0..s.len() {
        total += ss[i] * digit;
        total %= MOD;
        r[total as usize] += 1;
        digit = (digit * 10) % MOD;
    }

    let count : i32 = r.iter().filter(|&n| n > &0).map(|n| n * (n-1)/ 2).sum();

    println!("{}", count);
}

Measured memory_bytes: 3164
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N+2)
	a[0] = 0
	for i := 1; i <= N; i++ {
		a[i] = getInt()
	}
	a[N+1] = 0
	// out(a)
	b := make([]int, N+2)
	for i := 1; i < N+2; i++ {
		b[i] = b[i-1] + abs(a[i]-a[i-1])
	}
	// out(b)

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	for i := 1; i < N+1; i++ {
		x := b[i-1] - b[0]
		y := b[N+1] - b[i+1]
		z := abs(a[i+1] - a[i-1])
		fmt.Fprintln(w, x+y+z)
	}
}


Measured memory_bytes: 4608
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long a = scan.nextLong();
    long b = scan.nextLong();

    if (a % 2 == b % 2) {
      System.out.println((b - a) / 2);
    } else {
      System.out.println(Math.min(n - b, a - 1) + 1 + (Math.abs(b - a - 1) / 2));
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long X;
  cin >> X;

  long double cur = 100.0;
  long long cnt = 0;

  while(cur < X){
    cnt++;
    long long tmp = cur *= 1.01;
    cur = tmp;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int L;
  cin >> L;
  int a = L*L*L;
  int b = 3*3*3;
  double result = (double) a / (double) b;
  cout << fixed << setprecision(10);
  cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
long long i,j,k,l,m,n;
while(cin>>m>>n){
    l=0;
    int x[m];
    for(i=0;i<m;i++) {cin>>x[i];  }
    sort(x,x+m);
    for(i=0;i<m-n;i++)l+=x[i];
    if(l<0) l=0;
    cout<<l<<endl;
    }
 return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int g[3][3] = {};
  REP(i, 3) {
    REP(j, 3) {
      cin >> g[i][j];
    }
  }
  REP(i, 2) {
    for (int j = i+1; j < 3; j++) {
      if (g[i][0]-g[j][0] != g[i][1]-g[j][1] ||
	  g[i][0]-g[j][0] != g[i][2]-g[j][2] ||
	  g[i][1]-g[j][1] != g[i][2]-g[j][2]) {
	dump("No");
	return 0;
      }
    }
  }
  REP(i, 2) {
    for (int j = i+1; j < 3; j++) {
      if (g[0][i]-g[0][j] != g[1][i]-g[1][j] ||
	  g[0][i]-g[0][j] != g[2][i]-g[2][j] ||
	  g[1][i]-g[1][j] != g[2][i]-g[2][j]) {
	dump("No");
	return 0;
      }
    }
  }
  dump("Yes");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<lu> vu;
typedef vector<v> vv;
typedef vector<vu> vvu;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
typedef pair<lu, lu> puu;
typedef vector<puu> vpuu;
const ll MOD = 1000000007;
const ld PI = 2 * acos(0.0);
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
  if (y > x) x = y;
#define amin(x, y) \
  if (y < x) x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
  if (f) yes else no;
#define noo \
  { no return; }
#define mod 1000000007

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
  vector<T> a = vector<T>(n + oneIndexed);

  for (ll i = 0; i < n; i++) {
    T p;
    cin >> p;
    a[i + oneIndexed] = p;
  }

  return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
  if (end == -1) end = sz(a) - 1;
  for (ll i = begin; i <= end; i++) {
    // printf("%lu ", a[i]);
    cout << a[i] << " ";
  }
  cout << endl;
}

template <typename T, typename A>
void papair(vector<T, A> const &a, ll begin = 0, ll end = -1) {
  if (end == -1) end = sz(a) - 1;
  for (ll i = begin; i <= end; i++) {
    // printf("%lu ", a[i]);
    cout << a[i].first << " " << a[i].second << endl;
  }
}

#define MAX (ll)3e5
v visited(MAX, 0);
v parents(MAX);
v depths(MAX);
vv dp(MAX, v(2, 1));
void dfs(vv &adjList, ll curr, ll prev, ll depth) {
  visited[curr] = 1;
  ll c = 0;
  for (auto neigh : adjList[curr]) {
    if (neigh == prev) continue;
    if (visited[neigh] == 0) {
      // parents[neigh] = curr;
      dfs(adjList, neigh, curr, depth + 1);
      dp[curr][0] = (dp[curr][0] * (dp[neigh][0] + dp[neigh][1]) % mod) % mod;
      dp[curr][1] = (dp[curr][1] * dp[neigh][0]) % mod;

      c++;
    } else if (visited[neigh] == 1) {
    }
  }
  //   if (c == 0) {
  //     dp[curr][0] = 1;
  //     dp[curr][1] = 1;
  //   }
  visited[curr] = 2;
}

void solve() {
  // ll n;
  // cin>>n;
  // vector<ll> arr = ga(n);
  ll n;
  cin >> n;
  ll m = n - 1;
  vv adjList(n + 1, v(0));
  for (ll i = 0; i < m; i++) {
    ll a, b;
    cin >> a >> b;
    adjList[a].push_back(b);
    adjList[b].push_back(a);
  }
  dfs(adjList, 1, -1, 0);
  cout << (dp[1][0] + dp[1][1]) % mod << '\n';
}

int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // ll t;cin >> t;while(t--)
  solve();
  return 0;
}

Measured memory_bytes: 37504
#include <stdio.h>

int count = 0;

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

void mergeSort(int a[], int left, int right) {
	int mid;

	if (left + 1 < right) {
		mid = (left + right) / 2;
		mergeSort(a, left, mid);
		mergeSort(a, mid, right);
		merge(a, left, mid, right);
	}
}

int main(void) {
	int a[500000];
	int n, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	
	mergeSort(a, 0, n);

	for (i = 0; i < n; i++) {
		printf("%d", a[i]);
		if (i != n - 1) {
			putchar(' ');
		}
	}
	putchar('\n');
	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 5620
#include<iostream>
#include<string>

using namespace std;

int main(){
	int n,a,b,y=0,yb=0;
	string s;
	cin>>n>>a>>b>>s;
	
	
	for(int i=0;i<n;i++){
		if(s[i]=='a'){
			if(a+b>y) {
				cout<<"Yes"<<endl;
				y++;
			}
			else cout<<"No"<<endl;
		}
		else if(s[i]=='b'){
			if(a+b>y&&b>yb){
				cout<<"Yes"<<endl;
				yb++;
				y++;
			}
			else cout<<"No"<<endl;
		}
		else if(s[i]=='c') cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int i=0;
  int j=n/2;
  if(n%2==0 && s.substr(0,j)==s.substr(j,n))
     cout<<"Yes\n";
  else
     cout<<"No\n";
  return 0;
}


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

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 3000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*ここから*/
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int maxx = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(maxx<A[i]){
            maxx = A[i];
        }
    }
    //cout << maxx << endl;
    bool b = false;
    int maxd=0;
    int count = 0;
    for(int i=0;i<N;i++){
        if(A[i]==maxx){
            count++;
        }
        if(maxd<A[i]&&maxx>A[i]){
            maxd = A[i];
        }
        if(count==2){
            b = true;
        }
    }
    //cout << maxx << endl;
    if(b==true){
        for(int i=0;i<N;i++){
            cout << maxx << endl;
        }
    }else{
        for(int i=0;i<N;i++){
            if(A[i]!=maxx){
                cout << maxx << endl;
            }else{
                cout << maxd << endl;
            }
        }
    }
}

Measured memory_bytes: 3924
import math
import sys

(x, k, d) = list(map(int, input().split()))

x = abs(x)

v = math.floor(x / d)

if v > k:
  x = abs(x - k * d)
  print(x)
  sys.exit()

x -= v * d
k -= v
x = abs(x)

if k % 2 == 0:
  print(x)
else:
  print(abs(x - d))

Measured memory_bytes: 9148
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        v.emplace_back(k);
    }
    auto x = minmax_element(v.begin(), v.end());
    cout << *x.second - *x.first << "\n";
    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 ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

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

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

int main(){
  string s, t;
  cin >> s >> t;
  
  bool ans = false;
  
  for(int i = 0; i < s.size(); i++){
    if(s == t){
      ans = true;
      break;
    }
    s = s.back() + s.substr(0, s.size() - 1);
  }
  
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

ll x,k,d;

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	scanf("%lld %lld %lld",&x,&k,&d);
	if(x<0) x=-x;

	ll ans;

	if(x/d>=k){
	  ans=x-k*d;
	}
	else{
		k-=x/d;
		ll rest=x%d;
		if(k%2==0){
			ans=rest;
		}
		else{
			ans=d-rest;
		}
	}

	printf("%lld\n",ans);

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000000000
using ll = long long;


int main(){
  int n;
    cin>>n;
  vector<int> h(n);
  rep(i,n) cin >> h.at(i);
  ll ans = h.at(0);
  rep(i,n-1){
    if(h.at(i)<h.at(i+1))ans+=(h.at(i+1)-h.at(i));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
T = input()

x = {}
for s in S:
    if s in x:
        x[s] += 1
    else:
        x[s] = 1

y = {}
for t in T:
    if t in y:
        y[t] += 1
    else:
        y[t] = 1

x2 = list(x.values())
x2.sort()
y2 = list(y.values())
y2.sort()


if len(x2) != len(y2):
    print("No")
else:
    for i in range(len(x2)):
        if x2[i] != y2[i]:
            print("No")
            break
    else:
        print("Yes")

Measured memory_bytes: 3632