akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, k, a[500];
vector<int> ya;
int cnt;

void div() {
	for (int i = 1; i <= sqrt(cnt); i++) {
		if (!(cnt%i)) {
			ya.push_back(i);
			if (i*i != cnt) {
				ya.push_back(cnt / i);
			}
		}
	}
	return;
}

bool ok(int x) {
	vector<int> vec;
	int c = 0, d = 0;
	for (int i = 0; i < n; i++) {
		vec.push_back(a[i] % x);
		c += a[i] % x;
	}
	sort(all(vec));
	for (int i = n - 1; i >= 0; i--) {
		c -= vec[i];
		d += x - vec[i];
		if (c == d) {
			if (c <= k)return true;
			else return false;
		}
	}
}

signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt += a[i];
	}
	div();
	sort(all(ya));
	for (int i = (int)ya.size() - 1; i >= 0; i--) {
		if (ok(ya[i])) {
			cout << ya[i] << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)

const int mod = 1e9 + 7;

int binpow(int a,int b)
{
    int res = 1;
    while(b)
    {
        if(b&1)
        {
            res = (res*a)%mod;
        }
        b >>= 1;
        a = (a*a)%mod;
    }
    return res%mod;
}
int nCr(int n,int r)
{
    r = min(r,n - r);
    int num = 1;
    int den = 1;
    for(int i = 1; i <= r; ++i)
    {
        num *= (n - i + 1);
        num %= mod;
        den *= i;
        den %= mod;
    }
    den = binpow(den,mod - 2);
    return  (num*den)%mod;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x,y;
    cin >> x >> y;
    if((x + y)%3 != 0)
    {
        cout << 0;
        return 0;
    }
    int n = (x + y)/3;
    int r = (2*y - x)/3;
    int z = (2*x  - y)/3;
    if(r < 0 || z < 0)
    {
        cout << 0;
        return 0;
    }

    cout << nCr(n,r) << ' ';
}

Measured memory_bytes: 256
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

int main()
{
	fast();
	ll n,i,x=0;
	string s;
	cin>>n;
	map<string,ll> m;
	while(n--)
	{
		cin>>s;
		m[s]++;
		x=max(x,m[s]);
	}
	for(auto it : m)
	{
		if(it.ss==x)
			cout<<it.ff<<endl;
	}
}

Measured memory_bytes: 23808
import sys
input=lambda: sys.stdin.readline().rstrip()
mod=10**9+7
n=int(input())
edge=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
Ans=[]
inf=10**6

#親と入次数を求める
Par=[inf]*n
Par[0]=-1
Deg=[0]*n
Deg[0]=0
Chk=[0]
while Chk:
  c=Chk.pop()
  for next in edge[c]:
    if Par[next]==inf:
      Par[next]=c
      Deg[next]+=1
      Chk.append(next)
 
#トポソする
from collections import deque
TS=list(v for v in range(n) if Deg[v]==0)
D=deque(TS)
while D:
  v=D.popleft()
  for t in edge[v]:
    if t!=Par[v]:
      Deg[t]-=1
      if Deg[t]==0:
        D.append(t)
        TS.append(t)

C1,C2=[0]*n,[0]*n
for i in reversed(range(n)):
  v=TS[i]
  if len(edge[v])==1 and Par[v]!=-1:
    C1[v]=1
    C2[v]=1
  else:
    c1,c2=1,1
    for g in edge[v]:
      if g==Par[v]:
        continue
      else:
        c1*=C1[g]+C2[g]
        c2*=C1[g]
    C1[v]=c1%mod
    C2[v]=c2%mod
print((C1[0]+C2[0])%mod)



Measured memory_bytes: 31824
#include <iostream>

using namespace std;

int main() {
    int N, K;

    cin >> N >> K;

    int out = 0;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        if (tmp < K) {
            continue;
        } else {
            out++;
        }
    }

    cout << out << endl;

    return 0;
}

Measured memory_bytes: 256
n, x, y = map(int, input().split())
dis = {i: 0 for i in range(1, n)}
for i in range(1, n):
    for j in range(i+1, n+1):
        mi = min(j-i, abs(i-x) + 1 + abs(j-y))
        dis[mi] += 1
for i in range(1, n):
    print(dis[i])

Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>

using namespace std;

