akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;


using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N, T;
  cin >> N >> T;
  vector< pair< int, int > > beet(N);
  cin >> beet;
  sort(begin(beet), end(beet));
  vector< int > dp(T + 1);
  for(auto &p : beet) {
    for(int k = T - 1; k >= 0; k--) {
      chmax(dp[min(T, k + p.first)], dp[k] + p.second);
    }
  }
  cout << dp.back() << endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef pair<ll, ll> pll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define PI 3.14159265358979323846264338327950288419716939937510
#define mp make_pair
ll inf = 1e18;
ll p = 1e9 + 7;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
vector<vector<ll>>adj(1e5 + 1);
vector<ll>used(1e5 + 1, 0), sub(1e5 + 1, 0);
void dfs(ll s, ll p)
{

    sub[s] = 1;
    for (auto v : adj[s])
    {
        if (v != p)
        {
            dfs(v, s);
            sub[s] += sub[v];
        }
    }
    return;
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j, y, x,  z, w, g, key, l, r, n, m, t, k;
    ll a, b, c;
    ll t2, t3, t4, t1;
    ll x1, x2, y1, y2;
    string s;
    cin >> s;
    ll sum = 0;
    n = s.length();
    for (i = 0; i < n; i++)
    {
        t1 = s[i] - '0';
        sum += t1;

    }
    if (sum % 9 == 0)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

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

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  string a,b,c;
  getline(cin,a,',');
  getline(cin,b,',');
  getline(cin,c);
  cout << a << ' ' << b << ' ' << c << endl;
  return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
char a[55], b[55], t[55], ans[55];
bool ok;
int main() {
	scanf("%s%s", a, b);
	int len1 = strlen(a);
	int len2 = strlen(b);
	for(int i = 0; i < len1; i++)ans[i] = 'z';
	ans[len1] = '\0';
	for(int i = 0; i <= len1 - len2; i++) {
		if(a[i] == b[0] || a[i] == '?') {
			bool flag = 1;
			for(int j = 0; j < len2; j++) {
				if(a[i + j] != b[j] && a[i + j] != '?')flag = 0;
			}
			if(flag) {
				for(int j = 0; j < i; j++) {
					if(a[j] != '?')t[j] = a[j];
					else t[j] = 'a';
				}
				for(int j = 0; j < len2; j++) {
					t[j + i] = b[j];
				}
				for(int j = i + len2; j < len1; j++)
					if(a[j] != '?')t[j] = a[j];
					else t[j] = 'a';
				t[len1] = '\0';
				if(strcmp(t, ans) < 0) {
					ok = 1;
					strcpy(ans, t);
				}
				memset(t, 0, sizeof(t));
			}
		}
	}
	if(ok)printf("%s\n", ans);
	else printf("UNRESTORABLE\n");
	return 0;
}

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

int main() {
  unsigned int ans = 0;
  unsigned int N, D;
  cin >> N >> D;
  vector<long> X(N);
  vector<long> Y(N);

  for (unsigned i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
    if (sqrt(X[i] * X[i] + Y[i] * Y[i]) <= D) {
      ans++;
    }
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 6428
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int x = n * 800;
		int y = n / 15 * 200;
		System.out.println(x - y);

	}

}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

void solve(int h,int w) {
    vector<vector<int>> c(h,vector<int>(w,0));
    cin>>c;
    int ans=0;
    REP(i,h) {
        REP(j,w) {
            if(c[i][j]) {
                queue<pii> q;
                q.push({i,j});
                while(!q.empty()) {
                    int y=q.front().first;
                    int x=q.front().second; q.pop();
                    REP(d,8) {
                        int yy=y+DY[d];
                        int xx=x+DX[d];
                        if(OUTOFRANGE(yy,xx,h,w)) continue;
                        if(!c[yy][xx]) continue;
                        q.push({yy,xx});
                        c[yy][xx]=0;
                    }
                }
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}
signed main() {
    while(1) {
        int w,h;
        cin>>w>>h;
        if(w+h==0) break;
        solve(h,w);
    }
    return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int main()
{
    long long ans;
    scanf("%lld",&ans);
    long long a = 100;
    int res = 0;
    while(a < ans){
        res++;
        double z = a * 0.01;
        a += z;
    }
    printf("%d",res);
    return 0;
}


Measured memory_bytes: 3840
using System;
using static System.Console;

class Program
{
    static int nextTurn(char c)
    {
	switch (c)
	{
	    case 'a': return 0;
	    case 'b': return 1;
	    case 'c': return 2;
		
	}
	return -1;
    }

    static string player(int n)
    {
	switch (n)
	{
	    case 0: return "A";
	    case 1: return "B";
	    case 2: return "C";
	}
	return "X";
    }
    
    
    public static void Main()
    {
	string sa = ReadLine();
	string sb = ReadLine();
	string sc = ReadLine();

	int turn = 0;
	int ia = 0, ib = 0, ic = 0;

	while (true)
	{
	    string s = "";
	    int i = 0;
	    switch (turn)
	    {
		case 0: s = sa; i = ia; break;
		case 1: s = sb; i = ib; break;
		case 2: s = sc; i = ic; break;
	    }
	    
	    if (i == s.Length)
	    {
		WriteLine(player(turn));
		return;
	    }

	    switch (turn)
	    {
		case 0: ia++; break;
		case 1: ib++; break;
		case 2: ic++; break;
	    }

	    turn = nextTurn(s[i]);
	}
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
const int N(1e5 + 5);
int x, y, a, b, c, rosu[N], verde[N], non[N], curr(1), val, cul;
int64_t sum;
priority_queue<pair<int, int>> q;
int main() {
    DAU
    cin >> x >> y >> a >> b >> c;
    for (int i = 1; i <= a; ++i)
        cin >> rosu[i], rosu[i] = -rosu[i];
    for (int i = 1; i <= b; ++i)
        cin >> verde[i], verde[i] = -verde[i];
    for (int i = 1; i <= c; ++i)
        cin >> non[i], non[i] = -non[i];
    sort(non + 1, non + c + 1);
    while (a < x)
        rosu[++a] = non[curr++];
    while (b < y)
        verde[++b] = non[curr++];
    sort(rosu + 1, rosu + a + 1);
    sort(verde + 1, verde + b + 1);
    for (int i = 1; i <= x; ++i) {
        sum += rosu[i];
        q.emplace(rosu[i], 1);
    }
    for (int i = 1; i <= y; ++i) {
        sum += verde[i];
        q.emplace(verde[i], 2);
    }
    while (!q.empty()) {
        tie(val, cul) = q.top();
        q.pop();
        if (val > non[curr] && curr <= c)
            sum -= val - non[curr++];
    }
    cout << -sum;
    PLEC
}

Measured memory_bytes: 3572
#include <stdio.h>

int main(void)
{
	int a, b;

	scanf("%d %d", &a, &b);

	if (a < b) {
		printf("a < b\n");
	} else if (a > b) {
		printf("a > b\n");
	} else {
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
/**
 * 
 */
import java.util.*;
/**
 * @author akira
 *
 */
class Main {

	static int n, s;
	static int[][] mem = new int[1 << 10][10001];
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		while(scan.hasNextInt()){
			n = scan.nextInt();
			s = scan.nextInt();
			for(int i = 0;i < mem.length;i++){
				for(int j = 0;j < mem[i].length;j++){
					mem[i][j] = -1;
				}
			}
			System.out.println("" + rec(0,0,0));
		}
	}
	static int rec(int cnt,int set,int sum){
//		System.out.println("" + cnt + " " + set + " " + sum);
//		System.out.flush();
		if(sum > s){
			return 0;
		}else if(cnt == n){
			if(sum == s){
				return 1;
			}else{
				return 0;
			}
		}else if(mem[set][sum] != -1){
			return mem[set][sum];
		}
		int res = 0;
		for(int i = 0;i < 10;i++){
			if(((set >> i) & 1) == 0){
				res += rec(cnt + 1,set | (1 << i),sum + i * (cnt + 1));
			}
		}
		return mem[set][sum] = res;
	}

}

Measured memory_bytes: 87420
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func main() {
	scanner.Split(bufio.ScanWords)
	n, _ := nextInt()
	a := make([]int, n)
	for i := range a {
		j := len(a) - i - 1
		a[j], _ = nextInt()
	}
	fmt.Println(stringifyArray(a))
}



Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,W,i;
    cin>>n>>W;
    ll wt[n],val[n];
    for(i=0;i<n;i++)
    cin>>wt[i]>>val[i];
    ll j,dp[n+1][W+1];
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=W;j++)
        {
            if(i==0||j==0)
            dp[i][j]=0;
            else if(wt[i-1]<=j)
            dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
            else
            dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][W]<<endl;
    return 0;
}

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

int a[100000];
bool visited[100000];
vector<int> path;

void search(int cur)
{
    if (visited[cur] == true) {
        cout << -1 << endl;
        return;
    } else if (cur == 1) {
        cout << path.size() << endl;
        return;
    }
    path.push_back(cur);
    visited[cur] = true;
    int next = a[cur] - 1;
    search(next);
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        visited[i] = false;
    }
    search(0);
    return 0;
}

Measured memory_bytes: 5880
#include<iostream>

using namespace std;

int main() {

	int n;
	cin >> n;

	int a = n % 10;
	int b = (n / 10) % 10;
	int c = (n / 100) % 10;
	int d = (n / 1000) % 10;
	
	if (b == c && a == b || b == c && c == d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

#[fastout]
fn main() {
    input! {
        s: String,
    };
    println!(
        "{}",
        match s.as_str() {
            "RRR" => 3,
            "RRS" | "SRR" => 2,
            "SSS" => 0,
            _ => 1,
        }
    );
}


Measured memory_bytes: 2168
#include<stdio.h>
const long long int prime = 1000000007;
const long long int max_v = 9223372036854775807;
long long int modPow(long long int a, long long int n, long long int p)
{
	if(n==1) return a%p;
	if(n%2 == 1) return ((a%p) * (modPow(a, n-1, p)%p))%p;
	long long int t = modPow(a, n/2, p)%p;
	return (((t%p)*(t%p))%p);
}
long long int factr(long long int a)
{
	if (a ==0||a==1) return (1);
	long long int index =0;
	long long int r_v=1;
	while (index < a)
	{
		r_v = (r_v%prime*(a-index))%prime;
		index++;
	}
	return (r_v%prime);
}
long long int fac_stop(long long int a, long long int x)
{
	if (x == 0) return (1);
	if (a == 1) return (1);
	long long int index = 0;
	long long int r_v=1;
	while (index < x)
	{
		r_v = (r_v%prime*(a-index)%prime);
		index++;
	}
	return (r_v%prime);
}


int	main(void)
{
	long long int n, a, b;
	scanf("%lld %lld %lld", &n, &a, &b);
	long long int sum;
	sum = (modPow(2, n, prime) -1)%prime;
	long long int count_b, count_a;
	count_a = (modPow(factr(a),prime -2,prime) * fac_stop(n,a)%prime)%prime;
	count_b = (modPow(factr(b),prime -2,prime) * fac_stop(n,b)%prime)%prime;
	long long int r = (sum%prime- count_a%prime -count_b%prime)%prime;
	if(r < 0)
		r = prime +r;
	printf("%lld\n",r);
	return (0);
}


Measured memory_bytes: 128
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;
bool check(int idx, vector<int> &dat, int k) {
    int m = dat.size();

    vector<bool> dp(k, false);
    bool flag = false;
    dp[0] = true;
    FOR(i, 0, m) {
        if (i == idx)
            continue;
        RFOR(j, k - 1, 0) {
            if (0 <= j - dat[i] && dp[j - dat[i]]) {
                dp[j] = true;
                if (k - dat[idx] <= j && j <= k - 1) {
                    flag = true;
                    break;
                }
            }
        }
        if (flag)
            break;
    }

    return flag;

}



int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);

    FOR(i, 0, n) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    auto b = lower_bound(a.begin(), a.end(), k);
    vector<int> dat(distance(a.begin(), b));
    copy(a.begin(), b, dat.begin());


    int m = dat.size();

    int lb = -1, ub = m;
    while (ub - lb > 1) {
        int half = (lb + ub) / 2;
        if (check(half, dat, k))
            ub = half;
        else
            lb = half;
    }

    cout << ub << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long LL;

LL fun(LL n, LL m)
{
    if((m / 2) < n) return  m / 2;
    LL ans = n;
    m = m - n * 2;
    ans = ans + m / 4;
    return ans;
}

int main()
{
    LL n, m;
    scanf("%lld%lld", &n, &m);
    LL ans = fun(n, m);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
import math
N = int(input())

def chkPrime(N):
  if N == 2 or N == 3:
    return True
  else:
    for i in range(2,int(math.sqrt(N))+1):
      if N % i == 0:
        return False
    else:
      return True

while not chkPrime(N):
  N += 1

print (N)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<map>
#include<queue>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
	char a[100];
	char b[100];
	int s,m,n;
    scanf("%s",a);
    scanf("%s",b);
	n=strlen(a);
	m=strlen(b);
	if(n>m) printf("GREATER\n");
	if(m>n) printf("LESS\n");
	if(m==n){
		s=strcmp(a,b);
		if(s>0) printf("GREATER\n");
		if(s<0) printf("LESS\n");
        if(s==0)  printf("EQUAL\n");
	}	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long ans = LLONG_MAX;
  long long N;
  cin >> N;
  for (long long i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      ans = min(ans, i - 1 + N / i - 1);
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Vi = vector<int>;

// auto mod int
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const { return pow(mod-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) const { return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
	vector<mint> fact, ifact;
	combination(int n):fact(n+1),ifact(n+1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k) {
			if (k < 0 || k > n) return 0;
			return fact[n]*ifact[k]*ifact[n-k];
		}
};


int main() {
	int k, n;
	string s;
	cin >> k >> s;
	n = s.size();
	combination c(n+k);
	mint ans = 0;
	for (int i = 0; i <= k; ++i) {
		mint now = mint(26).pow(k  - i);
		now *= mint(25).pow(i);
		now *= c(i + n - 1, n - 1);
		ans += now;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 35584
/* "The world is full of obvious things which nobody by any chance ever observes." */


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

typedef long long ll;
#define mod 1000000007
#define pi  3.14159265358979323846
#define pb push_back
#define mk make_pair
#define popcnt(a) _Generic((a), int: __builtin_popcount(a), \  long long: __builtin_popcountll(a))  
#define precise(x) cout<<fixed<<setprecision(10)<<x
#define test cout<<"#";
#define input freopen("input.txt", "r", stdin)
#define output freopen("output.txt", "w", stdout) 

const ll inf = 1e18L + 2;

ll ans[1000001][3];

ll solve(ll ar[][3], ll n, ll d)
{
    if(n==1 && d == 0)
        return ar[n-1][d];
    if(n==1 && d == 1)
        return ar[n-1][d];
    if(n==1 && d == 2)
        return ar[n-1][d];
    if(ans[n][d]!=-1)
        return ans[n][d];
    if(d == 0)
        return ans[n][d] = ar[n-1][d] + max(solve(ar, n-1, 1), solve(ar, n-1, 2));
    if(d == 1)
        return ans[n][d] = ar[n-1][d] + max(solve(ar, n-1, 2), solve(ar, n-1, 0));
    if(d == 2)
        return ans[n][d] = ar[n-1][d] + max(solve(ar, n-1, 1), solve(ar, n-1, 0));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll ar[n][3];
    memset(ans, -1, sizeof(ans));
    for(ll x = 0; x < n; x++)
    {
        cin>>ar[x][0]>>ar[x][1]>>ar[x][2];
    }
    cout<<max(solve(ar, n, 0), max( solve(ar, n, 1), solve(ar, n, 2)));
}

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

const int N = 2e3;

int n,m;
char fi[N+5][N+5];

int atas[N+5][N+5], baw[N+5][N+5],kiri[N+5][N+5], kan[N+5][N+5];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		getchar();
		for(int j=1;j<=m;j++){
			scanf("%c",&fi[i][j]);
		}
	}
	
	// kiri atas
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(j==1) kiri[i][j] = j;
			else if(fi[i][j-1] == '#') kiri[i][j] = j;
			else kiri[i][j] = kiri[i][j-1];
			if(i==1) atas[i][j] = i;
			else if(fi[i-1][j] == '#') atas[i][j] = i;
			else atas[i][j] = atas[i-1][j];
		}
	}
	for(int i=n;i>=1;i--){
		for(int j=m;j>=1;j--){
			if(j==m) kan[i][j] = j;
			else if(fi[i][j+1] == '#') kan[i][j] = j;
			else kan[i][j] = kan[i][j+1];
			if(i==n) baw[i][j] = i;
			else if(fi[i+1][j] == '#') baw[i][j] = i;
			else baw[i][j] = baw[i+1][j];
		}
	}
	
	int ans = 0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(fi[i][j] == '#') continue;
//			printf("%d %d >> atas : %d, baw : %d, kan : %d, kiri : %d\n",i,j,atas[i][j],baw[i][j], kan[i][j], kiri[i][j]);
			ans = max(ans,baw[i][j] - atas[i][j] + kan[i][j] - kiri[i][j] + 1);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 66944
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if (k % 2)
        cout << b-a;
    else
        cout << a-b;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    sort(p, p + n);
    int ans = 0;
    for(int i = 0; i < n - 1; i++){
        ans += p[i];
    }
    ans += p[n-1] / 2;

    cout << ans << '\n'; 
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int x, y;
    while (1) {
        scanf("%d %d", &x, &y);
        if (x==0 && y==0) {
            break;
        }
        if (x<y) {
            printf("%d %d\n", x, y);
        }else{
            printf("%d %d\n", y, x);
        }
       
    }

    return 0;
}


Measured memory_bytes: 1980
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int ans = 0;
    rep(i,n)if(s[i] != t[i])ans++;
    cout << ans << endl;

}


Measured memory_bytes: 3844
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n, m; cin >> n >> m;
    vector<int> P(n), O(n); 
    rep(i, n){
        cin >> P[i]; P[i]--;
        O[P[i]] = i;
    }
    vector<vector<int>> G(n);
    rep(i, m){
        int a, b; cin >> a >> b; a--, b--;
        //cout << P[a] << "+" << P[b] << ln; 
        G[P[a]].push_back(P[b]);
        G[P[b]].push_back(P[a]);
    }
    ll res = 0;
    queue<int> que;
    vector<int> seen(n);
    rep(i, n){
        vector<int> A, B(n);
        if(seen[i])continue;
        que.push(i); seen[i] = true;
        while(!que.empty()){
            int v = que.front(); que.pop();
            A.push_back(v);
            B[O[v]] = true;
            for(auto e: G[v]){
                if(seen[e])continue;
                seen[e] = true;
                que.push(e);
            }
        }

        for(int num: A){
            if(B[num])res++;
        }
    }
    cout << res << ln;
}

Measured memory_bytes: 10716
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
ll A[100001], B[100001];
int NA,NB,Q;
const ll INF=100000000000;
int main(){
	scanf("%d %d %d",&NA,&NB,&Q);
	for(int i=0;i<NA;i++) scanf("%lld",A+i);
	for(int i=0;i<NB;i++) scanf("%lld",B+i);
	while(Q--){
		ll x;
		scanf("%lld",&x);
		int adx=lower_bound(A,A+NA,x)-A;
		int bdx=lower_bound(B,B+NB,x)-B;
		vector<ll> aleft,aright,bleft,bright;
		for(int i=-1;i<=1;i++){
			if(0<=adx+i&&adx+i<NA){
				if(A[adx+i]<=x) aleft.push_back(A[adx+i]);
				if(A[adx+i]>=x) aright.push_back(A[adx+i]);
			}
			if(0<=bdx+i&&bdx+i<NB){
				if(B[bdx+i]<=x) bleft.push_back(B[bdx+i]);
				if(B[bdx+i]>=x) bright.push_back(B[bdx+i]);
			}
		}
		ll Min=INF;
		sort(aleft.begin(),aleft.end());
		sort(aright.begin(),aright.end());
		sort(bleft.begin(),bleft.end());
		sort(bright.begin(),bright.end());
		if(!(aleft.empty()||bleft.empty())){
			Min=min(Min,abs(x-min(aleft[aleft.size()-1],bleft[bleft.size()-1])));
		}
		if(!(aright.empty()||bright.empty())){
			Min=min(Min,abs(x-max(aright[0],bright[0])));
		}
		if(!(aleft.empty()||bright.empty())){
			ll tmp[]={abs(x-aleft[aleft.size()-1]),abs(x-bright[0])};
			Min=min(Min,min(tmp[0],tmp[1])*2+max(tmp[0],tmp[1]));
		}
		if(!(bleft.empty()||aright.empty())){
			ll tmp[]={abs(x-bleft[bleft.size()-1]),abs(x-aright[0])};
			Min=min(Min,min(tmp[0],tmp[1])*2+max(tmp[0],tmp[1]));
		}
		printf("%lld\n",Min);
	}
}

Measured memory_bytes: 2816
from itertools import product

INF = 1000000007

def mat2_mul(X, Y):
	z = [[0, 0], [0, 0]]
	for (i, j, k) in product(range(2), range(2), range(2)):
		z[i][j] += X[i][k] * Y[k][j]
	return z

def mat2_pow(X, n):
	if n == 0:
		return [[1, 0], [0, 1]]
	elif n % 2:
		return mat2_mul(X, mat2_pow(X, n - 1))
	else:
		half_pow = mat2_pow(X, n / 2)
		return mat2_mul(half_pow, half_pow)

def fib(n):
	if n == 0:
		return 0
	else:
		f = [[0, 1], [1, 1]]
	return mat2_pow(f, n - 1)[1][1]


N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
ans, start = 1, 0
tmp = []

for k in a:
	ans *= fib(k - start)
	ans %= INF
	start = k + 1

ans *= fib(N - start + 1)
print(ans % INF)


Measured memory_bytes: 7096
n = int(input())
a = list(map(int,input().split()))
count = 0
while True:
         for i in range(n):
                  if a[i] % 2 == 0:
                           a[i] = a[i] // 2
                  else:
                           break
         else:
                  count += 1
                  continue
         break
print(count)


Measured memory_bytes: 2940
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double r;
    cin >> r;
    printf("%.3f\n", (double)r*2.0*3.141);

    return 0;
}

Measured memory_bytes: 3804
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    ll N, A, B, ans, m;

    cin >> N >> A >> B;
    ans = N / (A + B);
    ans = ans * A;
    m = N % (A + B);

    if(m < A){
        ans += m;
    } else {
        ans += A;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l
int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    if (a + 2 < b) {
        ll fc = a - 1;
        ll cnt = 0;
        if (fc + 2 > k) {
            cout << k + 1 << endl;
            return 0;
        }
        cnt = b;
        k -= fc + 2;
        ll sum = b - a;
        if (k % 2 == 0) {
            cnt += sum * (k / 2);
            cout << cnt << endl;
        }
        else {
            cnt += sum * (k / 2);
            cout << cnt + 1 << endl;

        }
    }
    else {
        cout << k + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())

xyz_list=[ [] for _ in range(8) ]
for _ in range(n):
    x,y,z=map(int,input().split())
    # (+,+,+)
    xyz_list[0].append(x+y+z)
    # (-,+,+)
    xyz_list[1].append(y+z-x)
    # (+,-,+)
    xyz_list[2].append(x+z-y)
    # (+,+,-)
    xyz_list[3].append(x+y-z)
    # (-,-,+)
    xyz_list[4].append(z-x-y)
    # (-,+,-)
    xyz_list[5].append(y-x-z)
    # (+,-,-)
    xyz_list[6].append(x-y-z)
    # (-,-,-)
    xyz_list[7].append(-x-y-z)

xyz_list[0].sort(reverse=True)
xyz_list[1].sort(reverse=True)
xyz_list[2].sort(reverse=True)
xyz_list[3].sort(reverse=True)
xyz_list[4].sort(reverse=True)
xyz_list[5].sort(reverse=True)
xyz_list[6].sort(reverse=True)
xyz_list[7].sort(reverse=True)

max_value=0
for idx in range(8):
    max_value=max(max_value,sum(xyz_list[idx][0:m]))

print(max_value)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;
void solve(){
	string s;
	cin>>s;
	sort(all(s));
	cout<<(s[0]==s[2]?"No":"Yes");
}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define endl '\n'

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7;
const int MAXN = static_cast<int>(1e6) + 17;

int n, k, q;
int a[MAXN];

bool read() {
    if (!(cin >> n >> k >> q))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

bool check(const vector< vector<int> >& kek, int x) {
    int res = 0;

    for (auto& v : kek)
        res += min(int(upper_bound(v.begin(), v.end(), x) - v.begin()), max(0, sz(v) - k + 1));

    return res >= q;
}

ll calc(int x) {
    vector< vector<int> > kek;
    kek.push_back(vector<int>());

    forn (i, n)
        if (a[i] < x) {
            if (!kek.back().empty())
                kek.push_back(vector<int>());
        } else {
            kek.back().push_back(a[i]);
        }

    for (auto& v : kek)
        sort(v.begin(), v.end());

    if (!check(kek, INF))
        return INF;

    ll l = x, r = INF;

    for (; l < r; ) {
        auto m = (l + r) / 2;

        if (check(kek, m))
            r = m;
        else
            l = m + 1;
    }

    return r - x;
}

void solve() {
    ll ans = INF;

    forn (i, n)
        ans = min(ans, calc(a[i]));

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');

#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 384
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1000000007;

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i, N){
        cin >> A[i];
        A[i] /= 2;
    }

    ll ans = A[0];
    for(int i = 1; i < N; i++){
        ll next = lcm(A[i], ans);
        int a = next / ans, b = next / A[i];
        while(1){
            if(a % 2 != b % 2){
                ans = INF;
                break;
            }
            else if( a % 2 == 0 && b % 2 == 0){
                a /= 2;
                b /= 2;
            }
            else {
                ans = next;
                break;
            }
        }
        if(ans == INF) break; 
    }

    int sum = 0;
    for(int i = 1; i * ans <= M; i +=2 ) sum++;
    cout << sum << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

string x;
cin >> x;

int n = x.size();
rep(i,n) cout << 'x';

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int a, b;
   std::cin >> a >> b;
   puts(a*b%2==0?"Even":"Odd");
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;

template <typename Int, Int MOD, int N>
struct comb_util {
	std::array<Int, N + 1> fc, ifc;

	comb_util() {
		fc[0] = 1;
		for (int i = 1; i <= N; i++) fc[i] = fc[i - 1] * i % MOD;
		ifc[N] = inv(fc[N]);
		for (int i = N - 1; i >= 0; i--) ifc[i] = ifc[i + 1] * (i + 1) % MOD;
	}

	Int fact(Int n) { return fc[n]; }

	Int inv_fact(Int n) { return ifc[n]; }

	Int inv(Int n) { return pow(n, MOD - 2); }

	Int pow(Int n, Int a) {
		Int res = 1, exp = n;
		for (; a; a /= 2) {
			if (a & 1) res = res * exp % MOD;
			exp = exp * exp % MOD;
		}
		return res;
	}

	Int perm(Int n, Int r) {
		if (r < 0 || n < r)
			return 0;
		else
			return fc[n] * ifc[n - r] % MOD;
	}

	Int binom(Int n, Int r) {
		if (n < 0 || r < 0 || n < r) return 0;
		return fc[n] * ifc[r] % MOD * ifc[n - r] % MOD;
	}

	Int homo(Int n, Int r) {
		if (n < 0 || r < 0) return 0;
		return r == 0 ? 1 : binom(n + r - 1, r);
	}
};

using comb = comb_util<long long, 1000000007, 3000000>;

comb cb;
vector<vector<int> > g;
vector<int> sz;
vector<int> res;
int N;
void dfs(int a, int p) {
	sz[a] = 1;
	res[a] = 1;
	//res[a] = (res[a] * (N - 1)) % MOD;
	for (int i = 0; i < g[a].size(); i++) {
		if (g[a][i] != p) {
			dfs(g[a][i], a);
			sz[a] += sz[g[a][i]];
			res[a] = (res[a] * res[g[a][i]]) % MOD;
			res[a] = (res[a] * cb.inv_fact(sz[g[a][i]])) % MOD;
		}
	}
	res[a] = (res[a] * cb.fact(sz[a] - 1)) % MOD;
}

void dfs2(int a, int p) {
	//res[a] = (res[a] * (N - 1)) % MOD;
	for (int i = 0; i < g[a].size(); i++) {
		if (g[a][i] != p) {
			int b = g[a][i];
			res[b] = (res[a] * cb.inv(N - sz[b])) % MOD;
			res[b] = (res[b] * sz[b]) % MOD;
			dfs2(g[a][i], a);
		}
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	g.resize(N);
	sz.resize(N);
	res.resize(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0, -1);
	dfs2(0, -1);
	for (int i = 0; i < N; i++) {
		cout << res[i] << endl;
	}
}

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

void Main()
{
	int N,K;
	cin>>N>>K;
	vec(A,N);
	vin(A);

	ll ans1=1,ans2=1;
	rep(i,K){
		ans2 *= A[i];
	}
	dout<<K<<":"<<ans2<<_n;

	for(int i=K; i<N; i++){
		ans1=(ans2/A[i-K])*A[i];
		//dout<<i+1<<":"<<ans1<<_n;
		//cout<<((ans1>ans2)?"Yes":"No")<<_n;
		ans2=ans1;
		if(A[i]>A[i-K])cout<<"Yes"<<_n;
		else cout<<"No"<<_n;
	}

}


void Test();
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3988
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>


using namespace std;

typedef pair < int , int > pii;

typedef long long ll;


int n;

string s;


int gcd(int a, int b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}
int lcm(int a, int b){
    return a * b / gcd(a, b);
}
ll cnt = 0;
 int b[200002];

vector < ll > v, g;

int a[200002];

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

    ll ans = 0;
    for(int i = 1; i <= n; i++){
        cin >> b[i];
        ans += min(a[i], b[i]);
        if(a[i] > b[i]){
            a[i] -= b[i];
        }
        else{
            b[i] -= a[i];
            a[i] = 0;
            if(a[i + 1] > b[i]){
                a[i + 1] -= b[i];
                ans += b[i];
            }
            else{
                ans += a[i + 1];
                a[i + 1] = 0;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[100005];
ll b[100005];
ll num=100000000;
void work_1(){
	ll ans1=0,ans2=0;
	for (int i=1;i<=(n+1)>>1;i++)
		ans1-=a[i]*2;
	ans1+=a[(n+1)>>1]+a[n>>1];
	for (int i=n;i>=(n-(n>>1)+1);i--)
		ans1+=a[i]*2;
	for (int i=1;i<=(n-1)>>1;i++)
		ans2-=a[i]*2;
	for (int i=n;i>=(n-(n>>1));i--)
		ans2+=a[i]*2;
	ans2-=a[n-(n>>1)]+a[n-(n>>1)+1];
	printf("%lld\n",max(ans1,ans2));
}
void work_2(){
	ll ans=0;
	for (int i=1;i<=n>>1;i++)
		ans-=a[i]*2;
	for (int i=n;i>=(n-(n>>1)+1);i--)
		ans+=a[i]*2;
	ans+=a[n>>1];
	ans-=a[(n>>1)+1];
	printf("%lld\n",ans);
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	if (n&1) work_1();else work_2();
}

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

int main(){
  ll n;
  cin>>n;
  ll p,q,r;
  for(ll a=1; a<=3500; a++){
    for(ll b=1; b<=3500; b++){
      if(4*a*b-n*b-n*a==0) continue;
      if(n*a*b % (4*a*b-n*b-n*a) == 0 && 1<=n*a*b/(4*a*b-n*b-n*a) && n*a*b/(4*a*b-n*b-n*a)<=3500){
        p=a; q=b; r=n*a*b/(4*a*b-n*b-n*a);
        break;
      }
    }
  }
  cout<<p<<" "<<q<<" "<<r<<endl;
}


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

using namespace std;

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
void chmax(T1 &a, const T2 &b) {
  if(a < b) a = b;
}

template <typename T1, typename T2>
void chmin(T1 &a, const T2 &b) {
  if(a > b) a = b;
}

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i != (int)(s.size())-1) cout << " ";
  }
  cout << "\n";
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

  ll n, m; cin >> n >> m;
  vll a(n);
  REP(i, n) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vll su(n+1);
  RREP(i, n-1) {
    su[i] = su[i+1] + a[i];
  }

  ll l = 0, r = 1;
  REP(i, 10) r *= 5;
  r *= 2;
  r++;
  while(r - l > 1) {
    ll mid = (l + r) / 2;
    ll cnt = 0;
    FOR(i, 0, n) {
      auto it = lower_bound(a.begin(), a.end(), mid-a[i]);
      int pos = distance(a.begin(), it);
      cnt += n - pos;
    }
    if(cnt >= m) {
      l = mid;
    } else {
      r = mid;
    }
  }

  ll ans = 0;
  ll cnt = 0;
  REP(i, n) {
    auto it = lower_bound(a.begin(), a.end(), l-a[i]);
    int pos = distance(a.begin(), it);
    cnt += n-pos;
    ans += su[pos] + (n-pos) * a[i];
  }

  cout << ans - (cnt-m) * l << endl;
}


Measured memory_bytes: 1920