akhauriyash/Code-Regression huggingface dataset:
#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 pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define null 0
#define pi 3.14159265358979323846
#define all(x) x.begin(), x.end()
#define d0(x) cout<<x<<" ";
#define d1(x) cout<<x<<"\n";
#define d2(x,y) cout<<x<<" "<<y<<"\n";
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n";
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n";
 
//#define ordered_set tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
template<typename T, typename U> static inline void amin(T &x, U y){if (y < x)x = y;} 
template<typename T, typename U> static inline void amax(T &x, U y){if (y > x)x = y;} 
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const  ll mod= 1000000007  ; 
const long long inf = (ll)1e18+17;
const int inff = 1500000000;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int test_case=0;
void solve(){ 
    ll n,k;cin>>n>>k;
    ll a[n+10],ans[n+10];
    for(int i=0;i<n;i++)cin>>a[i];
    ans[0]=0;
    for(int i=1;i<n;i++){
        ans[i]=inf;
        for(int j=i-1,p=0;j>=0 && p<k;j--,p++)
            amin(ans[i],ans[j]+abs(a[j]-a[i]));
    }
    cout<<ans[n-1]<<endl;
}
 
int main()
{  
    clock_t tt;tt = clock(); 
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    if(test_case==1)
    cin>>t;
    //pre();
    for(int i=1;i<=t;i++){
       //cout<<"Case #"<<i<<": ";
       solve();
    }
    tt = clock() - tt; double time_taken = ((double)tt)/CLOCKS_PER_SEC;   
    //printf("code took %f seconds to execute \n", time_taken); 
    return 0;
}
 
// ============== Notes =============== //
// common bugs
// - remove ios_base for interactive problems
// - int overflow (especially intermediate expressionns)
// - array bounds (indices bigger than MAXN?)
// - special cases (n=1? graph not connected?)
// - re-initialize efficiently between test cases

Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

ll dp[10][10][10][2];
int main(void) {
    ll n;
    cin >> n;

    // 先頭がi
    string s = to_string(n);
    ll sz = s.size();
    dp[0][0][0][0] = 1;
    REP(i, sz) REP(j, 10) REP(l, 10) REP(k, 2) {
        ll lim = k==1 ? 9 : s[i]-'0';
        REP(d, lim+1) {
            ll nj = j;
            if(j == 0) nj = d;
            dp[i+1][nj][d][k||d<lim] += dp[i][j][l][k];
        } 
    }

    ll ret = 0;
    FOR(i, 1, 10) FOR(j, 1, 10) {
        ll tmp1 = dp[sz][i][j][0] + dp[sz][i][j][1];
        ll tmp2 = dp[sz][j][i][0] + dp[sz][j][i][1];
        ret += tmp1*tmp2;
    }
    cout << ret << endl;

    return 0;
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int n, maxw;
  cin >> n >> maxw;
  vecll v(n), w(n);
  rep(i,n){
    cin >> v[i] >> w[i];
  }

  vecll2(dp, n+1, maxw+1);

  rep(i,n){
    rep(j,maxw+1){
      if(j-w[i]>=0){
        ll m1 = v[i] + dp[i][j-w[i]];
        ll m2 = v[i] + dp[i+1][j-w[i]];
        ll m3 = dp[i][j];
        dp[i+1][j] = max({m1, m2, m3});
      } else {
        dp[i+1][j] = dp[i][j];
      }
    }
  }

  prt(dp[n][maxw]);

}



Measured memory_bytes: 10828
#include<stdio.h>