int main(){

	int H, W;
  	
  	while(H>0 || W > 0){
  		cin >> H >> W;
      if(H > 0 || W>0){
      	for(int i =0; i<H; i++){
      		for(int j=0; j<W; j++){
          	cout << "#";
        	}
        	cout << endl;
      	}
      	cout << endl;
     	}
    }
  
    return 0;
}


Measured memory_bytes: 3104
import java.util.*

fun main(args: Array<String>) {
    val numbers = Numbers()
    (1..readLine()!!.toInt()).map { readLine()!!.toInt() }.forEach(numbers::addValue)
    numbers.printValue()
}

data class Numbers(private val digits: MutableMap<Int, DigitNumbers> = TreeMap()) {

    fun addValue(value: Int) {
        val digit = value.toString().length
        addValue(digit, value)
    }

    private fun addValue(digit: Int, value: Int) {
        val digitNumbers = digits[digit] ?: DigitNumbers()
        digitNumbers.addIfNeeded(value)
        digits[digit] = digitNumbers
    }


    fun printValue() {
        val values = mutableListOf<Int>()
        digits.values.forEach {
            values.addAll(it.values)
            if (values.size >= 3) {
                return@forEach
            }
        }

        println(values.flatMap { v -> values.filter { v != it }.map { "$it$v".toInt() }.toList() }.sorted()[2])
    }
}

data class DigitNumbers(private val numbers: MutableList<Int> = mutableListOf()) {

    companion object {
        private const val LIMIT_VALUE = 3
    }

    val values: List<Int> get() = numbers

    fun addIfNeeded(value: Int) {
        if (numbers.size <= LIMIT_VALUE) {
            numbers.add(value)
        } else if (numbers.max()!! >= value) {
            numbers.add(value)
            numbers.sort()
            numbers.removeAt(numbers.size - 1)
        }
    }
}



Measured memory_bytes: 39472
N, M = map(int, input().split())

b = [1] * N
b[0] = -1
for i in range(M):
  x, y = map(int, input().split())
  if b[x - 1] < 0:
    b[x - 1] += 1
    b[y - 1] = -(abs(b[y - 1]) + 1)
  else:
    b[x - 1] -= 1
    if b[y - 1] < 0:
      b[y - 1] -= 1
    else:
      b[y - 1] += 1
print(len([x for x in b if x < 0]))


Measured memory_bytes: 4656
#include <iostream>

using namespace std;

int solve(const int a, const int b) {
  if(a <= 0 && b >= 0) return 0;
  if(a > 0) return 1;
  if((b - a) % 2 == 0) return -1;
  else return 1;


}