int main(void){
    int i,j,k,l,f,N,M;

    char a[50][50],b[50][50];

    scanf("%d %d",&N,&M);

    for(i = 0;i < N;i++)
        scanf("%s",&a[i][0]);

    for(i = 0;i < M;i++)
        scanf("%s",&b[i][0]);

    for(i = 0;i < N - M + 1;i++)
        for(j = 0;j < N - M + 1;j++){
            f = 1;
            for(k = 0;k < M;k++){
                for(l = 0;l < M;l++){
                    if(a[i + k][j + l] != b[k][l])
                        f = 0;
                }
            }
            if(f == 1){
                printf("Yes\n");
                return 0;
            }
        }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n, k, q int
	fmt.Scan(&n, &k, &q)
	a := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Scan(&a[i])
	}

	score := make([]int, n)
	for i := 0; i < q; i++ {
		score[a[i]-1]++
	}

	for i := 0; i < n; i++ {
		if k-(q-score[i]) > 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 5888
a,b,m = map(int,input().split())
a_inputs = [int(i) for i in input().split()]
b_inputs = [int(i) for i in input().split()]
x_inputs = [[int(j) for j in input().split()]for i in range(m)]

ans = min(a_inputs)+min(b_inputs)

for xyc in x_inputs:
    cost = a_inputs[xyc[0]-1]+b_inputs[xyc[1]-1]-xyc[2]
    if cost<ans:
        ans= cost
print(ans)

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

public class Main{
     public static void main(String[] args){
InputStreamReader is = new InputStreamReader(System.in);       
   BufferedReader br = new BufferedReader(is);

int x = 0;

try{
String str = br.readLine();
                x = Integer.parseInt(str);

 }catch(IOException e){}

double i = Math.pow(x, 3);

int num = (int)i;
System.out.println(num);




}
}

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

int main(){
  int ining;
  vector<int> result;

  cin>>ining;

  for(int i=0;i<ining;++i){
    int out_count=0;
    int score=0;
    string event;
    bool first=false;
    bool second=false;
    bool third=false;
    
    while(out_count!=3){
      cin>>event;

      if(event=="HIT"){
	if(third==true){
	  third=false;
	  score++;
	}
	if(second==true){
	  third=true;
	  second=false;
	}
	if(first==true){
	  second=true;
	}
	first=true;
      }

      else if(event=="HOMERUN"){
	if(first==true && second==true && third==true){
	  score+=4;
	  first=false;
	  second=false;
	  third=false;
	}
	else if((first==true && second==true && third==false) ||
		(first==true && second==false && third==true) ||
		(first==false && second==true && third==true)){
	  score+=3;
	  first=false;
	  second=false;
	  third=false;
	}
	else if((first==true && second==false && third==false) ||
		(first==false && second==true && third==false) ||
		(first==false && second==false && third==true)){
	  score+=2;
	  first=false;
	  second=false;
	  third=false;
	}
	else if(first==false && second==false && third==false)
	  score++;
      }

      else if(event=="OUT")
	out_count++;
    }
    result.push_back(score);
  }
  for(auto i:result)
    cout<<i<<endl;
}
	  

Measured memory_bytes: 3056
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int margin = 0;
    for (char c : s) {
        if (c == 'g') {
            if (margin > 0) {
                ans++;
                margin--;
            } else {
                margin++;
            }
        } else {if (margin>0){
                margin--;
            } else{
                ans--;
                margin++;
            }

        }
    }

    cout << ans << endl;
    return 0;
}
//long long n,t;
//long long a[100005];
//long long uru[100005]={0};
//cin>>n>>t;
//for(int i=0;i<n;i++){
//cin>>a[i];
//}
//#include<stdio.h>
//#include<algorithm>
//using namespace std;
//char in[110000];
//int main(){
//    scanf("%s",in);
//    int ret=0;
//    for(int i=0;in[i];i++){
//        if(i&&in[i]!=in[i-1])ret++;
//    }
//    printf("%d\n",ret);
//}

//int a,b;scanf("%d%d",&a,&b);
//for(int i=0;i<a;i++)scanf("%d",p+i);
//#include <iostream>
//#define REP(i,n) for (int i=0;i<(n);i++)

//int main() {
//
//    std::cout << "Hello, World!" << std::endl;
//    return 0;
//}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
N = int(input())
p = list(map(int,input().split()))

sort_p = sorted(p)
number = 0

for n in range(len(p)):
  if p[n] != sort_p[n]:
    number += 1

if number == 0 or number == 2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec_1line<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    // const N: usize = 3;
    // const A: [usize; N] = [3,1,2];
    // const B: [usize; N] = [2,5,4];
    // const C: [usize; N-1] = [3,6];
    let N: usize = read();
    // let A: [usize; N]   = read_vec_1line;
    // let B: [usize; N]   = read_vec_1line;
    // let C: [usize; N-1] = read_vec_1line;
    let A = read_vec_1line::<usize>();
    let B = read_vec_1line::<usize>();
    let C = read_vec_1line::<usize>();

    let mut ans: usize = 0;
    for i in 0..N {
        let k: usize = A[i];
        ans += B[k-1];
        if i < N-1 {
            if A[i+1] == k+1 && k != N {
                ans += C[k-1]
            } else {
                continue;
            }
        } else {
            continue;
        }
    }
    println!("{}", ans);
}

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

using namespace std;
long long int arra[201010];
long long int B[201010];
long long int C[201010];
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}

int main()
{
	long long int p,q,r,s,t,u,v,w,x,y,z,i,j,k,l,m,n,sum=0;
	cin>>n>>m;
	vector< pair <int, int> >apu; 
	for(i=0;i<=n-1;i++)
	{
		cin>>arra[i];
	}
	sort(arra,arra+n);
	for(i=0;i<=m-1;i++)
	{
		cin>>B[i]>>C[i];
		 apu.push_back( make_pair(B[i],C[i]) ); 
		
	}
sort(apu.begin(), apu.end(), sortbysec); 
	j=0;
	x=0;
	for(i=m-1;i>=0;i--)
	{
		long long int cnt=0;
        if(x<n)
        while (arra[x]<apu[i].second)
        {
            arra[x]=apu[i].second;
            cnt++;
            x++;
            if(x==n)
                break;
            if(cnt==apu[i].first)
                break;
        }
        else
            break;
	}
	for(i=0;i<=n-1;i++)
	{
		//cout<<arra[i]<<" ";
		sum=sum+arra[i];
	}
	cout<<sum;
	

}

Measured memory_bytes: 4472
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
		String[] data = input.split(" ");
		int a = Integer.parseInt(data[0]);
		int b = Integer.parseInt(data[1]);
		int c = Integer.parseInt(data[2]);

		if ((0 <= a && a <= 100) && (0 <= b && b <= 100)
				&& (0 <= c && c <= 100)) {
			if ((a < b) && (b < c)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}

}



Measured memory_bytes: 26188
#define Bobyama
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int A, P;

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

  cin >> A >> P;
  P += A*3;

  cout << P/2 << endl;

  return 0;
}


Measured memory_bytes: 888
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Convert;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var _N = cin.Read;
            var N = _N.ToCharArray();
            if ((N[0] == N[1] && N[0] == N[2]) || (N[1] == N[2] && N[1] == N[3]))
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }


        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 13268
n  = int(input())
a = list(map(int, input().split()))
a_sorted = sorted(a)
ai = max(a)

low = 0
high = len(a_sorted) - 1

val = 10 ** 9 ##aj候補
absd = 10 ** 9 ##差分

while low <= high:
    mid = (low + high) // 2
    guess = a_sorted[mid]
    d = (ai / 2) - guess
    if absd > abs(d):
        absd = min(absd, abs(d))
        val = guess
    if d < 0:
        high = mid - 1
    else:
        low = mid + 1
print('{} {}'.format(ai, val))

Measured memory_bytes: 14052
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  string s;cin>>s;int k;cin>>k;
  string ss = s;
  vector<string> z;
  vector<string> ans;
  sort(ss.begin(),ss.end());
  ss.erase(unique(ss.begin(), ss.end()), ss.end());
  for(int i = 0; ss.size() > i; i++){
    for(int j = 0; s.size() > j; j++){
      if(s[j] == ss[i]){
        z.push_back(s.substr(j));
      }
    }
    for(int i = 0; z.size() > i; i++){
      for(int j = 0; min(k+1,(int)z[i].size()) > j; j++){
        ans.push_back(z[i].substr(0,j+1));
      }
    }
    sort(ans.begin(),ans.end());
    ans.erase(unique(ans.begin(),ans.end()),ans.end());
    if(ans.size() >= k){
      cout << ans[k-1] << endl;
      return 0;
    }
    z.clear();

  }
}

Measured memory_bytes: 17788
n=int(input())
a = list(map(int,input().split()))

p = 10**9+7
ans = 0
for i in range(60):
    x = 1<<i
    one = sum(1 for j in a if j&x)
    ans += pow(2,i,p)*one*(n-one)

print(ans%p)