int main() {
  int a, b; cin>>a>>b;
  int ans = solve(a, b);
  if(ans == 0) cout << "Zero" << endl;
  else if(ans > 0) cout << "Positive" << endl;
  else cout << "Negative" << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
 
class main{
  static void Main(string[] args){
    int order = int.Parse(Console.ReadLine().Split(" ")[1])-1;
    string s = Console.ReadLine();
    string sub = s.Substring(order, 1).ToLower();
    
    Console.WriteLine(s.Remove(order, 1).Insert(order, sub));
  }
}

Measured memory_bytes: 27800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second

int main(void){
	ll l,r; cin >> l >> r;
	if(l/3 < r/3 && l/673 < r/673){
		cout << 0 << endl;
		return 0;
	}
	ll ans = 2019;
	for(ll i=l; i<r; i++){
		for (ll j=i+1; j<=r; j++){
			ans = min(ans, i*j % 2019);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	ass := make([][]int, h)
	for j := range ass {
		ass[j] = make([]int, w)
		for i := range ass[j] {
			ass[j][i] = 10000
		}
	}

	for j := range ass {
		var s string
		fmt.Scan(&s)
		for i, r := range s {
			if r == '#' {
				ass[j][i] = 0
			}
		}
	}

	for j := 0; j < h; j++ {
		for i := 0; i < w; i++ {
			if v := ass[j][i] + 1; i+1 < w && v <= ass[j][i+1] {
				ass[j][i+1] = v
			}
		}
	}
	for j := 0; j < h; j++ {
		for i := w - 1; i >= 0; i-- {
			if v := ass[j][i] + 1; i-1 >= 0 && v <= ass[j][i-1] {
				ass[j][i-1] = v
			}
		}
	}
	for i := 0; i < w; i++ {
		for j := 0; j < h; j++ {
			if v := ass[j][i] + 1; j+1 < h && v <= ass[j+1][i] {
				ass[j+1][i] = v
			}
		}
	}
	for i := 0; i < w; i++ {
		for j := h - 1; j >= 0; j-- {
			if v := ass[j][i] + 1; j-1 >= 0 && v <= ass[j-1][i] {
				ass[j-1][i] = v
			}
		}
	}

	ans := 0
	for _, as := range ass {
		for _, a := range as {
			if a > ans {
				ans = a
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 10112
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
template <typename T = int>
T in() {
    T temp; cin >> temp; return temp;
}

template <typename VType = int>
list<VType> const LR(VType start, VType end) {
    list<VType> ret; for (VType i = start; i < end; i++) ret.push_back(i); return move(ret);
}

bool func(int A, int B, int C) {
    if (A <= C && C <= B) return true;
    if (B <= C && C <=A) return true;
    return false;
}
int main() {
    int A(in()), B(in()), C(in());
    cout << (func(A, B, C) ? "Yes" : "No") << endl;
    return 0;
}




Measured memory_bytes: 256
n=int(input())
for i in range(n):
    a,b,c=map(int,input().split())
    if a*a+b*b == c*c :
        print("YES")
    elif b*b+c*c == a*a :
        print("YES")
    elif c*c+a*a == b*b :
        print("YES")
    else :
        print("NO")


Measured memory_bytes: 5600
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,A;
	cin >> N >> A;//N[1,50]枚のカード,A[1,50]平均
	vector<LL> X(N);
	for(int i=0;i<N;++i){
		cin >> X[i];
	}
	const int dpMAX = A*N;
	vector< vector<LL> > dp(N+1,vector<LL>(dpMAX+1,0));
	dp[0][0] = 1;
	
	for(int i=0;i<N;++i){
		for(int take=N-1;take>=0;--take){//take枚目
			const int indexMAX = dpMAX-X[i];
			for(int index=indexMAX;index>=0;--index){
				if( dp[take][index] ){
					dp[take+1][index+X[i]] += dp[take][index];
				}
			}
		}
	}
	LL ans = 0;
	for(int take=1;take<=N;++take){
		ans += dp[take][A*take];
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 1280
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint N, x;
	lint ans = 0;
	cin >> N >> x;
	vector<lint> a(N + 1, 0);

	for (int i = 1; i < N + 1; i++)
	{
		cin >> a[i];
		if (x < a[i - 1] + a[i])
		{
			lint tmp = (a[i - 1] + a[i]) - x;
			ans += tmp;
			a[i] -= tmp;
		}
	}
	cout << ans << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 1024
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
using namespace std;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if(b - a <= 0) cout << "delicious" << endl;
    else if(b - a <= x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define len 100005
using namespace std;
typedef struct pp
{
    char name[100];
    int t;
}p;
p Q[len];
int head,tail,n;
void enqueue(p x)
{
    Q[tail]=x;
    tail=(tail+1)%len;
}
p dequeue()
{
    p x=Q[head];
    head=(head+1)%len;
    return x;
}
int min(int a,int b)
{
    return a<b?a:b;
}
int main()
{
    int elaps=0,c;
    int i,q;
    p u;
    scanf("%d %d",&n,&q);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head=1;
    tail=n+1;
    while(head!=tail)
    {
        u=dequeue();
        c=min(q,u.t);
        u.t-=c;
        elaps +=c;
        if(u.t>0)
            enqueue(u);
        else{
            printf("%s %d\n",u.name,elaps);
        }
    }
    return 0;
}

Measured memory_bytes: 12756
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	double ans = 0.0;
	int cnt = 0;
	for (int i = 1; i < n+1; i++) {
		if (i % 2 == 1)cnt++;
	}

	ans = (double)(cnt) / n;

	cout << fixed << setprecision(10) << ans << endl;

	return 0;
}

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

typedef pair<int, int> ii;

int main()
{
  ll h,w; cin>>h>>w;
  ll ch, cw, dh, dw; cin>>ch>>cw>>dh>>dw;
  ch--; cw--; dh--; dw--;
  vector<string> s(h);
  rep(i, h) cin>>s[i];

  vector<vector<ll>> d(h, vector<ll>(w, inf));
  d[ch][cw] = 0;

  queue<ii> que, que2;
  que.push(ii{ch, cw});
  que2.push(ii{ch, cw});

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

  while(!que.empty()) {
    ii p = que.front(); que.pop();
    int gy = p.first;
    int gx = p.second;
    while (!que2.empty()) {
      ii t = que2.front(); que2.pop();
      int ny = t.first;
      int nx = t.second;
      int wall = 0;
      for (int i=0; i<4; i++) {
        int tx = nx + dx[i];
        int ty = ny + dy[i];
        if (tx < 0 || w <= tx || ty < 0 || h <= ty) continue;
        if (s[ty][tx] == '#') {
          wall++; continue;
        }
        if (d[ty][tx] <= d[ny][nx]) continue;
        d[ty][tx] = d[ny][nx];
        que2.push(ii{ty, tx});
      }
      if (wall == 0) continue;
      que.push(ii{ny, nx});
    }
    for (int i=-2; i<=2; i++) for (int j=-2; j<=2; j++) {
      int tx = gx + j;
      int ty = gy + i;
      if (tx < 0 || w <= tx || ty < 0 || h <= ty) continue;
      if (s[ty][tx] == '#') continue;
      if (abs(i)+abs(j) <= 1) continue;
      if (d[ty][tx] <= d[gy][gx] + 1) continue;
      d[ty][tx] = d[gy][gx] + 1;
      que.push(ii{ty, tx});
      que2.push(ii{ty, tx});
    }
  }

  if (d[dh][dw] == inf) cout << -1 << endl;
  else cout << d[dh][dw] << endl;

  return 0;
}


Measured memory_bytes: 13392
# -*- coding: utf-8 -*-
S = input()
T = input()

match_idx = 999
for i in range(len(S)-len(T)+1):
    unmatch = 0
    for s,t in zip(S[i:i+len(T)],T):
        if s != t and s != '?':
            unmatch = 1
    if unmatch == 0:
        match_idx = i


if match_idx > len(S)-len(T):
    print('UNRESTORABLE')
    exit()

xT = '?'*(match_idx) + T + '?'*(len(S)-len(T)-match_idx)

ans_list = []
for s,t in zip(S,xT):
    if s == '?' and t == '?':
        ans_list.append('a')
    elif s == '?':
        ans_list.append(t)
    else:
    # elif t == '?':
        ans_list.append(s)

print(''.join(ans_list))


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

ll solove(ll a, ll b, ll x){
    ll res = int((a*x)/b) - a* int(x/b);
    return res;
}

int main(int argc, char const *argv[]) {
    ll a,b,n; std::cin >> a >> b >> n;
    // ll ans = 0;
    // if (n < b) {
    //     ans = solove(a,b,n);
    //     ll temp = solove(a,b,min(b-1,n));
    //     ans = max(ans,temp);
    //
    // } else {
    //     //とりあえずnを試す
    //     ll temp_1 = solove(a,b,n);
    //     // x%b=b-1をのxの最大値を試す
    //     // ll syo = n/b;
    //     // ll kari = b*syo - 1;
    //     // ll temp_2 = solove(a,b,kari);
    //     // 最後に試しにb-1を試す
    //     ll temp_3 = solove(a,b,b-1);
    //     ans = max(temp_3,temp_1);
    //
    // }
    ll ans = solove(a,b,min(b-1,n));
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N+1),y(M+1);
  x[N] = X;
  y[M] = Y;
  for(int i=0; i<N; i++){
    cin >> x[i];
  }
  for(int i=0; i<M; i++){
    cin >> y[i];
  }
  sort(x.begin(),x.end(),greater<int>());
  sort(y.begin(),y.end());
  if(x[0]<y[0]){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }
  return 0;
}


Measured memory_bytes: 764
N = gets.to_i
Ai = gets.split.map(&:to_i).sort
M = (10 ** 9) + 7

if N.even?
  arr = (1..(N/2)).flat_map { |i| t = 2 * i - 1; [t, t] }
  if arr != Ai
    p 0
    exit
  end
else
  a, *b = Ai
  unless a.zero?
    p 0
    exit
  end
  arr = (1..(N/2)).flat_map { |i| t = 2 * i; [t, t] }
  if arr != b
    p 0
    exit
  end
end

p (2 ** (N/2)) % M


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

using namespace std;

int main()
{
  int n;
  cin>>n;
  if(n % 1000)
  {
    int ans = n/1000 + 1;
    ans = ans*1000 - n;
    cout<<ans;
  }
  else
  {
    cout<<0;
  }
  
  return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

set<int> isi;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int a=1;a<=n;a++)
    {
        int inp;
        cin>>inp;
        isi.insert(inp);
    }
    cout<<isi.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	int a;
	cin>>a;
	if(a%2)a*=2;
	cout<<a<<endl;
}







Measured memory_bytes: 256
x = int(input())
a = False
while a == False:
  b = list(range(1,x) ) 
  c = [x/c for c in b]
  d = [d.is_integer() for d in c[1:-1]]
  if not any(d):
    a = True
    break    
  else:
    x = x + 1
print(x)

Measured memory_bytes: 16584
from collections import deque

section = input( )
depth = 0
area = 0
depthArr = deque( )
areaArr = deque( )

for i, ground in enumerate( section ):
	if "\\" == ground:
		depth += 1
		depthArr.append( i )
	elif 0 < depth and "/" == ground:
		if len( depthArr ):
			j = depthArr.pop( )
			pool =  i - j
			area += pool

			while len( areaArr ):
				preJ, prePool = areaArr.pop( )
				if j <= preJ:
					pool += prePool
				else:
					areaArr.append( ( preJ, prePool ) )
					break
			areaArr.append( ( j, pool ) )

print( area )
output = []
output.append( len( areaArr ) )
for arr in areaArr:
	output.append( arr[1] )
print( " ".join( map( str, output ) ) )

Measured memory_bytes: 7484
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    
    if(a == 1 && b == 0 && c == 0){
        cout << "Close";
    }
    else if(a == 0 && b == 1 && c == 0){
        cout << "Close";
    }
    else if(a == 1 && b == 1 && c == 0){
        cout << "Open";
    }
    else if(a == 0 && b == 0 && c == 1){
        cout << "Open";
    }
    else{
        cout << "Close";
    }
    cout << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t,ans="";
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='B'){
      t=ans.substr(0,ans.size()-1);
      ans=t;
    }else{
      ans+=s[i];
    }
  }
  cout << ans << endl;
  return 0;
}


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

using ll = long long int;
using P = pair<int, int>;
using P3 = pair<int,P>;
using PP = pair<P, P>;
constexpr int INF = 1<<30;
constexpr ll MOD = ll(1e9)+7;
constexpr int di[] = {0,1,0,-1};
constexpr int dj[] = {1,0,-1,0};


bool solve(){
    int m, n;
    cin >> m >> n;
    vector<string> s(m), t(2);
    for(int i=0;i<m;i++){
        cin >> s[i];
    }
    for(int i=0;i<2;i++){
        cin >> t[i];
    }
    int ans = 0, cnt = 0;
    for(int i=0;i<m-1;i++){
        for(int j=0;j<n-1;j++){
            bool ok = true;
            for(int k=0;k<4;k++){
                ok &= s[i+k/2][j+k%2] == t[k/2][k%2];
            }
            if(ok) cnt++;
        }
    }
    char c[4] = {' ', 'J','O', 'I'};
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            char tmp = s[i][j];
            int d0 = 0;
            c[0] = tmp;
            for(int x=0;x<4;x++){
                int diff = 0;
                bool ok = true;
                s[i][j] = c[x];
                if(i<m-1 && j<n-1){
                    for(int k=0;k<4;k++){
                        ok &= s[i+k/2][j+k%2] == t[k/2][k%2];
                    }
                    if(ok) diff++;
                }
                if(i<m-1 && j>0){
                    ok = true;
                    for(int k=0;k<4;k++){
                        ok &= s[i+k/2][j-1+k%2] == t[k/2][k%2];
                    }
                    if(ok) diff++;
                }
                if(i>0 && j<n-1){
                    ok = true;
                    for(int k=0;k<4;k++){
                        ok &= s[i-1+k/2][j+k%2] == t[k/2][k%2];
                    }
                    if(ok) diff++;
                }
                if(i>0 && j>0){
                    ok = true;
                    for(int k=0;k<4;k++){
                        ok &= s[i-1+k/2][j-1+k%2] == t[k/2][k%2];
                    }
                    if(ok) diff++;
                }
                if(x == 0) d0 = diff;
                ans = max(ans, cnt-d0+diff);
            }
            s[i][j] = tmp;
        }
    }
    cout << ans << endl;
    return true;
}

int main(){
    solve();
    return 0;
}



Measured memory_bytes: 3948
#include <iostream>
using namespace std;
int main(){
	char c;
	int n=0;
	while(cin>>c){
		n++;
		if(c=='U'||c=='D')continue;
		if(n%2==1)if(c=='R')continue;
		if(n%2==0)if(c=='L')continue;
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
struct data{
	double x,y;
	data(){}
	data(double x,double y):x(x),y(y){}
	bool operator < (const data& a) const{
		return atan2(x,y) < atan2(a.x,a.y);
	}
};
vector<data> A;
int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		double x,y;
		cin >> x >> y;
		if(EQ(x,0.0)&&EQ(y,0.0))continue;
		A.pb(data(x,y));
	}
	sort(all(A));
	double ans = 0.0;
	for(int i=0;i<A.size();i++){
		for(int j=0;j<A.size();j++){
			double xs = 0.0;
			double ys = 0.0;
			for(int k=i;;k=(k+1)%A.size()){
				xs += A[k].x;
				ys += A[k].y;
				if(k==j)break;
			}
			chmax(ans,sqrt(sq(xs)+sq(ys)));
		}
	}
	printf("%.15f\n",ans);
	return 0;
}


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

#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);

using namespace std;

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

const int MOD = 1000000007;


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

void sub_self(int& a, int b) {
	a -= b;
	if (a < 0) {
		a += MOD;
	}
}


const int INF = 1e9 + 5;

int main() {

	// fast input/output
	FAST_IO;

	string a, b;
	cin >> a >> b;
	vector<vector<pair<int, pair<int, int>>>> dp(a.length() + 1,
	        vector<pair<int, pair<int, int>>>(b.length() + 1, { -INF, {0, 0}}));
	// dp[i][j] -- the max total length so far
	dp[0][0] = {0, {0, 0}};
	for (int i = 0; i < (int)a.size(); ++i) {
		for (int j = 0; j < (int)b.size(); ++j) {
			if (a[i] == b[j]) {
				dp[i + 1][j + 1] = max(make_pair(dp[i][j].first + 1, make_pair(i, j)), dp[i + 1][j + 1]);
			}
			dp[i + 1][j] = max(dp[i + 1][j], make_pair(dp[i][j].first, make_pair(i, j)));
			dp[i][j + 1] = max(dp[i][j + 1], make_pair(dp[i][j].first, make_pair(i, j)));
		}
	}
	pair<int, pair<int, int>> ans = { 0, {0, 0}};
	for (int i = 0; i <= (int)a.size(); ++i) {
		for (int j = 0; j <= (int)b.size(); ++j) {
			ans = max(ans, make_pair(dp[i][j].first, make_pair(i, j)));
		}
	}
	string s = "";
	if(ans.first == 0) {
		cout<<"";
		return 0;
	}
	pair<int, int> cur = ans.second;
	while (!(cur.first == 0 || cur.second == 0)) {
		int i = cur.first;
		int j = cur.second;
		auto prev = dp[i][j].second; // a cell from which we came to (i,j)
		if (prev == make_pair(i - 1, j - 1)) {
			assert(a[i - 1] == b[j - 1]);
			s += a[i - 1];
		}
		cur = prev;
	}
	reverse(s.begin(), s.end());
	cout << s;
	return 0;
}


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

int main(void){
    string o,e;
    cin >> o >> e;
    int num = o.size() + e.size();
    if(num%2==0){
        num /= 2;
    for (int i = 0; i < num;i++){
        cout << o.at(i) << e.at(i);
    }
    cout << endl;
    return 0;
    }

    else{
         num = num / 2 + 1;
         for (int i = 0; i < num - 1;i++){
             cout << o.at(i) << e.at(i);
         }
         cout << o.at(num-1) << endl;
         return 0;
    }
}

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

int main() {
    int N,K; cin >> N >> K;
    vector<int> h(N);
    int ans = 0;
    for(int i = 0; i < N; i++)
        cin >> h.at(i);
    for(int i = 0; i < N; i++)
        if(h.at(i) >= K) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        String s = br.readLine().trim();
        String mmdd = s.substring(4);
        System.out.println("2018" + mmdd);


    }

}



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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;

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

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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= 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
  {
    mint res(*this);
    return res /= a;
  }
};