Measured memory_bytes: 42156
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
struct pnode{int a,b,c;}p[300100];
bool operator <(pnode p,pnode q) {return p.a-p.b>q.a-q.b;}
struct node{int a,b;};
bool operator <(node p,node q) {return p.a-p.b>q.a-q.b;}
priority_queue<node> q;
int n,na,nb,nc;
ll f[300300],g[300300];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
	na=read();nb=read();nc=read();n=na+nb+nc;
	rep(i,1,n) 
	{
		p[i].a=read();p[i].b=read();p[i].c=read();
	}
	sort(p+1,p+1+n);
	//rep(i,1,n) cout << p[i].a << " " << p[i].b << " " << p[i].c << endl;
	ll sum=0;
	rep(i,1,na) 
	{
		node tmp;
		tmp.a=p[i].a;tmp.b=p[i].c;
		q.push(tmp);sum+=p[i].a;
	}
	f[na]=sum;
	rep(i,na+1,na+nc)
	{
		node now=q.top();
		if (now.a-now.b<p[i].a-p[i].c)
		{
			sum-=now.a;sum+=now.b;
			q.pop();
			node tmp;
			tmp.a=p[i].a;tmp.b=p[i].c;sum+=p[i].a;
			q.push(tmp);
		}
		else sum+=p[i].c;
		f[i]=sum;
	}
	sum=0;
	while (!q.empty()) q.pop();
	//rep(i,1,n) cout << f[i] << " ";cout << endl;
	per(i,n,n-nb+1)
	{
		node tmp;
		tmp.a=p[i].b;tmp.b=p[i].c;
		q.push(tmp);sum+=p[i].b;
	}
	g[n-nb+1]=sum;
	per(i,n-nb,na+1)
	{
		node now=q.top();
		//cout << now.a << " " << now.b << endl;
		if (now.a-now.b<p[i].b-p[i].c)
		{
			sum-=now.a;sum+=now.b;
			q.pop();
			node tmp;
			tmp.a=p[i].b;tmp.b=p[i].c;sum+=p[i].b;
			q.push(tmp);
		}
		else sum+=p[i].c;
		g[i]=sum;
	}
	ll ans=0;
	//rep(i,1,n) cout << g[i] << " ";cout << endl;
	rep(i,na,n-nb+1) ans=max(ans,f[i]+g[i+1]);
	printf("%lld",ans);
	return 0;
}
		


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

using namespace std;

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

const int N = 55;

int n, m;
ll Pass[N];
vector <pii> Adj[N];

bool DFS(int x, int y, int i, int p = 0)
{
    if(x == y)  return true;

    for(int k = 0; k < Adj[x].size(); k++)
    {
        int z = Adj[x][k].first;
        int j = Adj[x][k].second;

        if(z == p)  continue;

        Pass[i] |= (1LL << j);

        if(DFS(z, y, i, x)) return true;

        Pass[i] &= ~(1LL << j);
    }

    return false;
}

ll Rec(int i = 0, int k = 0, ll Mask = 0)
{
    if(i == m)
    {
        ll Res = 0;

        for(int j = 1; j < n; j++)
            if(!(Mask & (1LL << j)))
                Res++;

        Res = 1LL << Res;

        return k & 1 ? -Res : +Res;
    }

    return Rec(i + 1, k, Mask) + Rec(i + 1, k + 1, Mask | Pass[i]);
}

int main()
{
    cin >> n;

    for(int i = 1; i < n; i++)
    {
        int x, y;   scanf("%d%d", &x, &y);

        Adj[x].emplace_back(y, i);
        Adj[y].emplace_back(x, i);
    }

    cin >> m;

    for(int i = 0; i < m; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        DFS(x, y, i);
    }

    cout << Rec() << endl;
}


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

int main()
{
	stack<int> staIn;
	string strIn;
	int nTemp = 0;
	int na = 0, nb = 0;
	while (cin >> strIn)
	{
		if (isdigit(strIn[0]))
		{
			nTemp = stoi(strIn);
			staIn.push(nTemp);
		}
		else
		{
			nb = staIn.top();
			staIn.pop();
			na = staIn.top();
			staIn.pop();
			switch (strIn[0])
			{
			case '+':
				staIn.push(na + nb);
				break;
			case '-':
				staIn.push(na - nb);
				break;
			case '*':
				staIn.push(na*nb);
				break;
			}
		}
	}
	cout << staIn.top() << endl;
	return 0;
}


Measured memory_bytes: 3160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int R = sc.nextInt();
		if (N < 10) {
			System.out.println(R + 100 * (10 - N));
		} else {
			System.out.println(R);
		}
	}
}


Measured memory_bytes: 22612
//created by Whiplash99
import java.io.*;
import java.util.*;
public class Main
{
    private static long countBits(long N)
    {
        long count=0;
        while (N>0)
        {
            count+=N&1;
            N>>=1;
        }
        return count;
    }
    private static long countTimes(long N)
    {
        if(N==0) return 0;
        return 1+countTimes(N%countBits(N));
    }
    private static long pow(long a, long b, long MOD)
    {
        a%=MOD;
        long res=1;
        while (b>0)
        {
            if((b&1)==1)
                res=(res*a)%MOD;
            a=(a*a)%MOD;
            b>>=1;
        }
        return res%MOD;
    }
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        N=Integer.parseInt(br.readLine().trim());
        char str[]=br.readLine().trim().toCharArray();
        long count=0;

        for(i=0;i<N;i++) if(str[i]=='1') count++;
        StringBuilder sb=new StringBuilder();

        long val1=0,val2=0,val3=0;
        for(i=N-1;i>=0;i--)
        {
            if(str[i]=='0') continue;

            val1+=pow(2,N-i-1,count);
            val1%=count;

            val2+=pow(2,N-i-1,count+1);
            val2%=count+1;

            if(count>1)
            {
                val3+=pow(2,N-i-1,count-1);
                val3%=count-1;
            }
        }

        for(i=0;i<N;i++)
        {
            if(str[i]=='0')
            {
                long tmp=val2;
                tmp+=pow(2,N-i-1,count+1);
                tmp%=count+1;
                sb.append(1+countTimes(tmp)).append("\n");
            }
            else
            {
                if(count==1) sb.append(0).append("\n");
                else
                {
                    long tmp=val3;
                    tmp-=pow(2,N-i-1,count-1);
                    tmp%=count-1;
                    if(tmp<0) tmp+=count-1;
                    sb.append(1+countTimes(tmp)).append("\n");
                }
            }
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 39032
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace procon
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToList();
            inputs.Sort();
            Console.WriteLine(string.Join(" ", inputs.Select(n => n.ToString()).ToArray()));
        }
    }
}

Measured memory_bytes: 9712
/*
 * Code be weshen zyk :'(
 * I won't surrender quietly
 */
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using orderd_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define S second
#define F first
#define pb push_back

using ii = pair<int, int>;
using ll = long long;
using db = long double;

const int N = 1e6 + 5, K = 12, MOD = 1e9 + 7;
const ll MX = 1e15;
ll fast(ll b, ll e){
	if(!e)
		return 1;
	if(e & 1)
		return b * fast(b, e - 1) % MOD;
	return fast(b * b % MOD, e >> 1);
}
ll F[N], iF[N];
void init(){
	F[0] = iF[0] = 1;
	for(int i = 1; i < N; i++){
		F[i] = F[i-1] * i % MOD;
		iF[i] = fast(F[i], MOD - 2);
	}
}
ll C(int n, int k){
	if(k > n || k < 0)
		return 0;
	return F[n] * iF[k] % MOD * iF[n-k] % MOD;
}
int main() {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	init();
	int n;	
	cin >> n;
	ll ans = 0, cur = 0;

	for(int i = 1; i < n; i++){
		ll num = C(i - 1, n - i - 1) * F[i] % MOD * F[n - i - 1] % MOD;
		num = (num - cur + MOD) % MOD;
		cur = (cur + num) % MOD;
		ans = (ans + num * i % MOD) % MOD;
	}

	cout << ans << '\n';


	return 0;
}


Measured memory_bytes: 15872
import std.stdio, std.string, std.conv, std.algorithm;
void main() {
	int n, m;
	"%d %d\n".readf(&n, &m);
	int[][] a;
	int[] b;
	foreach (_n; 0..n) a ~= readln.split.to!(int[]);
	foreach (_m; 0..m) b ~= readln.split[0].to!int;
	foreach (_a; a) {
		long s = 0L;
		foreach (i; 0..m) s += _a[i] * b[i];
		s.writeln;
	}
}