bool check(vector<P> s) {
  int h = 0;
  for(auto p : s) {
    int b = h+p.first;
    if(b < 0) return false;
    h += p.second;
  }
  return true;
}
int main()
{
  string s;
  cin >> s;
  int n = s.size();
  vector<pair<char, ll>> vec;
  ll count = 1ll;
  rep(i, n-1) {
    if(s[i] == s[i+1]) ++count;
    else {
      vec.emplace_back(s[i], count);
      count = 1;
    }
  }
  vec.emplace_back(s[n-1], count);
  vector<ll> a(n+1, 0ll);
  if(vec[0].first == '>') a[0] = vec[0].second;
  int i = 0;
  for(int s = 0; s < vec.size(); ++s) {
    if(vec[s].first == '<') {
      if(s < vec.size()-1) {
        rep(t, vec[s].second-1) {
          a[i+1] = a[i]+1;
          ++i;
        }
        a[i+1] = max(a[i]+1, vec[s+1].second);
        ++i;
      }
      else {
        rep(t, vec[s].second) {
          a[i+1] = a[i]+1;
          ++i;
        }
      }
    }

    if(vec[s].first == '>') {
      a[i+1] = vec[s].second-1;
      ++i;
      rep(t, vec[s].second-1) {
        a[i+1] = a[i]-1;
        ++i;
      }
    }
  }
  cout << (ll)accumulate(ALL(a), 0ll) << endl;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;

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

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

int main()
{
  int n,m,b,k;
  cin >> n >> m;
  int a[m];
  int count = 0;
  for(int i=0;i<m;i++) a[i] = 0;
  for(int i=0;i<n;i++){
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> b;
      a[b-1]++;
    }
  }
  for(int i=0;i<m;i++){
    if(a[i] == n) count++;
  }
  cout << count << endl;
  return 0;
}


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