Measured memory_bytes: 2884
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

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

    int bigger = max(a, b);
    int smaller = min(a, b);

    if((a + b) % 2 == 0)
    {
        cout << (a + b)/2 << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let nm = readInts()
    let (n, m) = (nm[0], nm[1])
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    var ans = n * m
    ans -= n * 2 + m * 2 - 4
    
    print(abs(ans))
}
main()


Measured memory_bytes: 13596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.14159265358979;
  
ll num[100050];

int main() {
  ll N,K,le,mid,ri;
  cin>>N>>K;
  K--;
  N--;
  cout<<(N-1+K)/K;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  li a,n; cin >>a >>n;
  li s=0;  rep(i,n){
    int x; cin >>x;
    s+=x;
  }
  printf("%s",s>=a?"Yes":"No");
  
}

/// confirm df==0 ///



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

int main() {

	int A, B;
	vector<int> a, b;
	
	cin >> A >> B;
	
	a.resize(A);
	b.resize(B);
	
	for(int i = 0; i < A; i++)
		cin >> a[i];
	for(int i = 0; i < B; i++)
		cin >> b[i];
	
	int ans = 0;
	for(int i = 0; i < B; i++) {
		int ap = 0, cnt = 0;
		for(int j = i; j < B; j++) {
			while(true) {
				if(a[ap] == b[j]) {
					cnt++;
					break;
				} else if(ap == A - 1) {
					break;
				} else {
					ap++;
				}
			}
			if(ap == A - 1) break;
			ap++;
		}
		ans = max(ans, cnt);
	}
	
	cout << ans << endl;

	return 0;

}

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

int N;

void solve()
{
	map<int, int> cnt;
	for(int x=1;x*x<=N;++x)for(int y=1;y*y<=N;++y)for(int z=1;z*z<=N;++z){
		cnt[x*x+y*y+z*z+x*y+y*z+x*z]++;
	}
	for(int i=1;i<=N;++i) cout << cnt[i] << '\n';
}

int main()
{
	cin >> N;
	solve();
	return 0;
}

Measured memory_bytes: 5340
# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) (x&1)
#define debug(x) cout << #x << " => " << x << endl
typedef long long ll;
typedef long double ld;
const ll oo = /*2 * 1000 * 1000 * 1000*/0x3f3f3f3f;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
//const int _p = 1007;
ll o(ll x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
//ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b)*b; }
using namespace std;

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

int n,x,y,s[200005],d0,t=0,ff[200005];
vector <int> V[200005];

void dfs(int k,int f,int d){
	if (k==n) d0=d;
	s[k]=1;
	ff[k]=f;
	if ((V[k].size()==1) && (k!=1)) return ;
	for (int i=0; i<V[k].size(); i++) {
		if (V[k][i]==f) continue;
		dfs(V[k][i],k,d+1);
		s[k]+=s[V[k][i]];
	}
}

int main() {
    //file_put();
    
    scanf("%d",&n);
	for (int i=1; i<=n-1; i++) {
		scanf("%d%d",&x,&y);
		V[x].push_back(y);
		V[y].push_back(x); 
	} 
	dfs(1,0,1);
	t=(d0-2)/2;
	int p=n;
	for (int i=1; i<=t; i++) p=ff[p];
	if (n-s[p]>s[p]) printf("Fennec\n"); else printf("Snuke\n");

    return 0;
}


Measured memory_bytes: 17280
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N,K;cin >> N >> K;
    int R,S,P;cin >> R >> S >> P;
    string T;cin >> T;

    // R 0 S 1 P 2
    LL point[3] = {P,R,S};
    vector<vector<LL>> win(K);
    rep(i,N){
        int num = i % K;
        int tmp;
        if(T[i] == 'r')tmp = 0;
        if(T[i] == 's')tmp = 1;
        if(T[i] == 'p')tmp = 2;
        win[num].push_back(tmp);
    }

/*    rep(i,K){
        rep(j,win[i].size()){
            cout << win[i][j] << " ";
        }
        cout << endl;
    }
*/

    LL ans = 0;

    rep(i,K){
        bool ok = false;
        rep(j,win[i].size()){
        if(j == 0){
                ans += point[win[i][j]];
            }
            else if(win[i][j] != win[i][j-1]){
                ans += point[win[i][j]];
                ok = false;
            }
            else{
                if(ok){
                    ans += point[win[i][j]];
                    ok = false;
                }
                else{
                    ok = true;
                }
            }
        }
    }
    cout << ans << endl;
}


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

typedef long long ll;

const int MAX_POW = 40;
ll N;
map<ll, int> F;

void prime_factor(ll n) {
	for (ll i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			++F[i];
			n /= i;
		}
	}
	if (n != 1)
		F[n] = 1;
}

int cnt_check(int x) {
	int cnt = 1;
	int sum = 0;
	for (int i = 1; i < MAX_POW; ++i) {
		sum += i;
		if (sum > x)
			break;
		else
			cnt = i;
	}
	return cnt;
}

int solve(void) {
	int res = 0;
	if (F.size() == 0)
		return res;
	map<ll, int>::iterator itr;
	for (itr = F.begin(); itr != F.end(); ++itr)
		res += cnt_check(itr->second);
	return res;
}

int main(void) {
	cin >> N;
	prime_factor(N);
	int ans = solve();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {
	var a, b int
	if _, err := fmt.Scan(&a, &b); err != nil {
		panic(err)
	}

	if a == b {
		fmt.Println("a == b")
	} else if a < b {
		fmt.Println("a < b")
	} else if a > b {
		fmt.Println("a > b")
	}
}



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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    // 1~Nに対して何回表が出れば良いか
    VI num(N);
    int max = 0;
    REP(i, N) {
        if (i + 1 >= K)
            num[i] = 0;
        else {
            int n = 0;
            int point = i + 1;
            while (point < K) {
                n++;
                point *= 2;
            }
            num[i] = n;
            if (max < n) max = n;
        }
    }
    ld bunbo, bunshi = 0.0;
    bunbo = N * (ld)pow(2, max);
    REP(i, N) {
        bunshi += pow(2, max - num[i]);
    }
    ld ans = bunshi / bunbo;
    cout << fixed << setprecision(10) << ans << ln;

    return 0;
}


Measured memory_bytes: 640
/*Points to be noted :
1)Don't be afraid to fail.
2)Never give up easily,keep trying.
3)Don't care about other ppl's progress.
4)Spend much time on each problem & keep trying. I WILL DO IT!💯*/

// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//


#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define r0 return 0;
#define tc int t;cin>>t;while(t--)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define md 998244353
#define inf 1000000000000000 //1e15
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
int factorial(int n)
{
    int fact=1;
    for(int i=2;i<=n;i++)
    fact=fact*i;
    
    return fact;
}
int ncr(int n,int r)
{
    return factorial(n)/(factorial(r)*factorial(n-r));
}
void c_p_c()
{
    crap;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
    c_p_c();
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    int sum=0;
    for(int i=0;i<n;i++)
        sum+=v[n-1-i/2];
    sum-=v.back();
    cout<<sum<<endl;
}

Measured memory_bytes: 4760
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << endl;
#else
#define DBG(X)
#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

const int MAX_N = (int)1e5 + 77;
vector<int> g[MAX_N];
bool met[MAX_N];
ll fact[MAX_N];

int n;
ll k;

ll binpow(ll x, ll y)
{
	if(!y)
		return 1LL;

	ll ret = binpow(x, y >> 1LL);
	ret = (ret * ret) % mod;

	if(y & 1LL)
		ret = (ret * x) % mod;

	return ret;
}

const int root = 0;

ll dfs(int v, ll depth)
{
	met[v] = true;
	ll answ = 1LL;

	ll c = 0;

	for(auto u: g[v])
	{
		if(!met[u])
		{
			answ = (answ * dfs(u, depth + 1)) % mod;
			++c;
		}
	}

	ll K = max(0LL, (depth == 0 ? k - 1 : k - 2));

	if(c > K)
	{
		answ = 0;
	}
	else
	{
		answ = (answ * fact[K]) % mod;
		answ = (answ * binpow(fact[K - c], mod - 2)) % mod;
	}

#ifdef __LOCAL
	cout << v + 1 << " --> " << answ << endl;
	DBG(K); DBG(c);
#endif

	return answ;
}