one = 0
two = 0
four = 0
for i in a:
  if i%4 == 0: four += 1
  elif i%2 == 0: two += 1
  else: one += 1

if four-one-two%2 >= -1: print("Yes")
else: print("No")

Measured memory_bytes: 20016
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<unsigned long> layer(50);
vector<unsigned long> patty(50);

unsigned long burger(int n, unsigned long x){
	if(x<=0)
		return 0;
	else if (n == 0)
		return 1;
	else if(x <= 1+layer[n-1])
		return burger(n - 1, x - 1);
	else
		return patty[n - 1] + 1 + burger(n - 1, x - 2 - layer[n - 1]);
}

int main(){
	int n;
	unsigned long x;
	cin >> n >> x;
	layer[0] = 1;
	patty[0] = 1;

	for (int i = 0; i < n-1;i++){
		layer[i + 1] = 2 * layer[i] + 3;
		patty[i + 1] = 2 * patty[i] + 1;
	}

	cout << burger(n, x) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

template<typename value_type>
class fast_mod_combination
{
public:
	value_type mod_value;

	vector<value_type> mod_inv;
	vector<value_type> fact;
	vector<value_type> fact_inv;

public:
	fast_mod_combination() {}
	fast_mod_combination(const value_type& limit, const value_type& m)
		: mod_value(m), mod_inv(), fact(), fact_inv()
	{
		mod_inv.assign(limit + 1, 0);
		fact.assign(limit + 1, 0);
		fact_inv.assign(limit + 1, 0);

		mod_inv[1] = 1;
		fact[0] = 1;
		fact[1] = 1;
		fact_inv[0] = 1;
		fact_inv[1] = 1;

		for (value_type i = 2; i <= limit; i++)
		{
			mod_inv[i] = mod_value - ((mod_value / i) * mod_inv[mod_value % i] % mod_value);
			fact[i] = (fact[i - 1] * i) % mod_value;
			fact_inv[i] = (fact_inv[i - 1] * mod_inv[i]) % mod_value;
		}
	}

public:
	value_type process(const value_type& n, const value_type& r)
	{
		if (n < 0 || r < 0 || n < r) return 0;
		if (n == r || r == 0) return 1;

		return (fact[n] * (fact_inv[r] * fact_inv[n - r] % mod_value)) % mod_value;
	}
};

//fast_mod_combination<long long> fmc(N, MOD);
//long long result = fmc.process(n, r);

fast_mod_combination<long long> fmc;

const int MAX = 2e5 + 1;
const long long MOD = 1e9 + 7;

int N;

vector<vector<int>> adj;
vector<int> subsize;

vector<long long> dp;
vector<long long> result;

void dfs_size(int curr, int prev)
{
	subsize[curr] = 1;
	for (int next : adj[curr])
	{
		if (next == prev) continue;
		dfs_size(next, curr);

		subsize[curr] += subsize[next];
	}

	dp[curr] = fmc.fact[subsize[curr] - 1];
	for (int next : adj[curr])
	{
		if (next == prev) continue;
		dp[curr] = (dp[curr] * dp[next]) % MOD * fmc.fact_inv[subsize[next]] % MOD;
	}
}

void dfs_rerooting(int curr, int prev)
{
	if (prev == -1)
		result[curr] = dp[curr];
	else
		result[curr] = (result[prev] * fmc.fact[subsize[curr]] % MOD * fmc.fact_inv[subsize[curr] - 1] % MOD * fmc.fact[N - 1 - subsize[curr]] % MOD * fmc.fact_inv[(N - subsize[curr])]) % MOD;

	for (int next : adj[curr])
	{
		if (next == prev) continue;
		dfs_rerooting(next, curr);
	}
}

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

	fmc = fast_mod_combination<long long>(MAX, MOD);

	cin >> N;

	adj.assign(N, vector<int>());
	subsize.assign(N, 0);

	dp.assign(N, -1);
	result.assign(N, -1);

	for (int i = 0; i < N - 1; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;

		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	dfs_size(0, -1);
	dfs_rerooting(0, -1);

	for (int i = 0; i < N; i++)
	{
		cout << result[i] << "\n";
	}

	return 0;
}


Measured memory_bytes: 22516
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<vector>

using namespace std;

typedef long long ll;

const int MX = 105;
const int MM = 1000000007;

typedef pair<int,int> pii;

ll t[MX][MX*MX];

int add(int x, int y){
	return x+y >= MM? x+y-MM : x+y;
}

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	t[N+1][0] = 1;
	for(int i = N; i >= 1; i--){
		for(int j = 0; j < MX*MX; j++){
			if( t[i+1][j] == 0 ) continue;
			for(int k = 0; k <= K; k++){
				if( k <= i ){
					int p = (k + j) / i;
					t[i][p + j] = add(t[i][p+j], t[i+1][j]);
				}
				else{
					t[i][j] = add(t[i][j], t[i+1][j]);
				}
			}
		}
	}
	ll m = 1;
	for(int i = 2; i <= N+1; i++){
		for(int j = 0; j < MX*MX; j++){
			t[i][j] = t[i][j] * m % MM;
		}
		if(i != N+1) m = m*(K+1) % MM;
	}
	ll ans = 0;
	for(int i = 1; i <= N; i++){
		ans = add(ans, K*(K+1)/2 * m % MM);
	}
	for(int i = 1; i <= N; i++){
		for(int j = 0; j < MX*MX; j++){
			if( t[i+1][j] == 0 ) continue;
			for(int k = 0; k <= K; k++){
				int p = (j + k) / i;
				if( k <= i ){
					ans = add(ans, MM - t[i+1][j] * p % MM);
				}
			}
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, const char *argv[]) {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  double sum = accumulate(A.begin(), A.end(), 0);
  double judge = sum / (4.0 * (double)M);
  sort(A.begin(), A.end(), greater<int>());
  for (int i = 0; i < M; i++) {
    if((double)A[i] < judge){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


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

using namespace std;

int main(void) {

    vector<int> ar;
    int A, B, K;

    cin >> A >> B >> K;
    int t = 0;
    int limit = min (A, B);
    for(int i = limit; i > 0; i--){
        if(A % i == 0 && B % i == 0)
            ar.push_back(i);
    }   

    cout << ar[K - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll n;
  cin >> n;
  ll h[n];
  rep(i,n) cin >> h[i];
  ll ppdp,pdp,dp;
  ppdp=0;
  pdp=abs(h[1]-h[0]);
  for(int i=2; i<n; i++){
    dp = min(abs(h[i]-h[i-2])+ppdp,abs(h[i]-h[i-1])+pdp);
    swap(dp,pdp);swap(dp,ppdp);
  }
  cout << pdp << endl;

  
  return 0;
    

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define sf(n) scanf("%f",&n)
#define pf(n) printf("%.12f",n)
#define psp printf(" ")
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

//const int maxn = 2e5 + 7; 
//const int md = 1e9 + 7;

int main() {
	ll r, g; cin>>r>>g; cout<<(2*g - r)<<endl;
}

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

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
        int r, c;
        cin >> r >> c;
        int n;
        cin >> n;

        if(r < c)
            r = c;
        r = (n+r-1)/r;
        cout << r << '\n';

        
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 256