void solve()
{
	cin >> n >> k;

	for(int i = 0; i < n - 1; ++i)
	{
		int v, u;
		cin >> v >> u;

		--v, --u;

		g[v].push_back(u);
		g[u].push_back(v);
	}

	cout << (k * dfs(root, 0LL)) % mod << endl;
}

int main()
{
	fact[0] = 1LL;

	for(ll i = 1; i < MAX_N; ++i)
		fact[i] = (i * fact[i - 1]) % mod;

	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 12416
x = input().split()
n,m,c = int(x[0]),int(x[1]),int(x[2])


b =  []
y = input().split()
for i in y:
    b.append(int(i))

a = []

for i in range(n):
    z = input().split()
    dd = []
    for w in z:
        dd.append(int(w))
    a.append(dd)


count = 0
for i in range(len(a)):
    hasil = 0
    for j in range(len(a[i])):
        hasil += a[i][j] * b[j]
    hasil += c
    #print(hasil)
    if hasil > 0:
        count += 1

print(count)

Measured memory_bytes: 3064
#include<cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int find = 0;
    for(int i = 0; i < n; i++){
        int u;
        scanf("%d",&u);
        find |= (u%2);
    }
    if(find) printf("first\n");
    else printf("second\n");
    return 0;
}


Measured memory_bytes: 1624
#include <bits/stdc++.h>
#define ll long long
#define sz(x) int(x.size())
using namespace std;

int main() {
	ll x;
	cin>>x;

	string s;
	cin>>s;

	if(sz(s) <= x) cout<<s<<"\n";
	else {
		cout<<s.substr(0, x)<<"...\n";
	}
}

Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long A = scan.nextLong();
        long B = scan.nextLong();
        long N = scan.nextLong();
        if (B - 1 <= N) {
            long ans = A * (B - 1) / B;
            System.out.println(ans);
            return;
        }
        long ans = A * N / B;
        System.out.println(ans);
    }
}


Measured memory_bytes: 27028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)
ll MOD = 1000000007;

ll mpow(ll a, ll n) {  // a^n (mod MOD)
    // 二分累乗法 O(log n)
    ll ans = 1;
    while (n != 0) {
        if (n & 1) ans = ans * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return ans % MOD;
}

int main() {
    ll N, ans = 1;
    cin >> N;
    map<pair<ll, ll>, pair<ll, ll>> m;
    ll ab0 = 0;
    for (ll i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        if (a == 0 && b == 0) {
            ab0++;
            continue;
        }

        if (make_pair(a, b) < make_pair(0ll, 0ll)) {
            a *= -1;
            b *= -1;
        }

        ll g = gcd(abs(a), abs(b));
        a /= g;
        b /= g;

        if (b > 0)
            m[make_pair(a, b)].first++;
        else
            m[make_pair(-b, a)].second++;
    }

    for (auto& [key, value] : m) {
        ans *= (mpow(2, value.first) + mpow(2, value.second) - 1) % MOD;
        ans %= MOD;
    }

    ans += ab0;
    ans += MOD - 1;
    ans %= MOD;

    cout << ans << endl;
}


Measured memory_bytes: 19172
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin>>n;
  int a=0,b=0,c=0,d=0;
  string x;
  rep(i,n){
    cin>>x;
    if(x=="AC") a++;
    else if(x=="WA") b++;
    else if(x=="TLE") c++;
    else if(x=="RE") d++;
  }
    
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<b<<endl;
  cout<<"TLE x "<<c<<endl;
  cout<<"RE x "<<d<<endl;
  
  return 0;
}

Measured memory_bytes: 3628
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int n;
    cin >> n;
    int d = n % 10;
    n /= 10;
    int c = n % 10;
    n /= 10;
    int b = n % 10;
    n /= 10;
    int a = n % 10;

    if (a + b + c + d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=" << 7;
    else if (a + b + c - d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=" << 7;
    else if (a + b - c + d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=" << 7;
    else if (a + b - c - d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=" << 7;
    else if (a - b + c + d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=" << 7;
    else if (a - b + c - d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=" << 7;
    else if (a - b - c + d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=" << 7;
    else if (a - b - c - d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=" << 7;
}


Measured memory_bytes: 256